jwbensley / Etherate

Linux CLI Ethernet and MPLS Testing Tool
MIT License
176 stars 19 forks source link

Something like ping for L2? #57

Open tjhacker opened 4 years ago

tjhacker commented 4 years ago

Is is possible to have a function similar to ping for layer 2 - just to check basic connectivity for broadcast and unicast?

ISSUE TYPE
VERSION DETAILS
[root@centos7 Etherate]# uname -a
Linux apollo.load 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
lspci | grep -i eth
[root@centos7 Etherate]# cat /etc/redhat-release || lsb_release -a || cat /etc/issue
CentOS Linux release 7.7.1908 (Core)
[root@centos7 Etherate]# lspci | grep -i eth
ip link
sudo ./etherate -V
sudo ./etherate -l
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:08.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:09.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:0a.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
[root@centos7 Etherate]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:98:a2:83 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:93:93:f5 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:05:39:42 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:aa:57:66 brd ff:ff:ff:ff:ff:ff
6: vxlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 62:bc:fa:29:9f:38 brd ff:ff:ff:ff:ff:ff
7: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether aa:65:0e:98:ca:83 brd ff:ff:ff:ff:ff:ff
8: ovs-br1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:27:93:93:f5 brd ff:ff:ff:ff:ff:ff
[root@centos7 Etherate]# sudo ./etherate -V
Etherate version 1.18 2018-06
[root@centos7 Etherate]# sudo ./etherate -l
Device lo, address 00:00:00:00:00:00, txqueuelen 1000, has interface index 1
Device eth0, address 08:00:27:98:a2:83, txqueuelen 1000, has interface index 2
Device eth1, address 08:00:27:93:93:f5, txqueuelen 1000, has interface index 3
Device eth2, address 08:00:27:05:39:42, txqueuelen 1000, has interface index 4
Device eth3, address 08:00:27:aa:57:66, txqueuelen 1000, has interface index 5
Device vxlan0, address 62:bc:fa:29:9f:38, txqueuelen 1000, has interface index 6
Device ovs-system, address aa:65:0e:98:ca:83, txqueuelen 1000, has interface index 7
Device ovs-br1, address 08:00:27:93:93:f5, txqueuelen 1000, has interface index 8
[
SUMMARY
STEPS TO REPRODUCE
jwbensley commented 4 years ago

Hi @tjhacker Hmm, it is possible but what would the requirement/purpoase be?

There is already the well known arping tool which does this. For example;

# I can see the MAC address of my default gateway is 7c:ad:74:b0:31:d6
$arp -na
? (192.168.58.1) at 7c:ad:74:b0:31:d6 on en0 ifscope [ethernet]

# I can use arping to ping it by sending an ICMP echo request to that unicast MAC address but with the dest IP set to 255.255.255.255:

$arping -i en0 7c:ad:74:b0:31:d6
ARPING 7c:ad:74:b0:31:d6
60 bytes from 192.168.58.1 (7c:ad:74:b0:31:d6): icmp_seq=0 time=5.770 msec
60 bytes from 192.168.58.1 (7c:ad:74:b0:31:d6): icmp_seq=1 time=5.060 msec
60 bytes from 192.168.58.1 (7c:ad:74:b0:31:d6): icmp_seq=2 time=9.237 msec
^C
--- 7c:ad:74:b0:31:d6 statistics ---
3 packets transmitted, 3 packets received,   0% unanswered (0 extra)
rtt min/avg/max/std-dev = 5.060/6.689/9.237/1.825 ms