Wednesday, March 10, 2021

How can I set up NAT rules to allow LXC containers to access the internet?

So, we want to create a virtual network of LXC containers at my job for one reason or another they want to simulate what it would be like to have a bunch of different servers up and running. They want us to learn how to do this manually. Thus far I've set up an unmanaged NAT bridge(lxc allows you to create managed ones, but this wasn't allowed) and assigned it an IP. I've also created a container and assigned an IP to it as well.

Basically I used netplan with this config to create my bridge:

```yaml network: version: 2 renderer: networkd ethernets: <your interface>: dhcp4: yes bridges: vbr0: addresses: - xx.xx.xx.xx/24 ``` 

The bridge works and I intend to use the a /24 subnet to assign IPs to the containers. Nonetheless, they're unreachable to the internet and I'm not sure about how I should go to manipulate my NAT iptables to make my bridge and containers accessible to the internet.



No comments:

Post a Comment