说明:
操作系统:CentOS 6.2
IP地址:192.168.21.164
子网掩码:255.255.255.0
网关:192.168.21.2
问题:
现在要增加一个IP地址:192.168.21.165(子网掩码、网关与原来的相同)
操作方法:
1、cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 #拷贝原网卡配置文件
2、vi /etc/sysconfig/network-scripts/ifcfg-eth0:0 #编辑网卡配置文件
DEVICE="eth0:0" #修改为eth0:0
HWADDR="00:0C:29:4E:0E:EF"
NM_CONTROLLED="yes"
ONBOOT="yes"
IPADDR=192.168.21.165 #修改为要增加的IP地址
NETMASK=255.255.255.0
GATEWAY=192.168.21.2
DNS1=8.8.8.8
DNS2=8.8.4.4
:wq! #保存
3、shutdown -r now #重启系统
备注:单网卡绑定多IP,其实是增添网卡的IP别名,如果要再增加IP地址可以继续配置一个ifcfg-eth0:1文件,依次类推“eth0:2”“eth0:3”
» 转载请注明来源:系统运维 » linux系统下单网卡绑定多个IP地址
为什么我添加了ip地址之后 重新启动网络,提示service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: RTNETLINK answers: File exists
[ OK ]
Rtnetlink answers:File exists是什么。。为什么会提示这个。。。
我的配置文件为:
eth0 Link encap:Ethernet HWaddr 00:02:55:A0:E4:66
inet addr:192.168.200.207 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::202:55ff:fea0:e466/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4329490 errors:0 dropped:0 overruns:0 frame:0
TX packets:1073059 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:666272060 (635.4 MiB) TX bytes:362130377 (345.3 MiB)
eth0:1 Link encap:Ethernet HWaddr 00:02:55:A0:E4:66
inet addr:192.168.10.254 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:2 Link encap:Ethernet HWaddr 00:02:55:A0:E4:66
inet addr:192.168.205.190 Bcast:192.168.205.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth0:3 Link encap:Ethernet HWaddr 00:02:55:A0:E4:66
inet addr:192.168.101.101 Bcast:192.168.101.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
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:188687 errors:0 dropped:0 overruns:0 frame:0
TX packets:188687 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:24062707 (22.9 MiB) TX bytes:24062707 (22.9 MiB)
帮我看一下是什么问题,我只配置一W个IP的时候就可以重启的时候不会报这个错误。。