debian与centos上单网卡配置多个IP
debian与contos单网卡绑定多个IP,如果是远程操作的话(如:ssh),切记要重启网卡的时候要 || ifup eth0
否则第二个IP或第二个配置文件有问题将导致网络中断,我的debian就断了….
- root@debian:/etc/network# cat interfaces
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- allow-hotplug eth0
- iface eth0 inet static
- address 10.0.0.212
- netmask 255.255.255.0
- network 10.0.0.0
- broadcast 10.0.0.255
- gateway 10.0.0.1
- # dns-* options are implemented by the resolvconf package, if installed
- dns-nameservers 10.0.0.1
- allow-hotplug eth0:1
- iface eth0:1 inet static
- address 10.0.0.145
- netmask 255.255.255.0
- network 10.0.0.0
- broadcast 10.0.0.255
- gateway 10.0.0.1
contos单网卡配置多个IP
- [root@localhost network-scripts]# ls |grep ifcfg-eth
- ifcfg-eth0
- ifcfg-eth1
- ifcfg-eth2
- ifcfg-eth3
- [root@localhost network-scripts]# cat ifcfg-eth0
- # Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+
- DEVICE=eth0
- BOOTPROTO=none
- HWADDR=xx:xx:xx:xx:xx:xx
- ONBOOT=yes
- NETMASK=xxx.xxx.xxx.xxx
- IPADDR=xx.xx.xx.xx
- GATEWAY=xx.xx.xx.xx
- TYPE=Ethernet
- 直接cp旧的文件,然后改一下就可以了。
- 第一个IP是 eth0
- 第二个IP是 eth0:0
- 第三个IP是 eth0:1
- 以此类推
- [root@localhost network-scripts]# service network restart || ifup eth0
- Shutting down interface eth0: [ OK ]
- Shutting down loopback interface: [ OK ]
- Bringing up loopback interface: [ OK ]
- Bringing up interface eth0: [ OK ]
- Bringing up interface eth1: [ OK ]
- Bringing up interface eth2: [ OK ]
- Bringing up interface eth3: [ OK ]
一个网卡绑定多个ip,其中一个配置文件出错,会影响整个连接,这个问题倒真是没考虑过。
感觉还不错,加油
回复:谢谢海波~
沙发 这个还能看懂!
回复:哈哈~方便点