I have replaced the IP with dummy IPs.
1.2.3.4 is the main IP
5.6.7.194 is the LXC Dedicated IP
Details for main server:
Main IP network interface 1.2.3.4
auto lo
iface lo inet loopback
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto vmbr1
iface vmbr1 inet manual
bridge_ports dummy0
bridge_stp off
bridge_fd 0
post-up /etc/pve/kvm-networking.sh
auto vmbr0
iface vmbr0 inet static
address 1.2.3.4
netmask 255.255.255.0
gateway 1.2.3.254
broadcast 1.2.3.255
bridge_ports eth0
bridge_stp off
bridge_fd 0
network 1.2.3.0
iface vmbr0 inet6 static
address 2607:5300:120:00cc::
netmask 64
gateway 2607:5300:120:00FF:FF:FF:FF:FF
post-up /sbin/ip -f inet6 route add 2607:5300:120:00ff:ff:ff:ff:ff dev vmbr0
post-up /sbin/ip -f inet6 route add default via 2607:5300:120:00ff:ff:ff:ff:ff
pre-down /sbin/ip -f inet6 route del default via 2607:5300:120:00ff:ff:ff:ff:ff
pre-down /sbin/ip -f inet6 route del 2607:5300:120:00ff:ff:ff:ff:ff dev vmbr0
auto vmbr2
iface vmbr2 inet static
address 192.168.100.1
netmask 255.255.255.0
bridge_ports eth1
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.100.0/24' -o vmbr1 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o vmbr1 -j MASQUERADE
LXC container network interface file:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 5.6.7.194
netmask 255.255.255.255
broadcast 5.6.7.194
gateway 1.2.3.254
post-up ip route add 1.2.3.254 dev eth0
post-up ip route add default via 1.2.3.254
pre-down ip route del 1.2.3.254 dev eth0
pre-down ip route del default via 1.2.3.254
dns-nameservers 213.186.33.99 # OVH DNS Server
dns-search ovh.net # For faster hosts resolution on the OVH network
Main IP routing table
Main IP Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 1.2.3.254 0.0.0.0 UG 0 0 0 br0
default 1.2.3.254 0.0.0.0 UG 0 0 0 vmbr0
1.2.3.0 * 255.255.255.0 U 0 0 0 vmbr0
1.2.3.0 * 255.255.255.0 U 0 0 0 br0
192.168.100.0 * 255.255.255.0 U 0 0 0 vmbr2
LXC container Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 1.2.3.254 0.0.0.0 UG 0 0 0 eth0
1.2.3.254 * 255.255.255.255 UH 0 0 0 eth0
I am not able to resolve the networking issue. Its on OVH servers.Any has any idea?
Best Answer
The problem here is that your VM is on a different IP network
5.6.7.0/24
than the default gateway1.2.3.4
that you are trying to use. Of course this could be just a mistake in your question.However, if they are in different IP networks, you have two options for fixing it:
1) Bridge the public network facing interface with the VM's virtual interface, and assign a public IP to the VM from the main IP subnet, for example
1.2.3.5
. Then you can assign the1.2.3.254
as the default gateway in the VM. This option requires that you have public IPs available.2) Make a separate IP network between host and VM. In this case, you do not bridge the public network facing interface with the VM's virtual interface, but you assign a private network IP to the host VM interface, for example
192.168.121.1
.Then you assign
192.168.121.2
as the IP address in VM, and use192.168.121.1
as the default gateway.Finally, you need to add SNAT for the traffic from the private network, so that traffic from the private network is changed to come from the
1.2.3.4
IP. And for any traffic coming from outside to VM, you need to add DNAT for those ports in the host.