标签:device gre 网络 说明 sel 清除 answer 接口 sts
来自于iproute包,可用于代替ifconfig
ip [ OPTIONS ] OBJECT { COMMAND | help }
ip 命令说明:
OBJECT := { link | addr | route }
ip link - network device configuration
set dev IFACE,可设置属性:up and down:激活或禁用指定接口,相当于 ifup/ifdown
show [dev IFACE] [up]::指定接口 ,up 仅显示处于激活状态的接口
man帮助:ip(8), ip-address(8), ip-link(8), ip-route(8)
范例: 查看帮助
[root@centos8 ~]#ip help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm
|
netns | l2tp | fou | macsec | tcp_metrics | token | netconf |
ila |
vrf | sr | nexthop }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec | -j[son] | -p[retty] |
-f[amily] { inet | inet6 | mpls | bridge | link } |
-4 | -6 | -I | -D | -M | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename]
|
-rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] |
-c[olor]}
[root@centos8 ~]#ip link help
Usage: ip link add [link DEV] [ name ] NAME
[root@centos8 ~]#ip addr help
Usage: ip address {add|change|replace} IFADDR dev IFNAME [ LIFETIME ]
[ CONFFLAG-LIST ]
ip address del IFADDR dev IFNAME [mngtmpaddr]
ip address {save|flush} [ dev IFNAME ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label LABEL ] [up]
ip address [ show [ dev IFNAME ] [ scope SCOPE-ID ] [ master DEVICE ]
[ type TYPE ] [ to PREFIX ] [ FLAG-LIST ]
[ label LABEL ] [up] [ vrf NAME ] ]
ip address {showdump|restore}
IFADDR := PREFIX | ADDR peer PREFIX
[root@centos8 ~]#ip route help
Usage: ip route { list | flush } SELECTOR
ip route save SELECTOR
ip route restore
ip route showdump
ip route get [ ROUTE_GET_FLAGS ] ADDRESS
[ from ADDRESS iif STRING ]
[ oif STRING ] [ tos TOS ]
[ mark NUMBER ] [ vrf NAME ]
[ uid NUMBER ] [ ipproto PROTOCOL ]
[ sport NUMBER ] [ dport NUMBER ]
ip route { add | del | change | append | replace } ROUTE
...
ip 地址管理
ip addr { add | del } IFADDR dev STRING [label LABEL] [scope {global|link|host}]
[broadcast ADDRESS]
[label LABEL]:添加地址时指明网卡别名
[scope {global|link|host}]:指明作用域,global: 全局可用.link: 仅链接可用,host: 本机可
用
[broadcast ADDRESS]:指明广播地址
ip address show
ip addr flush
范例:
#禁用网卡
ip link set eth1 down
#网卡改名
ip link set eth1 name wangnet
#启用网卡
ip link set wangnet up
#网卡别名
ip addr add 172.16.100.100/16 dev eth0 label eth0:0
ip addr del 172.16.100.100/16 dev eth0 label eth0:0
#清除网络地址
ip addr flush dev eth0
范例: 增加网卡别名实现一个网卡多个IP
[root@centos8 ~]#ip address add 10.0.0.18/24 dev eth0 label eth0:1
[root@centos8 ~]#ip address del 10.0.0.18/24 dev eth0 label eth0:1
[root@centos8 ~]#ip a
#先加新IP,再删除旧的IP
[root@centos8 ~]#ip address add 10.0.0.88/24 dev eth0
[root@centos8 ~]#ip address del 10.0.0.8/24 dev eth0
[root@centos8 ~]#ip a
[root@centos8 ~]#ip addr add 10.0.0.18/24 dev eth0
[root@centos8 ~]#ip a
[root@centos8 ~]#ip addr add 10.0.0.18/24 dev eth0
RTNETLINK answers: File exists
#
[root@centos8 ~]#ip addr change 10.0.0.18/24 dev eth0 preferred_lft 30 valid_lft
6
preferred_lft is greater than valid_lft
[root@centos8 ~]#ip addr change 10.0.0.18/24 dev eth0 preferred_lft 3 valid_lft
10
[root@centos8 ~]#ip a
#过10s后地址消失
[root@centos8 ~]#ip a
[root@centos8 ~]#ip addr change 10.0.0.18/24 dev eth0 preferred_lft 10 valid_lft
20
[root@centos8 ~]#ip addr change 10.0.0.18/24 dev eth0 preferred_lft 20 valid_lft
40
[root@centos8 ~]#ip a
#replace 代替现有地址信息
[root@centos8 ~]#ip addr replace 10.0.0.18/24 dev eth0 preferred_lft 30
valid_lft 60
[root@centos8 ~]#ip a
#replace 也可实现新加IP
[root@centos8 ~]#ip addr replace 10.0.0.28/24 dev eth0 preferred_lft 30
valid_lft 60
[root@centos8 ~]#ip a
标签:device gre 网络 说明 sel 清除 answer 接口 sts
原文地址:https://www.cnblogs.com/xuanlv-0413/p/14672277.html