I have two interfaces on my computer, eth0 and eth1.
Both subnets have a DHCP server on them.
How could I use dhclient to renew IP address for both interfaces?
If I do:
dhclient -r && dhclient eth0
It renews the IP on eth0. Then, if I want to just do:
dhclient eth1
It fails with error:
dhclient(22421) is already running - exiting.
I can do:
dhclient -r && dhclient eth1
But the dhclient -r part releases the lease and I loose the IP address on eth0 as well.
For now, the only way I've managed to do what I want is to run dhclient for eth0, brutally kill it, and run it on eth1: I end up with a renewed IP on both interfaces.
I also tested with dhclient -x instead of dhclient -r, no luck.
Surely, this is not the way to go!
EDIT:
Two answers suggested doing dhclient -r eth0 eth1 && dhclient eth0 eth1
This, indeed, limits the broadcast calls to these interfaces. But the first DHCP server to answer will be the only one used, hence resulting in a new IP on a single interface and not both. See here, we can see DHCPDISCOVER calls on both interfaces, but the DHCPREQUEST is only done on eth0, first interface through which a DHCP server was found:
Listening on LPF/eth0/0a:00:27:00:00:00
Sending on LPF/eth0/0a:00:27:00:00:00
Listening on LPF/eth1/84:8f:69:d3:d4:a1
Sending on LPF/eth1/84:8f:69:d3:d4:a1
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5 (xid=0x170fcb67)
DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 4 (xid=0x115a24c3)
DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x170fcb67)
DHCPOFFER from 192.168.1.1
DHCPACK from 192.168.1.1 (xid=0x170fcb67)
bound to 192.168.1.4 -- renewal in 1710 seconds.