Eu tenho um Ubuntu Server 16.04 LTS em execução em um servidor DELL R210 II com 2 placas de rede. Eu quero definir cada NIC com uma rede / gateway diferente para fornecer conexão de internet redundante para o servidor. Siga meu arquivo /etc/network/interfaces
:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto em1
iface em1 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameserver 8.8.8.8 8.8.4.4
# The secundary network interface
auto em2
iface em2 inet static
address 192.168.25.2
netmask 255.255.255.0
post-up ip route add 192.168.25.0/24 dev em2 src 192.168.25.2 table rt2
post-up ip route add default via 192.168.25.1 dev em2 table rt2
post-up ip rule add from 192.168.25.2/32 table rt2
post-up ip rule add to 192.168.25.2/32 table rt2
E este é o meu arquivo / etc / iproute2 / rt_tables:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 rt2
Eu fiz essa configuração de acordo com esta referência: link
Se 192.168.0.1 estiver inoperante, eu posso conectar-me ao servidor através do gateway 192.168.25.1. Se 192.168.25.1 estiver inoperante, eu também posso conectar o servidor pelo gateway 192.168.0.1.
Meu problema é que o servidor não pode acessar a Internet se o gateway 192.168.0.1 estiver desativado:
myuser@myserver:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.0.10 icmp_seq=1 Destination Host Unreachable
From 192.168.0.10 icmp_seq=2 Destination Host Unreachable
From 192.168.0.10 icmp_seq=3 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4014ms
pipe 3
myuser@myserver:~$ ping -I em2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.25.2 em2: 56(84) bytes of data.
From 192.168.25.2 icmp_seq=1 Destination Host Unreachable
From 192.168.25.2 icmp_seq=2 Destination Host Unreachable
From 192.168.25.2 icmp_seq=3 Destination Host Unreachable
^C
myuser@myserver:~$ ping 192.168.25.1
PING 192.168.25.1 (192.168.25.1) 56(84) bytes of data.
64 bytes from 192.168.25.1: icmp_seq=1 ttl=64 time=2.44 ms
64 bytes from 192.168.25.1: icmp_seq=2 ttl=64 time=0.220 ms
64 bytes from 192.168.25.1: icmp_seq=3 ttl=64 time=0.195 ms
64 bytes from 192.168.25.1: icmp_seq=4 ttl=64 time=0.209 ms
^C
--- 192.168.25.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.195/0.768/2.448/0.969 ms
A saída do ifconfig é:
em1 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::1a03:73ff:feeb:5370/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:64671928 errors:0 dropped:1 overruns:0 frame:0
TX packets:9052331 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:96568794836 (96.5 GB) TX bytes:909947279 (909.9 MB)
em2 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
inet addr:192.168.25.2 Bcast:192.168.25.255 Mask:255.255.255.0
inet6 addr: fe80::1a03:73ff:feeb:5371/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8177 errors:0 dropped:2 overruns:0 frame:0
TX packets:265 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2759155 (2.7 MB) TX bytes:38231 (38.2 KB)
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:285531 errors:0 dropped:0 overruns:0 frame:0
TX packets:285531 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:44372922 (44.3 MB) TX bytes:44372922 (44.3 MB)
Estes são os resultados das rotas / regras ip:
myuser@myserver:~$ ip rule show
0: from all lookup local
32764: from all to 192.168.25.2 lookup rt2
32765: from 192.168.25.2 lookup rt2
32766: from all lookup main
32767: from all lookup default
myuser@myserver:~$ ip route show
default via 192.168.0.1 dev em1 onlink
169.254.0.0/16 dev em2 scope link metric 1000
192.168.0.0/24 dev em1 proto kernel scope link src 192.168.0.10
192.168.25.0/24 dev em2 proto kernel scope link src 192.168.25.2
Qualquer ajuda é apreciada!