Chinaunix首页 | 论坛 | 博客
  • 博客访问: 313175
  • 博文数量: 173
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1060
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-09 16:23
文章分类

全部博文(173)

文章存档

2015年(66)

2014年(107)

我的朋友

分类: LINUX

2015-01-08 09:38:03

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. 编辑路由表    

修改/etc/iproute2/rt_tables,添加内容:

252   net2

251  net3

#/etc/rc.lo添加原路返回路由

ip  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

本文来自于中国蓝客联盟

    • 本文来自:
阅读(615) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~