Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Add to the bottom of the /etc/network/interfaces file of the host,

Code Block
languagebash
# Creates a macvlan interface called macvlan0 without an IP address
iface mvlan0 inet manual
   pre-up ip link add mvlan0 link eth0 address 8a:38:2a:cc:d7:aa type macvlan mode bridge
   post-down ip link del macvlan0
auto mvlan0

...

This macvlan0 is a placeholder on the host that will be used by a container interface. I have only purchased one additional static IP address so not all scenarios are tested. Please fill out the chart if you can,

If somebody gets to step 2 in below chart, please fill out for me. Otherwise, I'll try myself using my home network which is not exactly the same thing.

#Hostcontainer1container2Results
1mvlan0connect to mvlan0 with static-IP-1 with container2 offconnect to mvlan0 with static-IP-1 with container1 offsuccess
2mvlan0connect to mvlan0 with static-IP-1 with container2 onconnect to mvlan0 with static-IP-2 with container1 onNot sure... I need to buy another static IP to test

Scenario 1 basically shows that a macvlan in the host may be used by multiple containers as long as only one host is offon at a time.

Scenario 2 may or may not in which case we would want to create a scenario 3 by adding an additional macvlan mvlan1.

Look at your existing network cards,

Code Block
languagebash
ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:27:13:69:9c:9d  
          inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::227:13ff:fe69:9c9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1185139 errors:0 dropped:0 overruns:0 frame:0
          TX packets:779265 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:267212921 (267.2 MB)  TX bytes:164973471 (164.9 MB)
          Interrupt:20 Memory:fc400000-fc420000 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:125735 errors:0 dropped:0 overruns:0 frame:0
          TX packets:125735 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:10929290 (10.9 MB)  TX bytes:10929290 (10.9 MB)
lxcbr0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::4483:50ff:feb5:bbe4/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1174 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1493 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:106747 (106.7 KB)  TX bytes:2243760 (2.2 MB)

Reboot your system to have the change take effect. Review your network card list,

Code Block
languagebash
ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:27:13:69:9c:9d  
          inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::227:13ff:fe69:9c9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:222 errors:0 dropped:0 overruns:0 frame:0
          TX packets:177 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:23794 (23.7 KB)  TX bytes:19751 (19.7 KB)
          Interrupt:20 Memory:fc400000-fc420000 
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:534 errors:0 dropped:0 overruns:0 frame:0
          TX packets:534 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:42672 (42.6 KB)  TX bytes:42672 (42.6 KB)
lxcbr0    Link encap:Ethernet  HWaddr e2:2a:05:fb:9a:ab  
          inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::e02a:5ff:fefb:9aab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:648 (648.0 B)
mvlan0    Link encap:Ethernet  HWaddr 8a:38:2a:cc:d7:aa  
          inet6 addr: fe80::8838:2aff:fecc:d7aa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3607 (3.6 KB)  TX bytes:648 (648.0 B)
wlan0     Link encap:Ethernet  HWaddr 00:26:c6:81:f7:4a  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Notice mvlan0 is present with the hardware address you specified.

Connect Container to macvlan on Host

...

Code Block
languagebash
# Specify static IPs per container name or mac address.
# Addresses should be outside of range in /etc/default/lxc-net (10.0.3.100 to 10.0.3.254)


dhcp-host=00:16:3e:a2:7d:54,10.0.3.10
dhcp-host=app,10.0.3.20
dhcp-host=database,10.0.3.30

The Because the container called "web" now has two interfaces. 1 static, 1 we still want to assign through dnsmasq. In order for dnsmasq to know which interface to use you must now specify by using the mac address.

Multiple Interfaces

...