linux路由ip转发好处和坏处,Linux路由转发简介

aee5d49c2f549932281f1c4ebe70ba07.png

要求:

需要让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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值