红联Linux门户
Linux帮助

linux单网卡绑定两个ip

发布时间:2015-12-13 10:55:38来源:linux网站作者:阳台

一、ubuntu系统:

#vi /etc/network/interfaces  OR  $ sudo vi /etc/network/interfaces
Modify as follows:

auto eth0
auto eth0:0
auto eth0:1
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.248
gateway 192.168.1.254
iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.248
iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.248
# add rest of alias / binds below

Save and close the file.

Now restart networking, enter:
#/etc/init.d/networking restart  OR $ sudo /etc/init.d/networking restart


二、centos系统:
配置IP地址:
[root@localhost network-scripts]#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static  
ONBOOT=yes
IPADDR=192.168.0.2  
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
配置完以后:
service network restart
修改DNS
[aeolus@db1 etc]$ vi resolv.conf
nameserver 202.96.128.68
nameserver 219.136.241.206
添加网通IP:
[root@localhost network-scripts]#vi /etc/sysconfig/etwrok-scripts/ifcfg-eth0:0
DEVICE=eth0:0  #其中的DEVICE为设备的名称,
BOOTPROTO=static   #模式
ONBOOT=yes    #开机启动
IPADDR=192.168.0.3  #ip addr
NETMASK=255.255.255.0  #子网掩码
    
如果需要再绑定多一个IP地址,只需要把文件名和文件内的DEVICE中的eth0:X加一即可。


Ubuntu实现单网卡双IP的方法:http://www.linuxdiyf.com/linux/10593.html

CentOS和openSUSE单网卡双ip配置记录:http://www.linuxdiyf.com/linux/3331.html

CentOS/RHEL 6.2单网卡设置双IP:http://www.linuxdiyf.com/linux/1700.html

实战Ubuntu下单网卡绑定多IP:http://www.linuxdiyf.com/linux/889.html

Ubuntu单网卡架设VPN并NAT共享上网办法:http://www.linuxdiyf.com/linux/622.html