У меня две сетевые карты: enp4s0 имеет открытый статический ip (я отредактировал ip ниже). enp2s0 имеет локальный статический ip (за моим маршрутизатором, 192.168.0.1).
Все запросы должны по умолчанию проходить через enp4s0 , и все запросы, поступающие из enp2s0, должны быть возвращены в enp2s0 .
enp2s0 не имеет проблем с отправкой или получением запросов. enp2s0, с другой стороны, не может отправлять запросы, но получает SSH-соединения и pings все еще работает.
$ ping -I enp2s0 8.8.8.8
$ ping -I enp2s0 127.0.0.1
Результаты в тайм-ауте и
$ ping -I enp2s0 localhost
connect: Network is unreachable
Однако pinging маршрутизатор или любое другое локальное устройство работает.
$ ping -I enp2s0 192.168.0.1
$ ping -I enp2s0 192.168.0.3
/ etc / network / интерфейсы
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp4s0
iface enp4s0 inet dhcp
# The secondary network interface
allow-hotplug enp2s0
iface enp2s0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
post-up ip route add 192.168.0.0/24 dev enp2s0 src 192.168.0.2 table routetable
post-up ip route add default via 192.168.0.1 dev enp2s0 table routetable
post-up ip rule add from 192.168.0.2/32 table routetable
post-up ip rule add to 192.168.0.2/32 table routetable
/ etc / network / interfaces
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.11.136.1 0.0.0.0 UG 0 0 0 enp4s0
10.11.136.0 0.0.0.0 255.255.252.0 U 0 0 0 enp4s0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
$ ip route
default via 10.11.136.1 dev enp4s0
10.11.136.0/22 dev enp4s0 proto kernel scope link src 10.11.136.13
192.168.0.0/24 dev enp2s0 proto kernel scope link src 192.168.0.2
$ ip route
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 routetable
$ ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::222:15ff:fe3c:5d29 prefixlen 64 scopeid 0x20<link>
ether 00:22:15:3c:5d:29 txqueuelen 1000 (Ethernet)
RX packets 344 bytes 52868 (52.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 292 bytes 43536 (43.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 2 collisions 0
enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.11.136.13 netmask 255.255.252.0 broadcast 10.11.139.255
inet6 fe20::2ade:d0ff:fe01:4e4 prefixlen 64 scopeid 0x20<link>
ether 93:de:d0:03:02:e4 txqueuelen 1000 (Ethernet)
RX packets 2609 bytes 450767 (450.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2949 bytes 494772 (494.7 KB)
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 1000 (Local Loopback)
RX packets 848 bytes 68061 (68.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 848 bytes 68061 (68.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ifconfig
ifdown: interface enp2s0 not configured
Configuring interface enp2s0=enp2s0 (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/ifenslave
+ [ inet = meta ]
+ IF_BOND_SLAVES=
+ [ ]
+ [ ]
+ [ -z ]
+ exit
run-parts: executing /etc/network/if-pre-up.d/vlan
/bin/ip addr add 192.168.0.2/255.255.255.0 broadcast 192.168.0.255 dev enp2s0 label enp2s0
RTNETLINK answers: File exists
Failed to bring up enp2s0.
Я предлагаю, чтобы строка enp2s0 читалась:
# The secondary network interface
allow-hotplug enp2s0
iface enp2s0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1 8.8.8.8
Перезагрузите интерфейс:
sudo ifdown enp2s0 && sudo ifup -v enp2s0
Проверьте:
ping -c3 www.ubuntu.com
Я предлагаю, чтобы строка enp2s0 читалась:
# The secondary network interface
allow-hotplug enp2s0
iface enp2s0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1 8.8.8.8
Перезагрузите интерфейс:
sudo ifdown enp2s0 && sudo ifup -v enp2s0
Проверьте:
ping -c3 www.ubuntu.com