centos 新增IP

mhabbyo發表於2016-09-26

具體命令如下:

ifconfig team0:1 10.50.61.17 netmask 255.255.255.0 up

team0 為新增的網路卡 

關閉的時候  up--> down

ifconfig team0:1 10.50.61.17 netmask 255.255.255.0 down


[root@YW-TR-DB]:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:d0:fa:f7 brd ff:ff:ff:ff:ff:ff
    inet 10.50.28.78/24 brd 10.50.28.255 scope global eth0
[root@YW-TR-DB]:~# ifc
ifcfg     ifconfig  
[root@YW-TR-DB]:~# ifconfig eth0:1 10.50.28.115  netmask 255.255.255.0 up
[root@YW-TR-DB]:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:d0:fa:f7 brd ff:ff:ff:ff:ff:ff
    inet 10.50.28.78/24 brd 10.50.28.255 scope global eth0
    inet 10.50.28.115/24 brd 10.50.28.255 scope global secondary eth0:1
[root@YW-TR-DB]:~# ifconfig eth0:1 10.50.28.115  netmask 255.255.255.0 down
[root@YW-TR-DB]:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0c:29:d0:fa:f7 brd ff:ff:ff:ff:ff:ff
    inet 10.50.28.78/24 brd 10.50.28.255 scope global eth0


這個IP地址並不是虛擬IP,只是在 team0 網路卡上新增了一個IP 地址,要實現新增能夠進行漂移的虛擬IP是要通過keepalived 來實現的

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29291882/viewspace-2125572/,如需轉載,請註明出處,否則將追究法律責任。

相關文章