ITPub博客

首页 > Linux操作系统 > Linux操作系统 > CentOS双网卡双IP设置

CentOS双网卡双IP设置

Linux操作系统 作者:dxm2025 时间:2015-01-08 09:39:52 0 删除 编辑

C

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.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

本文来自于中国蓝客联盟


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30015039/viewspace-1394149/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-11-09

  • 博文量
    169
  • 访问量
    233177