linux 系统单网卡绑定多个IP地址方法
2014-10-19 15:35
661 查看
如果linux 系统只有一个物理网卡,而在实际使用中,有时需要配置单网卡具备多个IP 地址。
步骤:
1、root登录 linux系统
2、查看现有网络配置
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vi ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.50.222
NETMASK=255.255.255.0
GATEWAY=192.168.50.1
3、配置新的虚拟网卡
注:仍然保留原有ifcfg-eth0文件,所以采用复制方式。
[root@localhost network-scripts]# cp ifcfg-eth0ifcfg-eth0:1
[root@localhost network-scripts]# viifcfg-eth0:1
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.1.1.100
NETMASK=255.255.255.0
GATEWAY=10.1.1.1
[root@localhost network-scripts]# service network restart
4、查看目前路由
route -n
Destination Gateway Genmask Flags MetricRef UseIface
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
如果只需要默认路由,则这样设置就可以啦。
如果需要不同的源IP地址走不同的默认路由,则定制举例如下:
route add -net 192.168.50.0/24 gw 192.168.50.1 dev eth0
route add -net 10.1.1.0/24 gw 10.1.1.1 deveth0:1
这样,源地址192.168.50.x网段默认走 eth0;源地址10.1.1.x的网段默认走eth0:1
其它的IP默认走eth0
查看路由信息如下:
route -n
Destination Gateway Genmask Flags MetricRef UseIface
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.50.0 192.168.50.1 255.255.255.0 UG 0 0 0 eth0
10.1.1.0 10.1.1.1 255.255.255.0 UG 0 0 0 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
用route -n 命令增加的路由在网络重启后,则路由丢失,可通过增加到rc.local 等多种方式实现永久保持。
<完>
原文:http://blog.sina.com.cn/s/blog_54dd9b610100h7ww.html
步骤:
1、root登录 linux系统
2、查看现有网络配置
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# vi ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.50.222
NETMASK=255.255.255.0
GATEWAY=192.168.50.1
3、配置新的虚拟网卡
注:仍然保留原有ifcfg-eth0文件,所以采用复制方式。
[root@localhost network-scripts]# cp ifcfg-eth0ifcfg-eth0:1
[root@localhost network-scripts]# viifcfg-eth0:1
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.1.1.100
NETMASK=255.255.255.0
GATEWAY=10.1.1.1
[root@localhost network-scripts]# service network restart
4、查看目前路由
route -n
Destination Gateway Genmask Flags MetricRef UseIface
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
如果只需要默认路由,则这样设置就可以啦。
如果需要不同的源IP地址走不同的默认路由,则定制举例如下:
route add -net 192.168.50.0/24 gw 192.168.50.1 dev eth0
route add -net 10.1.1.0/24 gw 10.1.1.1 deveth0:1
这样,源地址192.168.50.x网段默认走 eth0;源地址10.1.1.x的网段默认走eth0:1
其它的IP默认走eth0
查看路由信息如下:
route -n
Destination Gateway Genmask Flags MetricRef UseIface
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.50.0 192.168.50.1 255.255.255.0 UG 0 0 0 eth0
10.1.1.0 10.1.1.1 255.255.255.0 UG 0 0 0 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
用route -n 命令增加的路由在网络重启后,则路由丢失,可通过增加到rc.local 等多种方式实现永久保持。
<完>
原文:http://blog.sina.com.cn/s/blog_54dd9b610100h7ww.html
相关文章推荐
- Linux系统下一块网卡绑定多个Ip地址方法
- linux系统单网卡绑定多个IP地址
- linux系统单网卡绑定多个IP地址
- Linux系统下一块网卡配置多个Ip地址方法
- linux系统下单网卡绑定多个IP地址
- linux系统单网卡绑定双IP的方法
- LINUX系统一个网卡绑定多个IP的方法
- linux系统单网卡绑定多个IP地址
- linux系统双网卡绑定单个IP地址
- linux系统单网卡绑定多个IP地址 推荐
- linux系统单网卡绑定双IP的方法
- linux系统单网卡绑定双IP的方法
- LINUX系统一个网卡绑定多个IP的方法
- Linux系统下一块网卡配置多个ip地址方法
- Linux系统上双网卡绑定方法
- linux系统下单网卡绑定多个IP地址
- linux系统实现网卡绑定
- linux单块网卡绑定多个ip及网卡聚合绑定多个ip方法
- Linux系统下获得本机(通用网卡)ip地址