Every container can have one or more network interfaces. Currently, osctl supports only bridged or routed veth. To add or remove an interface to/from a container, the container has to be stopped.
vpsAdminOS has bridge
lxcbr0 by default, so unless you create your own bridge,
you can use this one. It comes with DHCP and NAT. To create a bridged interface,
osctl ct netif new bridge --link lxcbr0 myct01 eth0
When the container starts, it will have interface
eth0 configured by DHCP.
Routed veth is not linked with any bridge. Instead, the veth is routed on a network layer using an interconnecting network, e.g. /30 IPv4 network to connect the host and container veth pair. IP addresses belonging to the container are then routed through the interconnecting network. The advantage of routed veth over the bridged veth is that the interfaces are isolated. The containers are not connected on the link layer.
For example, say we have an interconnecting network
veth will get IP
10.100.10.101 and container veth
Any IP address/network can then be routed to the container via the interconnecting
network. Let's route IP
18.104.22.168 to our container. On the host, we would add
the IP address from the interconnecting network and route
the veth to the container:
ip address add 10.100.10.101/30 dev $hostveth ip route add 22.214.171.124/32 via 10.100.10.102 dev $hostveth
In the container, we'd first add the IP addresses from the interconnecting network, then the routed IP address and finally set default route through the host:
ip address add 10.100.10.102/30 dev eth1 ip address add 126.96.36.199/32 dev eth1 ip route add default via 10.100.10.101 src 188.8.131.52
You don't actually have to do that manually, because osctld manages all this for you. What you need to do is to select the interconnecting network and then assign IP addresses. osctld will manage the interfaces, addresses and routes.
osctl ct netif new routed --via 10.100.10.100/30 myct01 eth1
Both bridged and routed veth support IP address management. IP addresses can be added and removed even while the container is running.
osctl ct netif ip add myct01 eth0 184.108.40.206/32 osctl ct netif ip add myct01 eth0 220.127.116.11/32 osctl ct netif ip ls myct01 eth0 VERSION ADDR 4 18.104.22.168/32 4 22.214.171.124/32
IPv6 is supported as well.
The commands above make the networking simply work, because osctld is also
managing network configuration inside the container. It generates configs
based on the container's distribution and uses the
ip utility to configure
the network at runtime. Supported distributions include:
Unless your distribution is supported by osctld, only the host will be configured and you will have to configure the container networking on your own.