Hello,
I have an Ubuntu 21.10 cloud instance which has several interfaces, one is connected to internet (ens3) and others connected to private networks.
I want to run lxc container with Ubuntu 22.04 which has internet access NAT through one nic and access to one of the private networks (ens13 - 192.168.1.0/24) through another nic.
If i create bridged network i am able to access all private networks.
I guess i should create routed 2 nic for lxc but how to configure them?
Thank you for the reply.
The LXD host has WAN connection on ens3 and private network 192.168.1.0/24 on ens13
For accessing internet i need routed nic to ens3 and for accessing private net - a routed nic to ens13.
I created container with the settings from your tutorial:
Now i have container with eth0 192.168.100.200/32 and gateway 169.254.0.1
Host has additional vethb5c9d2ad attached with IP 169.254.0.1/32
Still no internet, i added iptables rule:
Using SNAT instead of MASQUERADE because ens3 has multiple public IPs attached and not all of them may be attached on this host instance (it’s main purpose is load balancing). Internet started working.
How can i set the iptables rule permanent on reboot?
Is it possible to configure iptables in lxc profile? Or should i include it in Ubuntu netplan config for ens3?
How to configure second nic in lxc? If i add eth1 in profile devices
eth1:
ipv4.address: 192.168.1.59
nictype: routed
parent: ens13
type: nic
then launching lxc shows error:
Creating garb-intranet
Error: Failed instance creation: Failed creating instance record: Failed initialising instance: Invalid devices: Device validation failed for "eth0": Existing NIC "eth1" already uses "ipv4.gateway" in auto mode