三网卡服务器 配置三线三IP linux策略路由
标签:IP配置 多线多
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://zhanguo1110.blog.51cto.com/5750817/1889651
1、服务器IP地址配置
eth0: 120.52.139.30/29 网关 120.52.139.25 联通地址
eth1: 123.58.236.11/28 网关 123.58.236.1 电信地址
eth2 : 112.35.19.38/29 网关 112.35.19.33 移动地址
2、配置路由表标签
[root@ttonnet ~]# cat /etc/iproute2/rt_tables
#
# reserved values
#
255local
254main
253default
252cnc
251ct
250yd
0unspec
#
# local
#
#1inr.ruhep
3、执行下面的命令
ip route add default via 120.52.139.25 dev eth0 src 120.52.139.30 table cnc
ip rule add from 120.52.139.30 table cnc
ip route add default via 123.58.236.1 dev eth1 src 123.58.236.11 table ct
ip rule add from 123.58.236.11 table ct
ip route add default via 112.35.19.33 dev eth2 src 112.35.19.38 table yd
ip rule add from 112.35.19.38 table yd
4、把上面的命令放到开机自启动脚本
[root@ttonnet ~]# cat /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.
ip route add default via 120.52.139.25 dev eth0 src 120.52.139.30 table cnc
ip rule add from 120.52.139.30 table cnc
ip route add default via 123.58.236.1 dev eth1 src 123.58.236.11 table tel
ip rule add from 123.58.236.11 table tel
ip route add default via 112.35.19.33 dev eth2 src 112.35.19.38 table yd
ip rule add from 112.35.19.38 table yd
本文出自 “zhanguo1110” 博客,请务必保留此出处http://zhanguo1110.blog.51cto.com/5750817/1889651
转载于:https://blog.51cto.com/mengyao/1967479