Correct way of using macvlan in Debian 10
by kevindd992002 from LinuxQuestions.org on (#5EXM7)
So I have these in my /etc/network/interfaces:
# The macvlan network subinterface
auto mac0
iface mac0 inet manual
pre-up ip link add mac0 link enp1s0 type macvlan mode bridge
pre-up ip addr add 192.168.20.110/32 dev mac0
post-up ip route add 192.168.20.96/28 dev mac0
post-down ip link del mac0 link enp1s0 type macvlan mode bridge
I'm doing this because I use macvlan in some of my docker containers for them to have their own IP's (in the same subnet) while on a single physical host. However, without the mac0 interface in the host, it won't reach the docker containers. This is explained here.
Everything is working well except that sometimes packets coming from the same physical host use the macvlan interface IP (192.168.20.110) instead of its actual enp1s0 interface IP (192.168.20.22). That makes sense because it's sharing the same interface and has essentially two IP's with the same MAC address.
However, without actually assigning an IP address on the mac0 interface, sometimes my whole networks gets bogged down when traffic from one of the docker containers using the docker macvlan network gets initiated.
So my question is how do I stop the host from using the mac0 interface IP as source IP when it is initiating traffic out the physical network?


# The macvlan network subinterface
auto mac0
iface mac0 inet manual
pre-up ip link add mac0 link enp1s0 type macvlan mode bridge
pre-up ip addr add 192.168.20.110/32 dev mac0
post-up ip route add 192.168.20.96/28 dev mac0
post-down ip link del mac0 link enp1s0 type macvlan mode bridge
I'm doing this because I use macvlan in some of my docker containers for them to have their own IP's (in the same subnet) while on a single physical host. However, without the mac0 interface in the host, it won't reach the docker containers. This is explained here.
Everything is working well except that sometimes packets coming from the same physical host use the macvlan interface IP (192.168.20.110) instead of its actual enp1s0 interface IP (192.168.20.22). That makes sense because it's sharing the same interface and has essentially two IP's with the same MAC address.
However, without actually assigning an IP address on the mac0 interface, sometimes my whole networks gets bogged down when traffic from one of the docker containers using the docker macvlan network gets initiated.
So my question is how do I stop the host from using the mac0 interface IP as source IP when it is initiating traffic out the physical network?