From 4072ce8de4081e158cd81785ad8a300ad9b50f89 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sun, 1 Sep 2019 12:55:12 +0100 Subject: [PATCH] Manually apply MAC address when supplied (fixes #1) If specified (via `--mac-address`), Docker only applies a user-selected MAC address when moving the interface into the container's network namespace. This means that the initial run of `udhcpc` will use the random veth MAC address, breaking any statically configured leases (since this is the IP address that Docker will assign to the container). --- net-dhcp/network.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net-dhcp/network.py b/net-dhcp/network.py index 0a93fea..892abfd 100644 --- a/net-dhcp/network.py +++ b/net-dhcp/network.py @@ -161,7 +161,11 @@ def create_endpoint(): } try: - if 'MacAddress' not in req_iface or not req_iface['MacAddress']: + if 'MacAddress' in req_iface and req_iface['MacAddress']: + (if_container + .set('address', req_iface['MacAddress']) + .commit()) + else: res_iface['MacAddress'] = if_container['address'] def try_addr(type_):