Ubuntu主机配置ISC-DHCP-Server为VirtualBox虚拟机固定分配DHCP IP地址失败求助
Hey there, let's troubleshoot why your fixed IP assignment for the vmr120 VM isn't working as expected. I've run into similar issues before, so here are the key checks and fixes to try:
Verify VirtualBox Network Mode First
This is the most common pitfall! If your VM is using NAT mode, it's actually using VirtualBox's built-in DHCP server—not your host's ISC-DHCP-Server. Head to VirtualBox → Selectvmr120→ Settings → Network, and switch the adapter to Bridge Adapter (connected to your host's physical network interface). This ensures the VM sends DHCP requests to your host's server.Double-Check the MAC Address
Make sure thehardware ethernetvalue in yourdhcpd.confmatches the VM's actual MAC exactly. You can find the VM's MAC in VirtualBox's network settings (under "Advanced" for the adapter). Even a single wrong character will break the fixed IP mapping.Ensure Fixed IP is Valid & Available
- Confirm
192.168.1.22isn't within the auto-assigned range in yourdhcpd.conf(check therangeline in your subnet configuration). If it is, the server might prioritize dynamic assignment over the fixed entry. - Run
ping 192.168.1.22from your host to check if the IP is already occupied by another device. DHCP won't assign an IP that's in use.
- Confirm
Validate DHCP Server Interface Listening
Open/etc/default/isc-dhcp-serverand check theINTERFACESv4(orINTERFACES) line—it should be set to the network interface your VM is bridged to (e.g.,INTERFACESv4="enp0s3"). If the server isn't listening on the correct interface, it won't receive the VM's DHCP requests.Clear Old DHCP Leases
- On the VM, run these commands to release and renew the lease:
sudo dhclient -r sudo dhclient - On your host, check the DHCP lease file at
/var/lib/dhcp/dhcpd.leases. If there's an old lease entry forvmr120, delete it, then restart the server again withsudo systemctl restart isc-dhcp-server.service.
- On the VM, run these commands to release and renew the lease:
Check DHCP Server Logs for Clues
Run this command to view the server's logs—it will show if the VM's DHCP request is being received, and if there are any errors (like MAC mismatches or IP conflicts):sudo journalctl -u isc-dhcp-server.service
Try these steps one by one, and you should be able to get the fixed IP working for your VM.
备注:内容来源于stack exchange,提问作者jeets

