私のルーターにLAN(192.168.0.1/24)とDMZ(192.168.1.1/24)があるとしましょう。マイコンピュータには2つのネットワークカードがあり、1つはLAN用、もう1つはDMZ用です。
デフォルトゲートウェイの代わりに両方のゲートウェイを使用するようにパスを設定するにはどうすればよいですか?
出力ifconfig
:
eth0 Link encap:Ethernet HWaddr 00:15:17:6f:94:44
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:458357 errors:0 dropped:0 overruns:0 frame:0
TX packets:250537 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:646967588 (616.9 MiB) TX bytes:33742301 (32.1 MiB)
Interrupt:16 Memory:fc3e0000-fc400000
eth1 Link encap:Ethernet HWaddr 00:1e:4f:13:31:b7
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:320 (320.0 B) TX bytes:2992 (2.9 KiB)
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:18979 errors:0 dropped:0 overruns:0 frame:0
TX packets:18979 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:10059282 (9.5 MiB) TX bytes:10059282 (9.5 MiB)
tap103i0 Link encap:Ethernet HWaddr 3e:fb:b1:e0:40:da
inet6 addr: fe80::3cfb:b1ff:fee0:40da/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:520 errors:0 dropped:0 overruns:0 frame:0
TX packets:766 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:44796 (43.7 KiB) TX bytes:702165 (685.7 KiB)
vmbr0 Link encap:Ethernet HWaddr 00:15:17:6f:94:44
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:fe6f:9444/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:437651 errors:0 dropped:0 overruns:0 frame:0
TX packets:245697 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:637230824 (607.7 MiB) TX bytes:31203868 (29.7 MiB)
vmbr1 Link encap:Ethernet HWaddr 00:1e:4f:13:31:b7
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::21e:4fff:fe13:31b7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:230 (230.0 B) TX bytes:2412 (2.3 KiB)
出力netstat -rn
:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 vmbr0
192.168.0.0 192.168.0.1 255.255.255.0 UG 0 0 0 vmbr0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 vmbr0
192.168.1.0 192.168.1.1 255.255.255.0 UG 0 0 0 vmbr1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 vmbr1
/etc/network/interfaces
:
auto lo
iface lo inet loopback
iface eth0 inet manual
iface eth1 inet manual
auto vmbr0
iface vmbr0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
post-up route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1
auto vmbr1
iface vmbr1 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.0.2
bridge_ports eth1
bridge_stp off
bridge_fd 0
post-up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
ベストアンサー1
使用しているローカルIPアドレスによって異なるデフォルトルートを使用する必要がある場合は、iproute2が機能する場所です。
https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System