Docker Community Forums

Share and learn in the Docker community.

Unable to Access Docker Host from MacVLAN

Hello,

I am sorry if this has been posted before and answered. I was unable to locate my exact scenario with a working solution provided.

I currently have a Synology NAS with docker installed. I created a macVLAN with the following configurations.

Network 192.168.1.0/24
DHCP Range 192.168.1.10-192.168.1.239
Docker Host / Synology 192.168.1.215

macVLAN
Subnet 192.168.1.0/24
IP Range 192.168.1.240/28
Gateway 192.168.1.1

I have 3 containers on this macvlan and all are able to communicate with each other. They are also able to access my gateway and access the internet. However when I try and ping 192.168.1.215 I am getting a route issue. I noticed in my ARP table 215 did not have a mac address it was listed as unknown.

What is the cleanest solution to have my containers access my host?

I am trying to create a reverse proxy to some applications on the Synology NAS that are not docker containers.

Thank You.

You can do this by doing the following:

ip link add foobar link enp7s0 type macvlan mode bridge
ip addr add 192.168.9.252/32 dev foobar
ip link set foobar up
ip route add 192.168.9.228/32 dev foobar
Where:

enp7s0 - Name of your physical adapter

192.168.9.252/32 - Genuine new IP on your network

192.168.9.228/32 - IP of the container using macvlan

Please be aware that this will not survive reboots, so you will need to script it to run each reboot or use another method to make it persisten

I cannot remember exactly the commands I did in the past to get macvlan online. However I assume I already did something similar to

ip link add foobar link enp7s0 type macvlan mode bridge
ip addr add 192.168.9.252/32 dev foobar
ip link set foobar up

So that means i just have to add the route on the host to the container.
ip route add 192.168.9.228/32 dev foobar

When you say this is not permanent, do you mean the route is not or the whole macvlan setup is not?

Sorry here is the command I already performed.

sudo docker network create --driver=macvlan --gateway=192.168.1.1 --subnet=192.168.1.0/24 —-ip-range=192.168.1.240/28 --o parent=ovs_eth0 Local_Network

So are you saying i have to do this as an addition

ip link add foobar link ovs_eth0 type macvlan mode bridge
ip addr add 192.168.1.215/32 dev foobar
ip link set foobar up
ip route add 192.168.1.241/32 dev foobar

or even better

ip route add 192.168.1.240/28 dev foobar?

So the docker create network is permanent but the links and routes are not?