灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:2307回复:0

CentOS双网卡双IP设置

楼主#
更多 发布于:2012-08-27 15:08

CentOS双网卡双IP设置

系统环境:CentOS Linux
网络环境: 两个IP地址,192.168.0.10和10.10.30.2,掩码是255.255.255.0,
这两个子网的网关地址分别是192.168.0.1和10.10.30.1。

1. 为网卡eth0配置ip地址192.168.0.10,为网卡eth1配置ip地址为10.10.30.2配置文件为:
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1

2. 配置默认网关为任意一个。这个默认网关,决定了系统主动去使用网络时,使用的接口。
配置文件:/etc/sysconfig/network

3. 编辑路由表  www.atcpu.com  
修改/etc/iproute2/rt_tables,添加内容:
252   net2
251  net3
#/etc/rc.local添加原路返回路由
ip route flush table net2
ip route add default via 192.168.0.1 dev eth0 src 192.168.0.10 table net2
ip rule add from 192.168.0.10 table net2
ip route flush table net3
ip route add default via 10.10.30.1 dev eth1 src 10.10.30.2 table net3
ip rule add from 10.10.30.2 table net3





喜欢0 评分0
游客

返回顶部