Linux ip命令详解

ip命令式用来配置网卡ip信息的命令,且是未来的趋势,重启网卡后IP失效

ip常见命令参数

Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
       ip [ -force ] -batch filename
where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |
                   tunnel | maddr | mroute | mrule | monitor | xfrm }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
                    -f[amily] { inet | inet6 | ipx | dnet | link } |
                    -o[neline] | -t[imestamp] | -b[atch] [filename] |
                    -rc[vbuf] [size]}

ip addr 常见命令参数

Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]
                                                      [ CONFFLAG-LIST]
       ip addr del IFADDR dev STRING
       ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
                            [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
          [ broadcast ADDR ] [ anycast ADDR ]
          [ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG  := [ permanent | dynamic | secondary | primary |
           tentative | deprecated | CONFFLAG-LIST ]
CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
CONFFLAG  := [ home | nodad ]
LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]
LFT := forever | SECONDS

常用的命令展示

为网卡配置和删除IPv4地址  【临时生效,永久生效需要更改配置文件】

eth2网卡配置文件: /etc/sysconfig/network-scripts/ifcfg-eth2

[root@localhost ~]# ip addr add 192.168.25.166/24  dev eth0  
[root@localhost ~]# ifconfig eth0 192.168.25.166 netmask 255.255.255.0 up 【效果同上】
[root@localhost ~]# ifconfig eth0 192.168.25.166/24 up       【效果同上】

image_thumb[9]

[root@localhost ~]# ip addr add 192.168.25.166/24  dev eth0:ws  
[root@localhost ~]# ifconfig eth0:ws 192.168.25.166/24 up   【效果同上】    
[root@localhost ~]# ifconfig eth0:ws 192.168.25.166 netmask 255.255.255.0 up 【效果同上】

image_thumb[10]

[root@localhost ~]# ip addr del 192.168.25.166/24  dev eth0:ws  
[root@localhost ~]# ifconfig eth0:ws  192.168.25.166 netmask 255.255.255.0 down  【效果同上】
[root@localhost ~]# ifconfig eth0:ws  192.168.25.166/24 dwon     【效果同上】

image_thumb[6]

posted @ 2018-07-07 09:54  小a玖拾柒  阅读(11214)  评论(0编辑  收藏  举报