# DNS Issue with FreeBSD Guest on virtualbox



## JKHH07 (Sep 21, 2011)

I am simply trying to specify a DNS server for my FreeBSD Guest OS in VirtualBox-4.1

The FreeBSD box is running inside Virtual Box. Virtual Box is hosted on Centos6.

We have our DNS server at 64.81.127.2 and 64.81.159.2. I can ping these DNS servers with replies from FreeBSD, no problem, but I cannot get it to resolve urls for FreeBSD (google.com, yahoo.com, etc). Just to be clear I am not trying to have FreeBSD act as a nameserver. Any help would be appreciated, I'm 8 hours in.


FreeBSD Guest OS Setup
Bridged Adapter (through Vbox) on em0
IP 69.12.13.125
SM 255.255.255.0
GW 69.12.13.3
FreeBSD>>:cat /etc/resolv.conf
nameserver 64.81.127.2
nameserver 64.81.159.2


Virtual Box Host
IP 69.12.13.121
SM 255.255.255.0
GW 69.12.13.3
CENTOS6>>:cat /etc/resolv.conf
nameserver 64.81.127.2
nameserver 64.81.159.2


----------



## silverglade00 (Sep 22, 2011)

It's been a while since I had the same problem, but I think I fixed it by making the host OS the nameserver for the guest. Never seemed like the proper solution, but it worked.


----------



## wblock@ (Sep 22, 2011)

No real idea, but maybe dig(1) output will show something.
`% dig @64.81.127.2 google.com`


----------



## redw0lfx (Sep 22, 2011)

No real idea either, except that maybe your VM guest is being NATed?

On the CentOS machine, I would run wireshark and filter out port 53, to see the dns request packets going and coming. Might give you a better idea why it can't resolve the hostnames.


```
#> tshark -f "port 53"
```


----------



## JKHH07 (Sep 23, 2011)

silverglade00 said:
			
		

> It's been a while since I had the same problem, but I think I fixed it by making the host OS the nameserver for the guest. Never seemed like the proper solution, but it worked.



silverglade00 - I did try this both NAT and Bridged, but no luck. I wonder how you did this ?


----------



## JKHH07 (Sep 23, 2011)

wblock@ said:
			
		

> No real idea, but maybe dig(1) output will show something.
> `% dig @64.81.127.2 google.com`




[font="Arial Black"]WBLOCK@ [/font]- I tried this out, and I did get a good response. So we know the system CAN communicate with the DNS. 

My next step was  "ping google.com" - but this comes out to "ping: cannot resolve http://www.google.com: Host name lookup failure"

Perhaps there is I typo'd a configuration somewhere making the system not use /etc/resolv.conf ???

my /etc/resolv.conf

nameserver      64.81.127.2
nameserver      64.81.159.2

[font="Arial Black"]Output[/font]

[root@freebsd ~]# dig @64.81.127.2 google.com

; <<>> DiG 9.6.-ESV-R3 <<>> @64.81.127.2 google.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31973
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             8       IN      A       74.125.73.99
google.com.             8       IN      A       74.125.73.103
google.com.             8       IN      A       74.125.73.104
google.com.             8       IN      A       74.125.73.105
google.com.             8       IN      A       74.125.73.106
google.com.             8       IN      A       74.125.73.147


----------



## JKHH07 (Sep 23, 2011)

redw0lfx said:
			
		

> No real idea either, except that maybe your VM guest is being NATed?
> 
> On the CentOS machine, I would run wireshark and filter out port 53, to see the dns request packets going and coming. Might give you a better idea why it can't resolve the hostnames.
> 
> ...




redw01fx - Capturing on em0
  0.000000 69.12.13.125 -> 64.81.127.2  DNS Standard query A http://www.google.com
  0.002091  64.81.127.2 -> 69.12.13.125 DNS Standard query A http://www.google.com

This is a cool utility. I'll remember this one


----------



## wblock@ (Sep 23, 2011)

Has /etc/nsswitch.conf been changed?


----------



## redw0lfx (Sep 23, 2011)

JKHH07 said:
			
		

> redw01fx - Capturing on em0
> 0.000000 69.12.13.125 -> 64.81.127.2  DNS Standard query A http://www.google.com
> 0.002091  64.81.127.2 -> 69.12.13.125 DNS Standard query A http://www.google.com
> 
> This is a cool utility. I'll remember this one



I find that bit interesting.  The DNS Standard query packet was sent to your nameserver, but your nameserver sent the same type of packet back, rather an a response, for example my nameserver is 192.168.15.19:


```
sudo tshark -i tun0 -f "port 53"
  7.147073 172.16.118.18 -> 192.168.15.19 DNS 60 Standard query A google.com
  7.195351 192.168.15.19 -> 172.16.118.18 DNS 292 Standard query response A 74.125.67.147 A 74.125.67.99 A 74.125.67.103 A 74.125.67.104 A 74.125.67.105 A 74.125.67.106
```

Also, not sure if that was a also a typo, but in an earlier post, you said you 'ping google.com' but got a response of 'can't find host for http://www.google.com'.  Just making sure that it isn't a configuration error were your domain might be getting appended incorrectly either by the Guest OS or your actual nameserver.


----------

