1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| [root@cephL ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:3a:98:1d brd ff:ff:ff:ff:ff:ff 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:52:03:aa brd ff:ff:ff:ff:ff:ff inet 192.168.56.102/24 brd 192.168.56.255 scope global dynamic enp0s8 valid_lft 945sec preferred_lft 945sec inet6 fe80::4b2b:b766:22c:f503/64 scope link valid_lft forever preferred_lft forever 4: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:3e:3e:e2 brd ff:ff:ff:ff:ff:ff 5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000 link/ether 52:54:00:66:bf:e6 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 6: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000 link/ether 52:54:00:66:bf:e6 brd ff:ff:ff:ff:ff:ff
scope解释,ip地址和路由都有一个域的概念,主要是告诉内核他们起作用的上下文。 在linux中,路由的域表明了目的网络和本机的距离。 而ip地址的域说明了这个ip地址的作用域。 在linux中一共有3种作用域,分别是HOST,LINK(对于ip地址来说说明这个地址是只在lan中使用,而对于route来说目的的地址在lan中),Universe/global(广域网的地址,对于route来说要到达这个地址肯定会多于1跳)。 要注意,域的默认值是Universe,也就是说你不显示指明,则默认都是Universe。
查看IP地址 [root@cephL ~]# ip addr show enp0s8 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:52:03:aa brd ff:ff:ff:ff:ff:ff inet 192.168.56.102/24 brd 192.168.56.255 scope global dynamic enp0s8 valid_lft 847sec preferred_lft 847sec inet6 fe80::4b2b:b766:22c:f503/64 scope link valid_lft forever preferred_lft forever
查看IPv6地址 [root@cephL ~]# ip -6 addr show dev enp0s8 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000 inet6 fe80::4b2b:b766:22c:f503/64 scope link valid_lft forever preferred_lft forever
添加IP地址 [root@cephL ~]# ip addr add 192.168.56.103/24 dev enp0s8 删除IP地址 [root@cephL ~]# ip addr del 192.168.56.103/24 dev enp0s8
|