使用场景:
1.机器拥有多块网卡(eth0:gateway 192.168.1.1、eth1:gateway 192.168.2.1、eth2:gateway 192.168.3.1)
2.通过其中一块网卡(eth0:gateway 192.168.1.1)连通外网
3.其余网卡连通专用子网
TIP:
外网网卡首先启动
默认路由为外网网卡(eth0)所连网关
1 2 |
Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 U 0 0 0 eth0 |
到其他子网的路由分别根据子网网关设置
1 2 3 |
Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 192.168.2.1 255.255.255.0 U 0 0 0 eth1 192.168.3.0 192.168.3.1 255.255.255.0 U 0 0 0 eth2 |
原因:
专用子网一定在网关所在网段内,因此网关路由信息即可涵盖。
外网IP范围太大,网关路由仅是出口网段。设为默认路由方便进行管理配置。例:
百度服务器地址:220.181.111.85
搜狐服务器地址:124.16.31.151
外网出口路由是:192.168.1.1/24,其网段当然无法覆盖前述服务器的公网地址。
默认路由出口0.0.0.0/0 覆盖全网段,可以包含任意IPV4地址。
外网所有ip均通过默认路由出口,不用再行配置。
妈妈再也不用担心你们上网了,so easy!