-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DHCP ignores containers mac-address when sending DHCPREQUEST to server #450
Comments
It looks like the tuning plugin doesn't set the mac address supplied by the runtime until after the ipam plugin has finished. So in the case of the dhcp plugin, the mac address used for e.g. dhcp discover, request etc will be the random mac was assigned by Linux. |
Just as the comments by @mccv1r0 , the set-mac-address action happens in chained plugin For now, I haven't thought of a good solution for this. |
Something worth noting is that when I change the config to acually specify the mac-address like so:
It works in the same way as setting it throught the " |
One idea: we could create an "ip assign" plugin which could appear later in the chain, change the bridge plugin so it just creates the veth at layer 2 if no ipam is supplied.
|
That would solve the Issue but I think it would be a better idea to integrate it as an optional option in "tuning".
interface-share-mac is a really bad name but I think it would be nicer to integrate it. It would be nice if you could just ask the mac plugin to use the containers mac instead of the interface's. or maybe an option under "type": "bridge" where you specify that the interface and container should have the same mac. I would love to hear your thoughts on this @mccv1r0 @bboreham |
I suspect we are not understanding each other. I think the problem you have identified is that the |
Hmm yea I see. Then ur solution is better, but still kind of feels like an extra step. Should not the default behavior of CNI be to look over the conf before setting an interface mac at random? |
so where do we take this now @bboreham ? Do you know anybody that could help? |
Under CNI chaining, each plugin runs independently and with zero knowledge of what any other plugin does. The whole idea of CNI is that plugins can come from anywhere. Another option would be to replace |
what do you mean by "wrapping bridge"? |
And also, would it not be possible to add an option to the bridge plugin that sets the mac address of the interface it creates? That would solve the issue instantly. @bboreham |
Wrapping And we won’t add the option into |
Is there any roadmap for this? I am wanting to roll a new deployment that relies on a podman backend, but I need some services to be set to specific IPs; I currently use DHCP for IPAM. Would it be possible to control the UID generated by the DHCP plugin? I think that would allow for more granular control, or at least provide reliable results. |
Not yet.
As a workaround to get you going, podman allows you to set the IPv4 address explicitly, see You need to use |
Would this still fully expose the container to the local network? (context: I'm running Home-Assistant in a container exposed on my network through macvlan, but every time I recreate the container, the IP address changes due to a new mac address being generated) |
Yes. The only difference would be your container would get the IPv4 address specified via |
You just overly simplified my life. Got it to work. Thanks! :) |
Any update on this issue? The ability to set the MAC address with the macvlan plugin would be very useful. Some control over the MAC address being generated (not completely random) would also solve this problem for the most part because for static DHCP leases you just need it to be consistent. |
As @zeroepoch I'm trying to use the prepopulated MAC address with MACVLAN networking to assign specific IP from DHCP.
I like this idea as it allows support in all drivers at once and not just in one driver as the idea about the new feature in the bridge driver. Also, it detaches DHCP leasing into a separate entity which is an improvement per KISS principle. Is there any progress on this issue? |
My thought would be to implement the mac convention / capability arg directly in the interface plugins. |
Sadly this doesn't really help, as there are other steps performed by |
I'm also affected by this issue. I'm guessing it mainly stems from the use case of wanting a predictable IP for one's long-lived container, such that it can be reached via a hostname rather than an IP-address. While this is being worked on, does anyone have a workaround? |
I fear that this could needlessly spam the issue, so such discussions should likely be kept down to a minimum. But I have a somewhat working and a little creative work-around deployed. My containers are attached via macvlan to a separate vlan network (to contain the mac-address spamming in my routers UI) and I am also running the However the containers are unable to communicate with the host via macvlan, so the dnsmasq instance of dnsname would be inaccessible by the containers. To work-around that, I do not actually have dnsmasq installed, but instead I use a small script as a replacement, that spawn dnsmasq with the given arguments/config files in another container with a static-ip-address: #!/bin/bash
NAME=$(echo $3 | cut -c 13-)
FOLDER=$(dirname $NAME)
sed -i.bak '/pid-file/d' $NAME
rm $FOLDER/pidfile
podman run --name dnsmasq --hostname dns --network=extern-static-dnsmasq -v $FOLDER:$FOLDER:Z --rm -d --cap-add=NET_ADMIN andyshinn/dnsmasq --log-facility=- $@
sleep 5;
pgrep dnsmasq | tail -1 > $FOLDER/pidfile Then I set the dns server of my other containers via This is all super hacky, but works quite stable so far. But I would absolutely discourage anyone to deploy this anywhere, but their own home network or testing environment. Debugging this requires knowledge into how cni works and building this was a whole day of reading source code and trying other rather crazy ideas, until I finally settled upon this "solution". So be careful. |
This change sets the mac address if specified during the creation of the macvlan interface. This is superior to setting it via the tuning plugin because this ensures the mac address is set before an IP is set, allowing a container to get a reserved IP address from DHCP. Related containernetworking#450
This change sets the mac address if specified during the creation of the macvlan interface. This is superior to setting it via the tuning plugin because this ensures the mac address is set before an IP is set, allowing a container to get a reserved IP address from DHCP. Related containernetworking#450 Signed-off-by: Clint Armstrong <[email protected]>
This change sets the mac address if specified during the creation of the macvlan interface. This is superior to setting it via the tuning plugin because this ensures the mac address is set before an IP is set, allowing a container to get a reserved IP address from DHCP. Related containernetworking#450 Signed-off-by: Clint Armstrong <[email protected]>
While we wait for the release, here is a small workaround that might fit in certain circumstances. IPAM DHCP already sends Client ID in the format full-container-id/CNI-network-name/container-iface-name e. g. af09e70c2313b355811ecf4376e47093ad83f037f90d91fa70f4c8dd63157d78/eth5_macvlan/eth0. If your container is long-lived and you control DHCP server and it has ability to issue addresses based on Client ID, you could assign the address based on this Client ID e. g. for dnsmasq it would be --dhcp-host=id:af09e70c2313b355811ecf4376e47093ad83f037f90d91fa70f4c8dd63157d78/eth5_macvlan/eth0,192.168.0.160. BTW with dnsmasq it's quite easily scriptable if you also use dhcp-hostsdir. I hope it helps. |
This change sets the mac address if specified during the creation of the macvlan interface. This is superior to setting it via the tuning plugin because this ensures the mac address is set before an IP is set, allowing a container to get a reserved IP address from DHCP. Related containernetworking#450 Signed-off-by: Clint Armstrong <[email protected]>
This change sets the mac address if specified during the creation of the macvlan interface. This is superior to setting it via the tuning plugin because this ensures the mac address is set before an IP is set, allowing a container to get a reserved IP address from DHCP. Related containernetworking#450 Signed-off-by: Clint Armstrong <[email protected]>
Hi!
I'm opening this because I'm trying to make a Podman container to join a PFsense LAN network on a bridge using a static DHCP lease. I thought that when podman released 1.7 (supporting setting static mac-addresses) this would be an easy task. I was wrong.
So currently im using the following network config list:
And this works from a Podman perspective. It asks for a IP through the dhcp.sock and the mac-address sat is indeed static. From Podmans side of things.
But the DHCP plugin (
/usr/libexec/cni/dhcp daemon &
) does not respect the containers mac-address and presents the DHCP server with a seemingly random mac-address.The mac-address on container
testMac
is currently 3e:84:ea:ab:7d:52 and nowhere to be seenAll help would be appriciated, thanku
The text was updated successfully, but these errors were encountered: