Running dhcpcd in manager mode with dual stack.
Usecase: Run dhcpcd in manager mode in dual stack. Runtime change to V4 only, V6 only or both.
This seems to be not working. Ran dhcpcd in manager mode with denyinterface - which is fine. It is starting manager in V4,V6 mode without any interface. Enable V4 - dhcpcd -4 eth0 - this is also fine. Now I want to add V6 also. So doing dhcpcd eth0. not enabling both V4 and V6.
Now I restart manger and then dhcpcd eth0 is starting both. Now I can't make it to do only V4. if I do dhcpcd -4 --rebind eth0 now its not removing V6 dhcp ip from the lease and interface.
And also "-k" option always release both V4 and V6 ip. How to release only one?
Is running "no dhcp", "dhcp" with various combination for V4, V6 at runtime supported?
So you've got it solved really. The secret is always specify the address family on the command line. So if you want one both then it's two dhcpcd calls to start both.
If you don't specify a family then dhcpcd expects to have both v4 and v6 in one process.
No it just doesn't work properly. I even tried with running 2 managers one for V4 and one For V6 via bindmounts and separate run directories. Ideally when -4 option is given it should run V4 and coupled with -k it should release V4. When -6 option is given it should run V6 and coupled with -k it should release V6. It doesn't work like that. When it runs in non manager mode working-wise it is fine but amount of processes it creates is too much considering number of nics and vlans.
OK, you're right, this doesn't work well because dhcpcd overlays the command on the whole state. Knowing that, we can do this:
$ doas dhcpcd --denyinterfaces=*
$ doas dhcpcd -n vioif0
sending commands to dhcpcd process
$ doas dhcpcd -U | grep protocol
protocol=link
protocol=dhcp
protocol=ra
protocol=dhcp6
$ doas dhcpcd -k6 vioif0
sending commands to dhcpcd process
netbsd$ doas dhcpcd -U | grep protocol
protocol=link
protocol=dhcp
$ doas dhcpcd -n vioif0
sending commands to dhcpcd process
$ doas dhcpcd -U | grep protocol
protocol=link
protocol=dhcp
protocol=ra
protocol=dhcp6
$ doas dhcpcd -k4 vioif0
sending commands to dhcpcd process
$ doas dhcpcd -U | grep protocol
protocol=link
protocol=ra
protocol=dhcp6
So releasing a specific family works fine.
We can also start a specific family at the cost of not handling any other family that maybe running for global dhcpcd events (such as carrier)
So if you only want IPv4, you can do dhcpcd -4n $interface.
If you only want IPv6, you can do dhcpcd -6n $interface.
If you want both states at the same time you can do if you only want IPv4, you can do dhcpcd -4n $interface`.
Does this make sense and can it work for you?
Yeah that looks fine. But each time rebinding with -n will send DHCP request again right? In this case will it delete and readd the ip? And also one more question I have. Whenever I run in non manager mode, for each V6 IP it starts [DHCP6 proxy] process whereas it is not started when its run in manager mode? Can you please help in understanding this difference of {DHCP6 proxy] process between manager and non-manager mode?