linux web服务器双线路配置

本文介绍如何在系统中配置两个网卡并设置相应的路由表,实现基于不同网卡的网络流量分离。通过创建和设置特定的路由表,可以指定不同网络流量通过不同的网关进行转发。

eth0 192.168.0.1/24 网关 192.168.0.254

eth1 192.168.1.1/24 网关 192.168.1.254


创建两个路由表,编辑 /etc/iproute/rt_tables增加两行: 

     100 ctc

      101 cmcc

设置路由:

ip route add 192.168.0.0/24 dev eth1 src 192.168.0.1 table ctc

ip route add default via 192.168.0.254 table ctc


ip route add 192.168.1.0/24 dev eth2 src 192.168.1.1 table cmcc

ip route add default via 192.168.1.254 table cmcc

设置你的缺省路由:

ip route add default via 192.168.0.1


ip rule add from 192.168.0.1 table ctc
ip rule add from 192.168.1.1 table cmcc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值