Na interface proxmox, havia uma seleção onde é possível definir para qual ponte virtual você pode apontar. Isso foi colocado errado:
Eu tenho 1 IP público e gostaria de compartilhar a conexão com a Internet para contêineres LXC rodando o Centos (nesta configuração) o host executa proxmox (baseado no debian). Se bem entendi, eu preciso de NAT masquerading, o problema é que o segundo recipiente que eu crio não obtém acesso à rede.
Configurações no host:
ifconfig:
eth0 Link encap:Ethernet HWaddr 0c:c4:7a:d9:1f:e8
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15789748 errors:0 dropped:3170 overruns:0 frame:0
TX packets:6323926 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13693916365 (12.7 GiB) TX bytes:1077829250 (1.0 GiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:11041 errors:0 dropped:0 overruns:0 frame:0
TX packets:11041 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:3907254 (3.7 MiB) TX bytes:3907254 (3.7 MiB)
veth104i0 Link encap:Ethernet HWaddr fe:b4:26:dc:aa:ac
inet6 addr: fe80::fcb4:26ff:fedc:aaac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:663 errors:0 dropped:0 overruns:0 frame:0
TX packets:10100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:62852 (61.3 KiB) TX bytes:883353 (862.6 KiB)
veth105i0 Link encap:Ethernet HWaddr fe:69:8f:16:a3:40
inet6 addr: fe80::fc69:8fff:fe16:a340/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:447158 errors:0 dropped:0 overruns:0 frame:0
TX packets:401684 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46903237 (44.7 MiB) TX bytes:5625117349 (5.2 GiB)
vmbr0 Link encap:Ethernet HWaddr 0c:c4:7a:d9:1f:e8
inet addr:*public IP* Bcast:***** Mask:255.255.0.0
inet6 addr:**** Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:503891 errors:0 dropped:0 overruns:0 frame:0
TX packets:527129 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5637105768 (5.2 GiB) TX bytes:61721641 (58.8 MiB)
vmbr1 Link encap:Ethernet HWaddr fe:69:8f:16:a3:40
inet addr:10.10.10.254 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::b42e:2eff:fe1a:5640/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:447158 errors:0 dropped:0 overruns:0 frame:0
TX packets:401684 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40643025 (38.7 MiB) TX bytes:5625117349 (5.2 GiB)
iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 10.10.10.0/24 !10.10.10.0/24
MASQUERADE all -- 10.10.10.0/24 anywhere
MASQUERADE all -- 10.10.10.0/24 !10.10.10.0/24
/ etc / network / interfaces
auto lo
iface lo inet loopback
iface eth0 inet manual
auto vmbr0
iface vmbr0 inet dhcp
netmask 255.255.255.0
gateway 143.169.254.254
bridge_ports eth0
bridge_stp off
bridge_fd 0
auto vmbr1
iface vmbr1 inet static
address 10.10.10.254
netmask 255.255.255.0
network 10.10.10.0
broadcast 10.10.10.255
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' ! -d '10.10.10.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 *public gateway* 0.0.0.0 UG 0 0 0 vmbr0
10.10.10.0 0.0.0.0 255.255.255.0 U 0 0 0 vmbr1
xxx.xxx.0.0 0.0.0.0 255.255.0.0 U 0 0 0 vmbr0
nos dois contêineres (o IP privado é diferente):
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.10.10.254 0.0.0.0 UG 0 0 0 eth0
10.10.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1031 0 0 eth0
ifconfig
eth0 Link encap:Ethernet HWaddr 2E:15:95:39:D1:17
inet addr:10.10.10.4 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::2c15:95ff:fe39:d117/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12437 errors:0 dropped:38 overruns:0 frame:0
TX packets:665 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1106036 (1.0 MiB) TX bytes:63024 (61.5 KiB)
/ etc / sysconfig / scripts de rede / ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.10.10.4
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
Como faço para obter rede para ambos os contêineres, e como um administrador de sistema geralmente descobre o que está errado aqui? Eu posso pingar do primeiro container para o host. Mas não do segundo container para o host ou o vizinho.
Tags lxc nat proxmox masquerade