以下命令在centos7环境中试验:
[root@cwaf ~]# ip addr 1: lo: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: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:16:e9:85 brd ff:ff:ff:ff:ff:ff inet 172.18.32.62/24 brd 172.18.32.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe16:e985/64 scope link valid_lft forever preferred_lft forever
2、查看本机的某个网卡的mac地址,例如eth0,# cat /sys/class/net/eth0/address
[root@cwaf ~]# cat /sys/class/net/eth0/address 00:0c:29:16:e9:85
3、查看本机的某个网卡的mac地址,例如eth0
可通过# cat /etc/sysconfig/network-scripts/ifcfg-eth0查看HWADDR=,如果存在这个字段的话
4、查看已知IP地址的MAC地址:使用ping命令加arp命令
ping命令是为了保证arp缓存中一定存在该ip的arp信息
[root@cwaf ~]# ping 172.18.32.59 PING 172.18.32.59 (172.18.32.59) 56(84) bytes of data. 64 bytes from 172.18.32.59: icmp_seq=1 ttl=64 time=0.203 ms 64 bytes from 172.18.32.59: icmp_seq=2 ttl=64 time=0.179 ms ^C --- 172.18.32.59 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.179/0.191/0.203/0.012 ms [root@cwaf ~]# [root@cwaf ~]# arp -n 172.18.32.59 Address HWtype HWaddress Flags Mask Iface 172.18.32.59 ether 8c:ec:4b:c3:a3:32 C eth0
5、通过# cat /proc/net/arp查看arp表
[root@cwaf ~]# cat /proc/net/arp IP address HW type Flags HW address Mask Device 172.18.32.59 0x1 0x2 8c:ec:4b:c3:a3:32 * eth0 172.18.32.76 0x1 0x2 00:0c:29:5a:30:b6 * eth0
以上就是
为各位朋友分享的 相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多 等着你!