CentOS 双网卡双 IP 设置
2014-05-12 16:51
274 查看
http://my.oschina.net/wellben/blog/75358
系统环境: CentOS6.3
网络环境: 两个 IP 地址(双网卡), 192.168.18.160 和 192.168.19.160, 掩码是 255.255.255.0
这两个子网的网关地址分别是: 192.168.18.254 和 192.168.19.254
1. 为网卡 em2 配置 ip 地址 192.168.19.160, 为网卡 em3 配置 ip 地址为 192.168.18.160 配置文件为:
/etc/sysconfig/network-scripts/ifcfg-em2
/etc/sysconfig/network-scripts/ifcfg-em3
2. 配置默认网关为任意一个. 这个默认网关, 决定了系统主动去使用网络时, 使用的接口.
修改配置文件: /etc/sysconfig/network, 添加内容:
GATEWAYDEV=em3
3. 编辑路由表
修改 /etc/iproute2/rt_tables, 添加内容:
252 net2
251 net3
修改 /etc/rc.local 添加原路返回路由
ip route flush table net2
ip route add default via 192.168.18.254 dev em3 src 192.168.18.160 table net2
ip rule add from 192.168.18.160 table net2
ip route flush table net3
ip route add default via 192.168.19.254 dev em2 src 192.168.19.160 table net3
ip rule add from 192.168.19.160 table net3
4. 在 Windows 下验证, 跟踪路由情况:
ping 192.168.18.160
ping 192.168.19.160
tracert 192.168.18.160
tracert 192.168.19.160
5. 桥接模式下注意事项(通过 kvm 虚拟机实践)
a. 默认网关一定要设置在桥上, 如(br100):
IPADDR=192.168.19.160
NETMASK=255.255.255.0
GATEWAY=192.168.19.254
修改配置文件: /etc/sysconfig/network 的 GATEWAYDEV 为桥:
GATEWAYDEV=br100
b. 桥上不能设置 UUID、HWADDR, 一定要设置在物理网卡上, 否则重启后找不到网卡.
PS: 在此次跌倒无数次, 每次都 rm -rf /etc/udev/rules.d/70-persistent-net.rules, 修改 em2 并关闭桥接.
重启后 em2 正常, 每次又开启桥并 service network restart, 桥正常了. 这样来来回回折腾死了.
最后才发现该问题, 必须设置在物理网卡上. 缺乏网络知识啊!
c. 原路返回 /etc/rc.local 处对应的地方需要修改成桥的名称, 如:
ip route flush table net3
ip route add default via 192.168.19.254 dev br100 src
192.168.19.160 table net3
ip rule add from 192.168.19.160 table net3
6. 最后记得重启机器
系统环境: CentOS6.3
网络环境: 两个 IP 地址(双网卡), 192.168.18.160 和 192.168.19.160, 掩码是 255.255.255.0
这两个子网的网关地址分别是: 192.168.18.254 和 192.168.19.254
1. 为网卡 em2 配置 ip 地址 192.168.19.160, 为网卡 em3 配置 ip 地址为 192.168.18.160 配置文件为:
/etc/sysconfig/network-scripts/ifcfg-em2
/etc/sysconfig/network-scripts/ifcfg-em3
2. 配置默认网关为任意一个. 这个默认网关, 决定了系统主动去使用网络时, 使用的接口.
修改配置文件: /etc/sysconfig/network, 添加内容:
GATEWAYDEV=em3
3. 编辑路由表
修改 /etc/iproute2/rt_tables, 添加内容:
252 net2
251 net3
修改 /etc/rc.local 添加原路返回路由
ip route flush table net2
ip route add default via 192.168.18.254 dev em3 src 192.168.18.160 table net2
ip rule add from 192.168.18.160 table net2
ip route flush table net3
ip route add default via 192.168.19.254 dev em2 src 192.168.19.160 table net3
ip rule add from 192.168.19.160 table net3
4. 在 Windows 下验证, 跟踪路由情况:
ping 192.168.18.160
ping 192.168.19.160
tracert 192.168.18.160
tracert 192.168.19.160
5. 桥接模式下注意事项(通过 kvm 虚拟机实践)
a. 默认网关一定要设置在桥上, 如(br100):
IPADDR=192.168.19.160
NETMASK=255.255.255.0
GATEWAY=192.168.19.254
修改配置文件: /etc/sysconfig/network 的 GATEWAYDEV 为桥:
GATEWAYDEV=br100
b. 桥上不能设置 UUID、HWADDR, 一定要设置在物理网卡上, 否则重启后找不到网卡.
PS: 在此次跌倒无数次, 每次都 rm -rf /etc/udev/rules.d/70-persistent-net.rules, 修改 em2 并关闭桥接.
重启后 em2 正常, 每次又开启桥并 service network restart, 桥正常了. 这样来来回回折腾死了.
最后才发现该问题, 必须设置在物理网卡上. 缺乏网络知识啊!
c. 原路返回 /etc/rc.local 处对应的地方需要修改成桥的名称, 如:
ip route flush table net3
ip route add default via 192.168.19.254 dev br100 src
192.168.19.160 table net3
ip rule add from 192.168.19.160 table net3
6. 最后记得重启机器
相关文章推荐
- CentOS 双网卡双 IP 设置
- CentOS多网卡单个ip和单个网卡多个ip的设置
- CentOS 网卡、网关、DNS、IP设置
- VM下Centos7单块网卡既可设置固定ip又可上网的方案
- centOS配置静态IP,设置网卡的名字
- VMware workstation CentOs 7 虚拟机网卡设置为NAT模式并设置固定IP
- CentOS双网卡双IP设置
- centos 和 ubuntu 下单网卡设置多个IP
- CentOS 网络基础:(5)设置多网卡绑定单IP
- CentOS设置网卡成DHCP动态获取IP
- 如何在CentOS中把网卡设置成动态获取IP
- Centos系统的单网卡绑定双ip的设置
- centos 双网卡双IP设置
- CentOS 双网卡双 IP 设置
- centos绑定多个ip CentOS一个网卡设置多个IP
- centos-6.2安装完后没有eth0网卡,无法设置ip的解决方法
- CentOS双网卡双IP设置
- 【linux】centos6.9设置etc0网卡开机自动获取ip
- centos-6.2安装完后没有eth0网卡,无法设置ip的解决方法
- CentOS设置网卡成DHCP动态获取IP