eth0 Link encap:Ethernet HWaddr D4:3D:7E:09:BB:AE
inet addr:223.100.133.142 Bcast:223.100.133.255 Mask:255.255.255.0
inet6 addr: fe80::d63d:7eff:fe09:bbae/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:781 errors:0 dropped:0 overruns:0 frame:0
TX packets:603 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:78887 (77.0 KiB) TX bytes:200637 (195.9 KiB)
Memory:dfca0000-dfcc0000
eth1 Link encap:Ethernet HWaddr D4:3D:7E:09:BB:AF
inet addr:172.17.72.6 Bcast:172.17.72.255 Mask:255.255.255.0
inet6 addr: fe80::d63d:7eff:fe09:bbaf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:148 errors:0 dropped:0 overruns:0 frame:0
TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9108 (8.8 KiB) TX bytes:6488 (6.3 KiB)
Memory:dfc40000-dfc60000
eth0 是外网 eth1是内网 要同时保持外网和内网172.16.72.16等内网联通
是否应该两个网卡均只设地址掩码不设其它 然后添加默认路由和内网路由???
route add default gw 223.100.133.1
ip route add -net 172.17.72.1 netmask 255.255.255.0 dev eth1
是这样吗???
linux 策略路由
答案:1 悬赏:10 手机版
解决时间 2021-02-16 21:27
- 提问者网友:泪痣哥哥
- 2021-02-16 00:35
最佳答案
- 五星知识达人网友:低音帝王
- 2021-02-16 01:12
1、查看本机路由信息 [root@Router ~]# ip route ls 192.168.70.0/24 dev eth0 proto kernel scope link src 192.168.70.70 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.70 169.254.0.0/16 dev eth1 scope link default via 192.168.1.1 dev eth0 2、确认是否需要改变默认路由 [root@Router ~]# ip route replace default via 192.168.70.254 dev eth0 table main [root@Router ~]# ip route ls 192.168.70.0/24 dev eth0 proto kernel scope link src 192.168.70.70 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.70 169.254.0.0/16 dev eth1 scope link default via 192.168.1.1 dev eth0 3、建立特殊路由表 [root@Router ~]# vi /etc/iproute2/rt_tables 255 local 254 main 253 default 200 test 4、向test路由表中添加它自己的默认路由 [root@Router ~]# ip route add default via 192.168.1.1 table test 注意:这个table test一定不要忘了写,否则写到了主路由表中 5、先看看机器当前的ip rule [root@Router ~]# ip rule ls 0: from all lookup local 32766: from all lookup main 32767: from all lookup default 可以看到,规则中走了3个路由表,local、main、default 我们平常用route看到的,实际是路由表main 这些规则是按序号大小顺序走的,一个不同,则走下一个,知道通路或走完为止 6、添加路由到路由表test中 [root@Router ~]# ip rule add to 59.76.0.0/16 pref 10000 table test 这个意思是说,去向IP地址范围为59.76.0.0/16的访问,则启用test的路由表中的路由规则 而test的路由规则是什么呢?上面已经设置了,走的是202.196.x.1的路由. 现在再来看一下当前的ip rule [root@Router ~]# ip rule ls 0: from all lookup local 10000: from all to 59.76.0.0/16 lookup test 32766: from all lookup main 32767: from all lookup default
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯