VirtualBox

Opened 18 months ago

#21713 new defect

DHCP engine of the NatNetwork doesn't read/get host's DNS settings to pass to the guest.

Reported by: Farhad Owned by:
Component: network/NAT Version: VirtualBox-7.0.8
Keywords: DNS, DHCP, NatNetwork Cc:
Guest type: Linux Host type: Mac OS X

Description

When I set the VM to be on the NatNetwork, Neither my host DNS list nor my home router's DNS list is not provided to the guest via DHCP.

Below is the DHCP configuration after it got created. You can see there's no 6/legacy: in it.

❯ VBoxManage list dhcpservers
NetworkName:    NatNetwork
Dhcpd IP:       10.0.2.3
LowerIPAddress: 10.0.2.4
UpperIPAddress: 10.0.2.254
NetworkMask:    255.255.255.0
Enabled:        Yes
Global Configuration:
    minLeaseTime:     default
    defaultLeaseTime: default
    maxLeaseTime:     default
    Forced options:   None
    Suppressed opts.: None
        1/legacy: 255.255.255.0
        3/legacy: 10.0.2.1
Groups:               None
Individual Configs:   None

Below is what I get in the guest OS and the content of the /etc/resolv.conf is empty.

$nslookup google.com
;; communications error to ::1#53: connection refused
;; communications error to ::1#53: connection refused
;; communications error to ::1#53: connection refused
;; communications error to 127.0.0.1#53: connection refused
;; no servers could be reached

I can ping IP addresses though like below.

$ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=3.15 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=3.16 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=3.08 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=56 time=3.53 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=56 time=3.49 ms
^C
--- 1.1.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4002ms
rtt min/avg/max/mdev = 3.081/3.283/3.533/0.188 ms

This is the result guest OS requesting DHCP in which there's no DNS settings:

$sudo nmap --script broadcast-dhcp-discover
[sudo] password for farhad: 
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-06 22:54 CEST
Pre-scan script results:
| broadcast-dhcp-discover: 
|   Response 1 of 1: 
|     Interface: enp0s3
|     IP Offered: 10.0.2.10
|     Server Identifier: 10.0.2.3
|     DHCP Message Type: DHCPOFFER
|     Subnet Mask: 255.255.255.0
|     Router: 10.0.2.1
|_    IP Address Lease Time: 10m00s
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 10.38 seconds

When I modify the DHCP on the host via VBoxManage dhcpserver modify --network NatNetwork --set-opt 6 1.1.1.1,8.8.8.8 and restarting it via vboxmanage dhcpserver restart --netname NatNetwork, then the DNS settings will show up in its configuratio, DHCP engine passes the values to the guest, and works as expected. Here are the results:

❯ VBoxManage list dhcpservers
NetworkName:    NatNetwork
Dhcpd IP:       10.0.2.3
LowerIPAddress: 10.0.2.4
UpperIPAddress: 10.0.2.254
NetworkMask:    255.255.255.0
Enabled:        Yes
Global Configuration:
    minLeaseTime:     default
    defaultLeaseTime: default
    maxLeaseTime:     default
    Forced options:   None
    Suppressed opts.: None
        1/legacy: 255.255.255.0
        3/legacy: 10.0.2.1
        6/legacy: 1.1.1.1,8.8.8.8
Groups:               None
Individual Configs:   None
$cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 1.1.1.1
nameserver 8.8.8.8
$sudo nmap --script broadcast-dhcp-discover
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-06 22:59 CEST
Pre-scan script results:
| broadcast-dhcp-discover: 
|   Response 1 of 1: 
|     Interface: enp0s3
|     IP Offered: 10.0.2.10
|     Server Identifier: 10.0.2.3
|     DHCP Message Type: DHCPOFFER
|     Subnet Mask: 255.255.255.0
|     Router: 10.0.2.1
|     Domain Name Server: 1.1.1.1, 8.8.8.8
|_    IP Address Lease Time: 10m00s
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 10.34 seconds
$nslookup google.com
Server:		1.1.1.1
Address:	1.1.1.1#53

Non-authoritative answer:
Name:	google.com
Address: 142.250.147.101
Name:	google.com
Address: 142.250.147.139
Name:	google.com
Address: 142.250.147.138
Name:	google.com
Address: 142.250.147.102
Name:	google.com
Address: 142.250.147.113
Name:	google.com
Address: 142.250.147.100
Name:	google.com
Address: 2a00:1450:4025:c01::64
Name:	google.com
Address: 2a00:1450:4025:c01::65
Name:	google.com
Address: 2a00:1450:4025:c01::8a
Name:	google.com
Address: 2a00:1450:4025:c01::8b
$ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=1674 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=668 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=3.02 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=56 time=3.10 ms
64 bytes from 1.1.1.1: icmp_seq=5 ttl=56 time=4.50 ms
64 bytes from 1.1.1.1: icmp_seq=6 ttl=56 time=4.05 ms
^C
--- 1.1.1.1 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5009ms
rtt min/avg/max/mdev = 3.022/392.808/1673.798/622.174 ms, pipe 2

Also, in the Bridged mode, the guest receives all the DNS list I have registered on my home router.

I have attached my VM logs for both cases (DHCP with --set-opt and without it) to this ticket.

Thank you for your attention to this matter.

Change History (0)

Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette