一、多网卡绑定1个ip
1. 新建ifcfg-bond0
[root@dex network-scripts]# cd /etc/sysconfig/network-scripts/尝试着拔掉一个网线,看看结果怎样。
VM中只能做mode=1
二、单网卡绑定多个ip
这一步很简单,只要添加一个配置文件即可
[root@james-test ~]# cd /etc/sysconfig/network-scripts
[root@james-test network-scripts]# cp ifcfg-eth0 ifcfg-eth0:3
[root@james-test network-scripts]# vi ifcfg-eth0:3
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0:3
BOOTPROTO=static
BROADCAST=192.168.100.255
HWADDR=00:0C:29:90:B5:80
IPADDR=192.168.100.7
IPV6INIT=yes
IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
NETWORK=192.168.100.0
ONBOOT=yes
[root@james-test network-scripts]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@james-test network-scripts]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4080254 errors:0 dropped:0 overruns:0 frame:0
TX packets:2391945 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:604068660 (576.0 MiB) TX bytes:3276087314 (3.0 GiB)
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.8 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.7 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1357158 errors:0 dropped:0 overruns:0 frame:0
TX packets:1357158 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:126429892 (120.5 MiB) TX bytes:126429892 (120.5 MiB)
或者直接使用ifconfig命令也可以
[root@james-test network-scripts]# ifconfig eth0:2 192.168.100.9
[root@james-test network-scripts]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.1 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4080397 errors:0 dropped:0 overruns:0 frame:0
TX packets:2392060 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:604083446 (576.0 MiB) TX bytes:3276102542 (3.0 GiB)
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.8 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:2 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.9 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr 00:0C:29:90:B5:80
inet addr:192.168.100.7 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1357194 errors:0 dropped:0 overruns:0 frame:0
TX packets:1357194 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:126433632 (120.5 MiB) TX bytes:126433632 (120.5 MiB)