显示IP地址的命令

显示IP地址的命令


 
Centos7默认显示IP地址的命令
 
 
 
#获取所有网卡的IP地址
[root@clf ~]# ip  a
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:eb:ea:8d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3310:9d15:9ee4:43e8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
      
                                 ip   a   =     ip  address   
[root@clf ~]# 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:eb:ea:8d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3310:9d15:9ee4:43e8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
 
 
 
#单独查看某个网卡的IP地址
[root@clf ~]# ip  a  s  eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:eb:ea:8d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3310:9d15:9ee4:43e8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@qls ~]# ip address  show  eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:eb:ea:8d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3310:9d15:9ee4:43e8/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
 
 
 
 
ifconfig是Centos6默认显示IP地址的命令
[root@clf ~]# yum install  -y  net-tools
 
 
 
#所有的网卡的IP地址信息
[root@clf ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.100  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::3310:9d15:9ee4:43e8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:eb:ea:8d  txqueuelen 1000  (Ethernet)
        RX packets 669  bytes 367883 (359.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 376  bytes 48482 (47.3 KiB)
        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 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
 
 
#获取某一个网卡的信息
[root@clf ~]# ifconfig   eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.100  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::3310:9d15:9ee4:43e8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:eb:ea:8d  txqueuelen 1000  (Ethernet)
        RX packets 699  bytes 370373 (361.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 394  bytes 51180 (49.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
 
 
hostname
#显示所有的IP地址,会显示IPv6的地址
[root@clf ~]# hostname -i
fe80::3310:9d15:9ee4:43e8%eth0 10.0.0.100
#只显示IPv4地址
[root@clf ~]# hostname -I
10.0.0.100
 
 
 
#如何获取到公网地址
[root@clf ~]# curl  ifconfig.me
139.226.13.64
[root@clf ~]# curl cip.cc
IP : 139.226.13.64
地址 : 中国  上海
运营商 : 联通
数据二 : 上海市 | 联通
数据三 : 中国上海上海 | 联通
URL : http://www.cip.cc/139.226.13.64
 
上一篇:转:Java中abstract和interface的区别


下一篇:PPTP-VPN日志功能,记录用户登录时间,流量统计,IP地址等信息