Dual NIC não está funcionando

1

Estou executando o Ubuntu Server 16.04 com duas placas de rede internas. O Ubuntu vê os dois cartões, mas tanto o eth0 quanto o eth1 só passarão tráfego de uma interface física, embora eles sejam configurados separadamente (eu acho). As informações estão abaixo:

lshw -C network
*-network
       description: Ethernet interface
       product: 82579LM Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: eth0
       version: 04
       serial: 54:be:f7:65:9a:9b
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=0.13-4 ip=172.22.1.112 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:26 memory:f7e00000-f7e1ffff memory:f7e39000-f7e39fff ioport:f080(size=32)
  *-network
       description: Ethernet interface
       product: 82574L Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: eth1
       version: 00
       serial: 54:be:f7:65:9a:9c
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=2.1-3 ip=172.22.1.113 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:18 memory:f7d00000-f7d1ffff ioport:e000(size=32) memory:f7d20000-f7d23fff

/etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The secondary network interface
auto eth1
iface eth1 inet dhcp

Obrigado por qualquer ajuda!

ifconfig:

eth0      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9b
          inet addr:172.22.1.112  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:61 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5880 (5.8 KB)  TX bytes:1436 (1.4 KB)
          Interrupt:20 Memory:f7e00000-f7e20000

eth1      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9c
          inet addr:172.22.1.113  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1093 errors:0 dropped:0 overruns:0 frame:0
          TX packets:575 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:88205 (88.2 KB)  TX bytes:42753 (42.7 KB)
          Interrupt:18 Memory:f7d00000-f7d20000

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:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

route -n:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.22.1.1      0.0.0.0         UG    0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0

rotear -n com eth0 desconectado. Não é possível acessar o endereço IP.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.22.1.1      0.0.0.0         UG    0      0        0 eth0
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
Script with eth0 disconnected

eth0      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9b
          inet addr:172.22.1.112  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9b/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:28527 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2202058 (2.2 MB)  TX bytes:1372 (1.3 KB)
          Interrupt:20 Memory:f7e00000-f7e20000

eth1      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9c
          inet addr:172.22.1.113  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31516 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1730 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6125004 (6.1 MB)  TX bytes:155950 (155.9 KB)
          Interrupt:18 Memory:f7d00000-f7d20000

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:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.22.1.1      0.0.0.0         UG    0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=27.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 time=25.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=58 time=27.8 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=58 time=26.6 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=58 time=26.6 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 25.818/26.897/27.860/0.733 ms


Script with eth1 disconnected

eth0      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9b
          inet addr:172.22.1.112  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:28540 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2202968 (2.2 MB)  TX bytes:1372 (1.3 KB)
          Interrupt:20 Memory:f7e00000-f7e20000

eth1      Link encap:Ethernet  HWaddr 54:be:f7:65:9a:9c
          inet addr:172.22.1.113  Bcast:172.22.1.255  Mask:255.255.255.0
          inet6 addr: fe80::56be:f7ff:fe65:9a9c/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:31528 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1735 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6125988 (6.1 MB)  TX bytes:156460 (156.4 KB)
          Interrupt:18 Memory:f7d00000-f7d20000

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:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.22.1.1      0.0.0.0         UG    0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
172.22.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4031ms
    
por Anthony Rivera 17.03.2017 / 18:23

1 resposta

-1

Ambas as NICs estão funcionando. Um deles tem os endereços IP individuais de:

eth0: 172.22.1.112
    and
etho1: 172.22.1.113

Você pode verificar se os dois estão funcionando fazendo ping de um dos endereços IP:

$ ping -c10 172.22.1.112
$ ping -c10 172.22.1.113

Se você tiver outro computador em sua rede, também poderá acessar seu computador a partir de um dos endereços IP.

Se você configurar um servidor da Web em sua máquina, poderá acessar o servidor da web usando um dos endereços IP:

http://172.22.1.112
http://172.22.1.113

O acesso (a saída que você vê com um desses exemplos é a verificação de que ambos estão funcionando. Além disso, o fato de seu dhcp server poder acessá-los e atribuir endereços IP é outra verificação de que eles estão funcionando.

Execute este script para testar as NICs separadas:

Copie e cole o script abaixo. Você pode nomear: testnic.sh . Execute o script individualmente enquanto cada nic estiver conectado ao computador e ao roteador / modem.

testnic.sh:

#!/bin/bash

ifconfig
route -n
sudo route del default gw 172.22.1.1
sudo route add default gw 172.22.1.1
ping -c5 8.8.8.8

Execute o comando como:

$ ./testnic.sh

Mostre o comando e a saída.

Atualização:

Sua saída anterior mostra que o problema, conforme mencionado, está na rota. Você tem que apagar a raiz anterior quando você remover esse nic, então crie outra rota em seu lugar.

Abaixo está um script de exemplo para ajudá-lo nessa tarefa. O script terá que ser testado e ajustado para o seu ambiente. Mas a resposta à sua pergunta é específica, e as duas estão funcionando. A diferença que você está vendo é o resultado de como você os configurou.

Ao remover um NIC, altere sua configuração de rede para usar o roteamento de um remining.

Este é outro exemplo de script para facilitar a alteração de configurações quando você alterna as NICs.

#!/bin/bash

currentroute=$(route -n | awk '/UG/{print $NF}')
available="none"

route="0"
available="none"
find /sys/class/net/en* -exec echo "{}/operstate" \; | while read line; do
    # echo "[$line]"    
    IFS='/' read -r -a array <<< "$line"
    device="${array[4]}"
    state="$(cat $line)"
    thisdevice="$device:$state"
    if [[ "$thisdevice" == "$currentroute:down" ]] ; then
        route="0"
    fi
    if [[ "$state" == "up" ]]
    then
        echo "The device $device is available"
        echo "$device" > /tmp/available             
    fi 
done
read -r available </tmp/available
if [[ "$route" == "0" ]]; then
    route del default gw 172.22.1.1 $currentdevice
    route add default gw 172.22.1.1 $available
fi

echo "[$route/$available]"
    
por L. D. James 17.03.2017 / 19:00