さまざまな指標/優先順位を持つ別々の物理インターフェイス用の複数のゲートウェイの追加

さまざまな指標/優先順位を持つ別々の物理インターフェイス用の複数のゲートウェイの追加

私のシステムには3つのインターフェースがあります。 eth0、eth1、usb0 です。

eth0は私のルータに接続されており、デフォルトで使用したい回線です。 eth1 は使用されません。 usb0はインターネットに接続された3G携帯電話です。

私の問題は、eth0とusb0を介して同時にインターネットにアクセスできるようにしたくないことです。現在、各インターフェイスに一致するようにゲートウェイを変更すると、他の接続は応答しなくなります。

インターフェイスファイルにインジケータ値を追加しようとしています。

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth0 usb0
iface lo inet loopback
        allow-hotplug eth0 usb0

# The primary network interface
iface eth0 inet static
        address 192.168.1.67
        netmask 255.255.255.0
        broadcast 192.168.1.254
        network 192.168.1.0
        post-up route add default gw 192.168.1.254 metric 1
        pre-down route del default gw 192.168.1.254


iface usb0 inet static
        address 192.168.42.86
        netmask 255.255.255.0
        broadcast 192.168.42.254
        network 192.168.42.0
        post-up route add default gw 192.168.42.129 metric 2
        pre-down route del default gw 192.168.42.129

残念ながら、起動時に実際にはusb0にのみアクセスできます。ルーティングを確認すると、eth0にゲートウェイがないことがわかります。

~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.42.129  0.0.0.0         UG    0      0        0 usb0
0.0.0.0         192.168.42.129  0.0.0.0         UG    2      0        0 usb0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.42.0    0.0.0.0         255.255.255.0   U     0      0        0 usb0

それらを介してインターネットに接続しようとしたとき。 eth0 は以下を提供します。

~# ping -I eth0 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.1.67 eth0: 56(84) bytes of data.
From 192.168.1.67 icmp_seq=1 Destination Host Unreachable
From 192.168.1.67 icmp_seq=2 Destination Host Unreachable
From 192.168.1.67 icmp_seq=3 Destination Host Unreachable
From 192.168.1.67 icmp_seq=4 Destination Host Unreachable
From 192.168.1.67 icmp_seq=5 Destination Host Unreachable
From 192.168.1.67 icmp_seq=6 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 6030ms

ただし、usb0はインターネットにアクセスできます。

~# ping -I usb0 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 192.168.42.86 usb0: 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=43 time=188 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=43 time=127 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=43 time=108 ms
64 bytes from 8.8.8.8: icmp_req=4 ttl=43 time=98.3 ms
64 bytes from 8.8.8.8: icmp_req=5 ttl=43 time=96.9 ms
64 bytes from 8.8.8.8: icmp_req=6 ttl=43 time=165 ms
64 bytes from 8.8.8.8: icmp_req=7 ttl=43 time=226 ms
^C
--- 8.8.8.8 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6002ms
rtt min/avg/max/mdev = 96.981/144.575/226.027/46.357 ms

何が間違っているのかわかりません。場合によっては(一般的ではありませんが)pingでは、次のような結果が得られます。

64 bytes from 8.8.8.8: icmp_req=3 ttl=43 time=132 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=43 time=672 ms (DUP!)
64 bytes from 8.8.8.8: icmp_req=3 ttl=43 time=1212 ms (DUP!)

どんな助けでも大変感謝します。

ベストアンサー1

おすすめ記事