linux 2张网卡网关,linux 双网卡双网关配置

有这种需求的客户一般是国内和国外都有业务,需要用到国内和国际线路。 这里以 centos 6.5 配置为例!

说明:两个网卡都配置好 IP 信息,只有走默认网关的一条线路是通的,所以要用到策略路由来配置另一条线路的路由

1.ip rule add from 172.163.1.66 table 100 (添加 100 的路由表,用于此国内线路 IP)

ip rule add from 192.168.1.66 table 101 (添加 101 的路由表,用于此国外线路 IP)

然后用 ip rule show 查看策略路由,是否添加成功

2.策略路由添加好后,为两条线路指定网关

ip route add default via 172.163.1.1 table 100 (国内线路 IP 网关为172.163.1.1)

ip route add default via 192.168.1.1 table 101 (国外线路 IP 网关为172.163.1.1)

这样两条线路的路由已设置好,都能通了。没问题后把这 4 段命令写到

/etc/rc.local 文件里边,系统启动就会自动执行。如果没写到这个文件里边系统重启后会失效,再次启动后要重新以上操作

[root@oralcedb ~]# vi /etc/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don’t

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

ip rule add from 172.163.1.66 table 100

ip rule add from 192.168.1.66 table 101

ip route add default via 172.163.1.1 table 100 ip route add default via 192.168.1.1 table 101

喜欢 (1)or分享 (0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值