【LIUNX】查询IP与MAC地址

查询IP与MAC地址

  • A.使用ifconfig查询
  • B.使用ip a查询

A.使用ifconfig查询

[root@server1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.5  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::7b4c:6610:f082:b301  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:dc:25:fc  txqueuelen 1000  (Ethernet)
        RX packets 22798  bytes 19698351 (18.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13016  bytes 2178517 (2.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
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 50  bytes 8074 (7.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50  bytes 8074 (7.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:41:ef:64  txqueuelen 1000  (Ethernet)
        RX packets 9638  bytes 1597814 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12129  bytes 14387305 (13.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::fc54:ff:feb3:28dd  prefixlen 64  scopeid 0x20<link>
        ether fe:54:00:b3:28:dd  txqueuelen 1000  (Ethernet)
        RX packets 9638  bytes 1732746 (1.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 18216  bytes 14704249 (14.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

其中我们使用两块网卡

  1. ens33:外网网卡
  2. virbr0:内网网卡

仔细查看内容

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.5  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::7b4c:6610:f082:b301  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:dc:25:fc  txqueuelen 1000  (Ethernet)
        RX packets 22798  bytes 19698351 (18.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13016  bytes 2178517 (2.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

网卡ens33中:
inet 192.168.3.5为网卡IPV4的IP
ether 00:0c:29:dc:25:fc就是这款网卡的mac地址

同理

网卡virbr0中:
inet 192.168.122.1为网卡IPV4的IP
ether 52:54:00:41:ef:64就是这款网卡的mac地址

B.使用ip a查询

[root@server1 ~]# 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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:dc:25:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.5/24 brd 192.168.3.255 scope global dynamic noprefixroute ens33
       valid_lft 1675sec preferred_lft 1675sec
    inet6 fe80::7b4c:6610:f082:b301/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:41:ef:64 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
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:41:ef:64 brd ff:ff:ff:ff:ff:ff
5: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:b3:28:dd brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:feb3:28dd/64 scope link 
       valid_lft forever preferred_lft forever

网卡ens33中:
inet 192.168.3.5为网卡IPV4的IP
ether 00:0c:29:dc:25:fc就是这款网卡的mac地址

同理

网卡virbr0中:
inet 192.168.122.1为网卡IPV4的IP
ether 52:54:00:41:ef:64就是这款网卡的mac地址

你可能感兴趣的:(liunx,liunx-uos,liunx-kylin,tcp/ip,网络,服务器,linux)