0

In a Ubuntu 20.04 machine connected to my home LAN, I created macvlans under my ethernet device:

$ sudo ip link add macvlan1 link enp37s0 type macvlan mode bridge
$ sudo dhclient macvlan1
$ sudo ip link add macvlan2 link enp37s0 type macvlan mode bridge
$ sudo dhclient macvlan2

By chance, they got the following addresses from DHCP:

  • macvlan1: 192.168.0.40
  • macvlan2: 192.168.0.41

I could ping my router from each of them:

$ ping 192.168.0.1 -I macvlan1
PING 192.168.0.1 (192.168.0.1) from 192.168.0.40 macvlan1: 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.713 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.25 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.20 ms
^C
--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2034ms
rtt min/avg/max/mdev = 0.713/1.052/1.245/0.240 ms

$ ping 192.168.0.1 -I macvlan2
PING 192.168.0.1 (192.168.0.1) from 192.168.0.41 macvlan2: 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=1.15 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=1.13 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=1.07 ms
64 bytes from 192.168.0.1: icmp_seq=4 ttl=64 time=0.548 ms
64 bytes from 192.168.0.1: icmp_seq=5 ttl=64 time=0.619 ms
^C
--- 192.168.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4030ms
rtt min/avg/max/mdev = 0.548/0.903/1.148/0.263 ms

Since they are were created in bridge mode, virtual devices should be connected to each other. But I can't ping one from the other:

$ ping 192.168.0.40 -I macvlan2
PING 192.168.0.40 (192.168.0.40) from 192.168.0.41 macvlan2: 56(84) bytes of data.
^C
--- 192.168.0.40 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4128ms

$ ping 192.168.0.41 -I macvlan1
PING 192.168.0.41 (192.168.0.41) from 192.168.0.40 macvlan1: 56(84) bytes of data.
^C
--- 192.168.0.41 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2039ms

Why I can't ping one from another? How to fix this?

1

The Linux kernel detects incoming packets with a local source address, considers them a routing mistake (packets that a particular computer sends out should never come back), and drops them to prevent network flooding.

Try to put each macvlan into a different network namespace (after all, macvlans were designed to be used from network namespaces). Then it should work.

| improve this answer | |
  • I support @dirkt suggestion to put each macvlan into a different network e.g. have first occupy 192.168.1.0/24 and second one 192.168.2.0/24 for example. – Roman Spiak Aug 1 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.