Não é possível conectar o macvlan à internet

Não é possível conectar o macvlan à internet

Quando tentei me conectar macvlanà internet e não tive sucesso. Eu usei namespace para fazer isso. Também verifiquei os comentários sobre esta questão -Como conectar o macvlan à internet?

Tenho máquina virtual EC2 (Ubuntu 20.04) da AWS, onde executei os seguintes comandos:

sudo ip netns add net1;
sudo ip link add macvlan1 link eth0 type macvlan mode bridge;
sudo ip link set macvlan1 netns net1;
sudo ip netns exec net1 ip address add 172.31.20.45 peer 172.31.16.1/32 dev macvlan1;
sudo ip netns exec net1 ip link set macvlan1 up; sudo ip netns exec net1 ip link set lo up;
sudo ip netns exec net1 ip route add default via 172.31.16.1;
sudo ip netns exec net1 su -c "screen";                           

Tentando executar ping no servidor DNS do Google a partir do namespace (conectar-se à Internet)

root@aws:/home/meliwex# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 172.31.20.45 icmp_seq=1 Destination Host Unreachable

Tentando fazer ping no gateway

root@aws:/home/meliwex# ping 172.31.16.1
PING 172.31.16.1 (172.31.16.1) 56(84) bytes of data.
From 172.31.20.45 icmp_seq=1 Destination Host Unreachable

Saída ifconfigno host (mantenho a saída simples):

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.20.45  netmask 255.255.240.0  broadcast 172.31.31.255
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0

A tabela de roteamento do host:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.31.16.1     0.0.0.0         UG    100    0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
172.31.16.0     0.0.0.0         255.255.240.0   U     0      0        0 eth0
172.31.16.1     0.0.0.0         255.255.255.255 UH    100    0        0 eth0

Saída ifconfigno namespace (mantenho a saída simples):

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
macvlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 172.31.20.45  netmask 255.255.255.255  broadcast 0.0.0.0

A tabela de roteamento do namespace:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.31.16.1     0.0.0.0         UG    0      0        0 macvlan1
172.31.16.1     0.0.0.0         255.255.255.255 UH    0      0        0 macvlan1

Então é possível consertar isso?

informação relacionada