要求:
需要让Linux01通过Linux02访问Linux03,把Linux02转换成一个路由器。
实施步骤:
(1) 准备环境:Linux01(ip:10.0.0.10)Linux02(双网卡eth0:10.0.0.11 eth1:10.0.1.11)Linux03(ip:10.0.1.10)
(2) 配置Linux01,添加路由:route add -net 10.0.1.0/24 gw10.0.0.11
(3) 配置Linux02,开启路由转发功能:echo "1" >/proc/sys/net/ipv4/ip_forward
(4) 配置Linux03,添加路由:route add -net 10.0.0.0/24 gw10.0.1.11
(5) 关闭所有防火墙
Linux01:[root@oldboyedu39 ~]# traceroute -n 10.0.1.10
traceroute to 10.0.1.10 (10.0.1.10), 30 hops max, 60 byte packets
1 10.0.0.11 0.188 ms 0.141 ms 0.113 ms
2 10.0.1.10 0.676 ms 1.081 ms 1.048 ms
[root@oldboyedu39 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.1.0 10.0.0.11 255.255.255.0 UG 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
Linux03:[root@oldboyedu39 ~]# traceroute -n 10.0.0.10
traceroute to 10.0.0.10 (10.0.0.10), 30 hops max, 60 byte packets
1 10.0.1.11 3.137 ms 3.056 ms 3.000 ms
2 10.0.0.10 4.003 ms 3.981 ms 3.948 m
[root@oldboyedu39 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.0.0 10.0.1.11 255.255.255.0 UG 0 0 0 eth0
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0