Sample Header Ad - 728x90

How to "predict" a DHCP IP address?

0 votes
2 answers
210 views
Before launching a VM from my script, I need to figure out which IP address it will get. So I did: dhclient And this works, because dhclient uses the MAC address from the macvtap interface specified, and returns me the IP address from the DHCP server. This is not a foolproof solution, because there may be some people who have a router at home that does not always return the same IP for the same MAC. But every router I ever owned did, so if it works for 99 percent of the cases it's good enough for me. But the problem is that dhclient also makes changes to the local configuration because it thinks I want to actually use that address on the host. There is a -n flag that should prevent this, but it is not supported by Debian or most other distributions. So what is the best way to just ask a DHCP server which IP it is planning to serve to a certain MAC address, without actually modifying any settings on the host?
Asked by Maestro (211 rep)
May 4, 2023, 08:42 PM
Last activity: May 5, 2023, 03:04 PM