Networking
Currently, ops
supports two networking modes; usermode and bridged. In this document we will dive into the differences between these networking modes and when it makes sense to select one over the other.
Native Networking
Note that by default you should probably just use the native networking provided by your cloud provider. These instructions only exist if you wish to build your own private cloud.
Usermode Network
Usermode is the default and simplest mode of networking. It utilizes the ready available network connection and shares it with the ops instance.
It is worth noting that the simplicity of usermode does come at a performance cost. Therefore, while usermode is a good option for demos, testing, and local development; it may not be a good choice for production environments.
No action is required to configure usermode networking, it is used by default.
Usermode does nat on a port but sometimes you'll want to add dns. This is fairly straight-forward to do. Again - this is only for dev/test not production deploys:
server:
build/run:
client:
You just need to include a /etc/hosts entry for your client to talk to 10.0.2.2:
Sample config:
Bridged Network
Bridged networking connects a virtual machine to a network using the host computer's Ethernet adapter. For more information about bridged networking, see this article.
We only recommend running bridge networking for local dev environments or environments where you are planning on having full control over orchestration. We do not recommend running this on the cloud as it'll be slow. You should instead use the native cloud deploy options (eg: ops instance create -t gcp
) as they will be using bridges underneath.
Via Instance Create
If you are on a Mac M1, M2 or M3 we recommend grabbing OPS desktop as it has vmnet-bridged support enabled by default and is pre-setup to run correctly. This way of working with bridges is much nicer too as you don't have to configure anything. Using this 'ops instance create' for the on-prem target will use bridge networking by default.
If you want to build yourself you need at least qemu 7.1 or qemu HEAD from brew. You currently need to be root, or in a proper group or set the suid bit (chmod +s) to the qemu binary.
On Mac creating a new instance with bridge support is easy as running:
On Linux:
To create a new network and attach a dhcp server to it:
Then you can create a new instance with this sample config:
Then you can run it:
Via Ops Run
Ops run currently only supports using a bridge on linux - not a mac. If you are on a mac you should use 'instance create' with the 'onprem' provider. This automatically manages bridges for you.
Here is a simple Go example demonstrating two applications sitting on their respective tap interfaces:
You'll either need the appropriate permissions or you can just give yourself sudo then you can run:
You may also optionally set the bridgeip like so:
Note: On the mac for 'ops run', you won't be able to use this syntax as there is no actual ethernet card (for most laptops).
IPv6
IPv6 support varies from cloud to cloud. Please consult the individual instructions found for each cloud:
Last updated