Docker macvlan network, unable to access internet : <p>I have a dedicated server with multiple IP addresses, some IP's have mac address associated while others(in a subnetwork) doesn't have mac addresses.
I have created docker macvlan network using:</p>

<pre><code>docker network create -d macvlan -o macvlan_mode=bridge --subnet=188.40.76.0/26 --gateway=188.40.76.1 -o parent=eth0 macvlan_bridge
</code></pre>

<p>I have ip: 88.99.102.115 with mac: 00:50:56:00:60:42. Created a container using:</p>

<pre><code>docker run --name cont1 --net=macvlan_bridge --ip=88.99.102.115 --mac-address 00:50:56:00:60:42 -itd nginx
</code></pre>

<p>This works, I can access nginx hosted at that ip address from outside.</p>

<p><strong>Case with IP which doesn't have mac address and the gateway is out of subnet.</strong></p>

<p>subnet: 88.99.114.16/28, gateway: 88.99.102.103</p>

<p>Unable to create network using:</p>

<pre><code>docker network create -d macvlan -o macvlan_mode=bridge --subnet=88.99.114.16/28 --gateway=88.99.102.103 -o parent=eth0 mynetwork
</code></pre>

<p>Throws error:</p>

<pre><code>no matching subnet for gateway 88.99.102.103
</code></pre>

<p>Tried with increasing subnet scope to include gateway:</p>

<pre><code>docker network create -d macvlan -o macvlan_mode=bridge --subnet=88.99.0.0/16 --gateway=88.99.102.103 -o parent=eth0 mynetwork
</code></pre>

<p>Network got created, then started nginx container using 'mynetwork' and well I dont have mac address for 88.99.114.18 so used some random mac address 40:1c:0f:bd:a1:d2.</p>

<pre><code>docker run --name cont1 --net=mynetwork --ip=88.99.114.18 --mac-address 40:1c:0f:bd:a1:d2 -itd nginx
</code></pre>

<p>Can't reach nginx(88.99.102.115).</p>

<ol>
<li>How do I create a macvlan docker network if my gateway is out of my subnet?</li>
<li>How do I run a container using macvlan network when I have only IP address but no mac address?</li>
</ol>

<p>I don't have much knowledge in networking, it will be really helpful if you explain in detail.</p>

<p>My /etc/network/interfaces file:</p>

<pre><code>### Hetzner Online GmbH - installimage
# Loopback device:
auto lo
iface lo inet loopback
iface lo inet6 loopback
# device: eth0
auto  eth0
iface eth0 inet static
  address   88.99.102.103
  netmask   255.255.255.192
  gateway   88.99.102.65
  # default route to access subnet
  up route add -net 88.99.102.64 netmask 255.255.255.192 gw 88.99.102.65 eth0

iface eth0 inet6 static
  address 2a01:4f8:221:1266::2
  netmask 64
  gateway fe80::1
</code></pre>
