您好,欢迎访问利联科技官网!    24小时服务热线:400-161-0880    我们有最适合您的产品和最好的服务。登录  /  注册  /  旧平台入口

centos 6.5 双线双网卡双IP配置教程

 

centos 6.5 双线双网卡双IP配置教程


服务器系统:centos 6.5 64位服务器系统


业务IP


120.41.32.101/26  eth0


36.250.79.101/26  eth1




第一部分:网卡文件配置




[root@localhost network-scripts]# cat ifcfg-eth0


#-------------------------------------------------------


DEVICE=eth0


TYPE=Ethernet


ONBOOT=yes


NM_CONTROLLED=yes


BOOTPROTO=static


IPADDR=120.41.32.101


NETMASK=255.255.255.192


GATEWAY=120.41.32.65


DNS1=8.8.8.8


DNS2=114.114.114.114




#-------------------------------------------------------


[root@localhost network-scripts]# cat ifcfg-eth1


DEVICE=eth1


TYPE=Ethernet


ONBOOT=yes


NM_CONTROLLED=yes


BOOTPROTO=static


IPADDR=36.250.79.101


NETMASK=255.255.255.192


#GATEWAY=120.41.32.65


DNS1=8.8.8.8


DNS2=114.114.114.114




第二部分:路由配置




1. 接下来,增加两个路由表,为后续的双网关做点小准备:




# vim /etc/iproute2/rt_tables




101 ChinaNet


102 ChinaCnc




2.手动添加静态路由




ip route flush table ChinaNet


ip route add default via 120.41.32.65 dev eth0 src 120.41.32.101 table ChinaNet


ip route add 127.0.0.0/8 dev lo table ChinaNet


ip rule add from 120.41.32.101 table ChinaNet




ip route flush table ChinaCnc


ip route add default via 36.250.79.65 dev eth1 src 36.250.79.101 table ChinaCnc


ip route add 127.0.0.0/8 dev lo table ChinaCnc


ip rule add from 36.250.79.101 table ChinaCnc




3.加入开机启动




# vim /etc/rc.local


#--------------------------------------------------------------


ip route flush table ChinaNet


ip route add default via 120.41.32.65 dev eth0 src 120.41.32.101 table ChinaNet


ip route add 127.0.0.0/8 dev lo table ChinaNet


ip rule add from 120.41.32.101 table ChinaNet




ip route flush table ChinaCnc


ip route add default via 36.250.79.65 dev eth1 src 36.250.79.101 table ChinaCnc


ip route add 127.0.0.0/8 dev lo table ChinaCnc


ip rule add from 36.250.79.101 table ChinaCnc


#--------------------------------------------------------------


您可能还会对下面的文章感兴趣: