SiliCloud Help Document Center
search
Popular search terms
法律与条款
用户服务
产品
技巧与案例
服务器管理
Wordpress
部署设计
游戏
通用技巧
Node JS
主流 Linux 服务器,均支持 ip 命令。
如果您的系统没有默认安装此命令,请通过以下命令安装:
Debian/Ubuntu:
apt install -y iproute2
Redhat/CentOS:
yum install -y iproute2
您可以通过help和官方文档 https://linux.die.net/man/8/ip,系统的学习ip
[root@localhost ~]# 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 }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec |
-f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
-4 | -6 | -I | -D | -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 | -a[ll] | -c[olor]}
下文介绍几种,日常常用的案例。
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq state UP group default qlen 1000
link/ether fa:16:3e:53:fd:b7 brd ff:ff:ff:ff:ff:ff
altname enp0s3
inet 172.16.0.179/24 metric 100 scope global dynamic ens3
valid_lft 64677sec preferred_lft 64677sec
inet6 2400:38e0:1:4002::b5/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::3ec/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::302/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::2cb/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::2b4/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::29e/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::242/64 scope global
valid_lft forever preferred_lft forever
inet6 2400:38e0:1:4002::1df/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe53:fdb7/64 scope link
valid_lft forever preferred_lft forever
2.新增IPv4(请自行替换IP地址和网卡名称)
ip addr add 172.16.0.179/24 dev ens3
3.删除IPv4(请自行替换IP地址和网卡名称)
ip addr del 172.16.0.179/24 dev ens3
4.新增IPv4的默认路由出口(请自行替换 网关IP地址)
ip router add default via 172.16.0.1
1.新增IPv6(请自行替换IP地址和网卡名称)
ip -6 addr add 2400:38e0:1:4002::2cb/64 dev ens3
2.删除IPv6(请自行替换IP地址和网卡名称)
ip -6 addr del 2400:38e0:1:4002::2cb/64 dev ens3
3.新增IPv6的默认路由出口(请自行替换 网关IP地址)
ip -6 router add 2000::/3 via 2400:38e0:1:4002::1
Related Doc
Do you have any suggestions for this document?