form1.cn
Make a little progress every day

CentOS查看内网IP和外网IP

05th of January 2018 Linux Command 14025

有时候登录CentOS服务器后有查看内网可外网IP的需求,执行以下命令:


查看内网IP地址,和window中cmd的ipconfig类似:

ifconfig -a

输出结果:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.29.100.1  netmask 255.255.252.0  broadcast 10.29.103.255
        ether 00:16:3e:05:5f:5f  txqueuelen 1000  (Ethernet)
        RX packets 3996  bytes 311358 (304.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7050  bytes 529344 (516.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.29.100.1  netmask 255.255.252.0  broadcast 121.42.231.255
        ether 00:16:3e:05:7e:8f  txqueuelen 1000  (Ethernet)
        RX packets 101869  bytes 9540162 (9.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 67299  bytes 23104726 (22.0 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
        loop  txqueuelen 1  (Local Loopback)
        RX packets 66131  bytes 14306251 (13.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 66131  bytes 14306251 (13.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


查看外网IP地址:

curl ifconfig.me