Linux查看IP地址的两种方法
环境: CentOS8.3 Ubuntu20.04
a. ifconfig
root@ubuntu:/etc/init.d# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.155.255.102 netmask 255.255.255.0 broadcast 10.155.255.255
inet6 fe80::20c:29ff:fea1:4926 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a1:49:26 txqueuelen 1000 (Ethernet)
RX packets 192875 bytes 21953498 (21.9 MB)
RX errors 0 dropped 95240 overruns 0 frame 0
TX packets 5161 bytes 479675 (479.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.5.102 netmask 255.255.255.0 broadcast 172.16.5.255
inet6 fe80::20c:29ff:fea1:4930 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:a1:49:30 txqueuelen 1000 (Ethernet)
RX packets 196 bytes 27952 (27.9 KB)
RX errors 0 dropped 16 overruns 0 frame 0
TX packets 133 bytes 13123 (13.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 373 bytes 32461 (32.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 373 bytes 32461 (32.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
b. ip address
root@ubuntu:/etc/init.d# ip address
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: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:a1:49:26 brd ff:ff:ff:ff:ff:ff
inet 10.155.255.102/24 brd 10.155.255.255 scope global noprefixroute ens160
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fea1:4926/64 scope link
valid_lft forever preferred_lft forever
3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:a1:49:30 brd ff:ff:ff:ff:ff:ff
inet 172.16.5.102/24 brd 172.16.5.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fea1:4930/64 scope link
valid_lft forever preferred_lft forever