2 个接口的路由表

2 个接口的路由表

我有以下接口

eth0 192.168.1.178 subnet mask 255.255.255.0 default gateway 192.168.1.1
eth1 10.4.0.6      subnet mask 255.255.255.252 default gateway 10.4.0.5

我希望 eth1 只能与 10.4.0.5/30 网络通信,其余流量应通过 192.168.1.1 。在此设置中,我无法 ssh 到 10.64.0.0/30 网络。

我该如何为此设置配置路由表?

这些是我当前的设置:

猫/等/网络/接口

interfaces(5) file used by ifup(8) and ifdown(8) 
Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

知识产权

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.178/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
       valid_lft 547025sec preferred_lft 547025sec
    inet6 fe80::d50:e658:eec:9444/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

7: eth1: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1436 qdisc pfifo_fast state UP group default qlen 1000
    link/ether YY:YY:YY:YY:YY:YY brd ff:ff:ff:ff:ff:ff
    inet 10.64.0.6/30 brd 10.64.0.7 scope global dynamic noprefixroute eth1
       valid_lft 5835sec preferred_lft 5835sec

路线-n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth0

0.0.0.0         10.64.0.5       0.0.0.0         UG    101    0        0 eth1

0.0.0.0         10.64.0.5       0.0.0.0         UG    102    0        0 eth1

10.64.0.4       0.0.0.0         255.255.255.252 U     101    0        0 eth1

192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 eth0

相关内容