1. 程式人生 > >ip、ifconfig命令與IP(轉)

ip、ifconfig命令與IP(轉)

localhost 子接口 問題 5.0 keep mas html 路由配置 ipaddr

Q:問題的要求就是在linux下不重新情況下,如何臨時增加一個IP及臨時刪除一個IP ?

A:該問題除了可以通過ifconfig命令完成外,也可以通過ip命令完成,不過兩者是有區別的。ifconfig 要加子接口,ip 不用

我常用的命令:

ip addr add 1.1.1.1/24 dev eth0

keepalived 我猜 也是引用了這個命令:

(inet 192.168.1.6/24 scope global secondary eth0
inet 192.168.1.7/24 scope global secondary eth0)


virtual_ipaddress {
192.168.1.6/24
192.168.1.7/24

也可以是這樣:

ifconfig

ifconfig eth0:1 192.168.10.198 netmask 255.255.255.0 up

2、ip命令刪除一個IP
[root@localhost ~]# ip addr del 192.168.10.199/24 dev eth0 


三、路由配置

增加路由

route add -net 192.168.6.0/24 gw 192.168.101.254
route add default gw 192.168.101.254

http://www.361way.com/ifconfig-ip-ip/1835.html

ip、ifconfig命令與IP(轉)