Centos 7 executando na VM como configurar o gateway padrão - o ping google.com falha

1

Estou usando o Centos 7 em execução no Oracle VM VirtualBox Manager. Eu queria que meu windows (host) fosse capaz de pingar Centos 7 (convidado) então eu mudei as configurações de rede em VM para usar adaptador de rede somente host que funcionou bem como minhas janelas podem pingar ip da máquina vm mas máquina VM não tem conexão de rede . Parece ser um problema com o gateway padrão, como definir o gateway padrão? Qual é o valor correto do gateway padrão? para que haja conexão de rede disponível para a máquina vm.

Captura de tela da rede que não tem rota e DNS padrão

[root@hostname sysconfig]# ifconfig -a
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        inet6 fe80::42:48ff:fe73:32ae  prefixlen 64  scopeid 0x20<link>
        ether 02:42:48:73:32:ae  txqueuelen 0  (Ethernet)
        RX packets 1086312  bytes 190220822 (181.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2244812  bytes 1153561488 (1.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fe57:e658  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:57:e6:58  txqueuelen 1000  (Ethernet)
        RX packets 1083  bytes 112900 (110.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 166  bytes 24915 (24.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 70229  bytes 8733878 (8.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 70229  bytes 8733878 (8.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth0022793: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::541a:3bff:fefe:40fc  prefixlen 64  scopeid 0x20<link>
        ether 56:1a:3b:fe:40:fc  txqueuelen 0  (Ethernet)
        RX packets 206  bytes 15300 (14.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5850  bytes 272760 (266.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth0333914: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 16:78:ed:04:52:5e  txqueuelen 0  (Ethernet)
        RX packets 68480  bytes 84562622 (80.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 90298  bytes 14502209 (13.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth06f16da: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::4aa:47ff:fe36:c394  prefixlen 64  scopeid 0x20<link>
        ether 06:aa:47:36:c3:94  txqueuelen 0  (Ethernet)
        RX packets 51  bytes 4678 (4.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5823  bytes 267358 (261.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth16e581d: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2cb7:66ff:fe1a:a627  prefixlen 64  scopeid 0x20<link>
        ether 2e:b7:66:1a:a6:27  txqueuelen 0  (Ethernet)
        RX packets 8  bytes 648 (648.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5769  bytes 262582 (256.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth1ecf198: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2022:c4ff:fe1c:9ab5  prefixlen 64  scopeid 0x20<link>
        ether 22:22:c4:1c:9a:b5  txqueuelen 0  (Ethernet)
        RX packets 8  bytes 648 (648.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5773  bytes 262882 (256.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth8536f91: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::ac21:2fff:fe0e:87e6  prefixlen 64  scopeid 0x20<link>
        ether ae:21:2f:0e:87:e6  txqueuelen 0  (Ethernet)
        RX packets 841994  bytes 71927871 (68.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1841996  bytes 992110236 (946.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethda88d72: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::f44c:52ff:fe6c:b856  prefixlen 64  scopeid 0x20<link>
        ether f6:4c:52:6c:b8:56  txqueuelen 0  (Ethernet)
        RX packets 8  bytes 648 (648.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5759  bytes 261746 (255.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:ce:19:b8  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0-nic: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:ce:19:b8  txqueuelen 500  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


[root@hostname network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=dc80dadc-3072-428f-888f-25dc8dcd8ca9
DEVICE=enp0s3
ONBOOT=no
[root@hostname network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-lo
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0

[root@hostname network-scripts]# cat /etc/resolv.conf 
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com


[root@hostname sysconfig]# ip route show
172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1 
192.168.56.0/24 dev enp0s3  proto kernel  scope link  src 192.168.56.101  metric 100 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 
[root@hostname sysconfig]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.56.0    0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
[root@hostname sysconfig]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.56.0    0.0.0.0         255.255.255.0   U     100    0        0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
[root@hostname sysconfig]# ifconfig enp0s3
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fe57:e658  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:57:e6:58  txqueuelen 1000  (Ethernet)
        RX packets 1070  bytes 110928 (108.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 164  bytes 24513 (23.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@hostname sysconfig]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
192.168.56.0    0.0.0.0         255.255.255.0   U         0 0          0 enp0s3
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

[root@hostname sysconfig]# ip route list
172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1 
192.168.56.0/24 dev enp0s3  proto kernel  scope link  src 192.168.56.101  metric 100 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1 

[root@hostname sysconfig]# ping google.com
ping: unknown host google.com
[root@hostname sysconfig]# nslookup google.com
;; connection timed out; trying next origin
;; connection timed out; no servers could be reached
    
por skyblue2323 08.12.2016 / 19:09

1 resposta

2

Esse é o comportamento esperado. A utilização da rede somente para host permite apenas conexões entre o host e a VM, ou entre VMs no mesmo host , como o nome sugere. No manual: "... e as máquinas virtuais não podem falar com o mundo fora do host, uma vez que elas não estão conectadas a uma interface de rede física".

Se você quiser estabelecer conexões de rede do host para o convidado e do convidado para o mundo externo, provavelmente desejará um adaptador de rede em ponte.

    
por 08.12.2016 / 19:36