# cannot resolve hostname :(



## fred974 (Aug 8, 2012)

Hello everyone...

I just finish a FreeBSD 9 release installation and I have a problem in pinging my server hostname.

I can ping the default gateway and google as well as the server IP but not the hostname..
could you help please?

Fred

/etc/rc.conf


```
hostname="webbsd.corp.u4agr.com"
ifconfig_em0="DHCP"
defaultrouter="10.8.20.1"
sshd_enable="YES"
moused_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
# -- sysinstall generated deltas -- # Wed Aug  8 11:40:50 2012
keymap="uk.iso"
```

/etc/hosts


```
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain
```

[cmd=]netstat -rn[/Cmd]


```
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            10.8.20.1          UGS         0       26    em0
10.8.20.0/24       link#1             U           0      202    em0
10.8.20.112        link#1             UHS         0        0    lo0
127.0.0.1          link#3             UH          0        0    lo0

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               ::1                           UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%lo0/64                     link#3                        U           lo0
fe80::1%lo0                       link#3                        UHS         lo0
ff01::%lo0/32                     ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%lo0/32                     ::1                           U           lo0
```

[Cmd=]ping yahoo[/Cmd]


```
webbsd# ping yahoo.com
PING yahoo.com (209.191.122.70): 56 data bytes
64 bytes from 209.191.122.70: icmp_seq=0 ttl=52 time=208.349 ms
64 bytes from 209.191.122.70: icmp_seq=1 ttl=52 time=210.072 ms
^C
--- yahoo.com ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 208.349/209.210/210.072/0.861 ms
```

[cmd=]ping own ip[/Cmd]


```
webbsd# ping 10.8.20.112
PING 10.8.20.112 (10.8.20.112): 56 data bytes
64 bytes from 10.8.20.112: icmp_seq=0 ttl=64 time=0.093 ms
64 bytes from 10.8.20.112: icmp_seq=1 ttl=64 time=0.554 ms
64 bytes from 10.8.20.112: icmp_seq=2 ttl=64 time=1.518 ms
^C
--- 10.8.20.112 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.093/0.722/1.518/0.594 ms
```

[cmd=]ping hostname[/cmd]


```
webbsd# ping webbsd
ping: cannot resolve webbsd: Host name lookup failure
```


----------



## johnd (Aug 8, 2012)

In /etc/hosts you need to append:

```
10.8.20.112 webbsd.corp.u4agr.com webbsd
```


----------



## fred974 (Aug 8, 2012)

Thank you Johnd

I can now ping the webbsd server from himself with no problem but i cannot ping webbsd from a windows box.
Any idea why?


```
Ping request could not find host webbsd
```


----------



## SirDice (Aug 8, 2012)

Don't use the hosts file for this. The machine gets it's IP address from DHCP, which can change.

Configure your router, most SOHO modem/routers have functionality in them to resolve locally registered hostnames. If that's not possible set up your own DHCP and ADNS server.


----------



## fred974 (Aug 8, 2012)

Sorry kpa... how do you do that?
i'm still in my learning days.

thank you


----------

