快速获取Linux系统IP地址

查看Linux系统IP地址详情

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.8.15  netmask 255.255.252.0  broadcast 10.0.11.255
        inet6 fe80::5054:ff:fe9e:637e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:9e:63:7e  txqueuelen 1000  (Ethernet)
        RX packets 2116499  bytes 282753266 (269.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2085076  bytes 384739573 (366.9 MiB)
        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 245  bytes 34295 (33.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 245  bytes 34295 (33.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

快速获取Linux系统IP地址

$ hostname -I
10.0.8.15 

# 如果当前系统IP地址众多,比如K8S集群,docker网卡等
$  hostname -I  awk '{print $1}'
10.0.20.13

快速获取Linux系统IP地址
http://www.qiqios.cn/2021/12/23/快速获取linux系统ip地址/
作者
一亩三分地
发布于
2021年12月23日
许可协议