標籤:路由轉寄
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M01/03/D3/wKiom1mhJSbyCvFfAACbjAuboPU453.jpg-wh_500x0-wm_3-wmp_4-s_1497226562.jpg" title="Linux路由轉寄簡易圖.jpg" alt="wKiom1mhJSbyCvFfAACbjAuboPU453.jpg-wh_50" />
要求:
需要讓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:
[[email protected] ~]# traceroute -n 10.0.1.10traceroute 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[[email protected] ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth010.0.1.0 10.0.0.11 255.255.255.0 UG 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
Linux03:
[[email protected] ~]# traceroute -n 10.0.0.10traceroute 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[[email protected] ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.0.0.0 10.0.1.11 255.255.255.0 UG 0 0 0 eth010.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
本文出自 “風雨山林” 部落格,請務必保留此出處http://fengyushanlin.blog.51cto.com/12092006/1959544
Linux路由轉寄簡介