# Static IP configuration problem



## ProgrammerGuy (Mar 17, 2013)

Hello everyone, I am trying to set up a DNS and web server on my FreeBSD installation. My FreeBSD version is 9 and it's running on VMWare virtual machine. I set my network card mode to bridged. 

My /etc/rc.conf file:

```
hostname="home.domain"
keymap="usa.iso.kbd"
ifconfig_em0="inet 192.168.10.10 netmask 255.255.255.0"
defaultrouter="192.168.10.1"
sshd_enable="YES"
#set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
#--sysinstall generated deltas -- # Sat Mar 16 07:56:30 2013
keympa="hr.iso.kbd"
```

My /etc/resolve.conf:

```
nameserver 195.222.32.10
```

But when I try to ping google.com I get this:

```
ping:cannot resolve google.com: Host name lookup failure
```

I tried to reset netif and router from rc.d. This is what I get for [cmd=]/etc/rc.d/router restart[/cmd]:

```
delete net default : gateway 192.168.10.1
delete net ::ffff:0.0.0.0: gateway ::1
delete net ::0.0.0.0: gateway ::1
delete net fe80::: gatway ::1
delete net ff02::: gateway ::1
ifconfig: interface auto does not exist
add net default : gateway 192.168.10.1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
add net fe80::: gateway ::1
add net ff02::: gateway ::1
```

My question is what's going on? Also I can't connect via Putty I get connection. I tried for couple of days to figure it out but nothing I tried on google, but nothing. Thanks in advance.


----------



## wblock@ (Mar 17, 2013)

There are several problems evident:

1. "sysinstall generated deltas" means you are using sysinstall(8) to edit things.  Please stop using that, just use a normal editor to edit config files.

2. Typo: keympa="hr.iso.kbd"

3. Probably the main problem: you have resolve.conf, but that filename is not spelled that way.  It should be resolv.conf.


----------



## J65nko (Mar 17, 2013)

To check DNS you should use dig(1).


```
[cmd=#]grep nameserver /etc/resolv.conf[/cmd]

nameserver [color=blue]213.133.98.98[/color]
nameserver 213.133.99.99

[cmd=#]  dig www.freebsd.org[/cmd]

; <<>> DiG 9.8.3-P4 <<>> www.freebsd.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30066
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 3, ADDITIONAL: 0

;; QUESTION SECTION:
;www.freebsd.org.               IN      A

;; ANSWER SECTION:
www.freebsd.org.        120     IN      CNAME   wfe0.ysv.freebsd.org.
wfe0.ysv.freebsd.org.   1657    IN      A       8.8.178.110

;; AUTHORITY SECTION:
freebsd.org.            2160    IN      NS      ns2.isc-sns.com.
freebsd.org.            2160    IN      NS      ns1.isc-sns.net.
freebsd.org.            2160    IN      NS      ns3.isc-sns.info.

;; Query time: 7 msec
;; SERVER: [color=blue]213.133.98.98[/color]#53([color=blue]213.133.98.98[/color])
;; WHEN: Sun Mar 17 15:02:39 2013
;; MSG SIZE  rcvd: 160
```
Here dig(1) uses the first nameserver listed in /etc/resolv.conf.

If you this does not work you can specify your nameserver:

```
[cmd=#] dig www.netbsd.org @195.222.32.10[/cmd]

; <<>> DiG 9.8.3-P4 <<>> www.netbsd.org @195.222.32.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: [color=blue]REFUSED[/color], id: 16360
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: [color=blue]recursion requested but not available[/color]

;; QUESTION SECTION:
;www.netbsd.org.                        IN      A

;; Query time: 27 msec
;; SERVER: [color=blue]195.222.32.10#53(195.222.32.10)[/color]
;; WHEN: Sun Mar 17 15:10:29 2013
;; MSG SIZE  rcvd: 32
```

My query is refused, probably because I am not a client from your ISP *bih.net.ba*:

```
[cmd=#] dig +short -x 195.222.32.10[/cmd]
ns1.bih.net.ba.
```


Because of the recursion requested but not available error it is possible that you specified the wrong nameserver in your /etc/resolv.conf:


```
[cmd=#]# dig +norecurse -t ns bih.net.ba @195.222.32.10[/cmd]

; <<>> DiG 9.8.3-P4 <<>> +norecurse -t ns bih.net.ba @195.222.32.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49858
;; flags: qr aa; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2

;; QUESTION SECTION:
;bih.net.ba.                    IN      NS

;; ANSWER SECTION:
bih.net.ba.             86400   IN      NS      ns2.bih.net.ba.
bih.net.ba.             86400   IN      NS      ns1.bih.net.ba.

;; ADDITIONAL SECTION:
ns1.bih.net.ba.         86400   IN      A       195.222.32.10
ns2.bih.net.ba.         86400   IN      A       195.222.32.20

;; Query time: 26 msec
;; SERVER: 195.222.32.10#53(195.222.32.10)
;; WHEN: Sun Mar 17 15:21:34 2013
;; MSG SIZE  rcvd: 96
```
As you can see this non-recursive DNS request works. 

There are 2 possiblities:


Your ISP has configured their nameservers to be authoritative as well as recursive. And they do not allow IP addresses outside their IP range to use their recursive resolving nameservers.

In this case the error I get in resolving *http://www.netbsd.org* is normal. You, as your customer, using one of their IP addresses, should not see this error.



Your ISP has separate nameservers for queries about their *bih.net.ba* domain (authoritative nameserver) and another set of recursive resolving nameservers using different IP addresses that only can be used by their customers.

In this case you will get the same error as me, because authoritative nameservers only can answer queries about the domain they are responsible/authoritative for. You really need to find out the addresses of their recursive resolving nameservers.


----------



## ProgrammerGuy (Mar 17, 2013)

When I enter `# dig [url]http://www.freebsd.org[/url] @195.222.32.10` 

```
;;<<>>DiG 9.8.1 - P1 <<>> www.freebsd.org  @195.222.32.10
;;global options: +cmd
;;connection timed out; no servers could be reached
```


----------



## J65nko (Mar 17, 2013)

What is the output of `# ifconfig` and `# netstat -rn -f inet`?

Can you ping your loopback address and *yahoo*?:

```
[cmd=#] ping -c2 127.0.0.1[/cmd]

PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.034 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.031 ms


[cmd=$]# ping -c2 87.248.122.122[/cmd]

PING 87.248.122.122 (87.248.122.122): 56 data bytes
64 bytes from 87.248.122.122: icmp_seq=0 ttl=58 time=12.065 ms
64 bytes from 87.248.122.122: icmp_seq=1 ttl=58 time=12.285 ms
```


----------



## ProgrammerGuy (Mar 18, 2013)

`# ping [url]http://www.yahoo.com[/url]`

```
ping: cannot resolve www.yahoo.com : Host name lookup failure
```
When I try to ping an IP address in this case google ip address
`# ping 216.239.51.99`

```
ping: sendto : No route to host
```
I can ping localhost it's apsolutly fine.
`# netstat -rn -f inet`

```
Routing table

Internet:
Destination Gateway       Flags  Refs  Use Netif Expire
default     192.168.10.1  UGS      0    28  em0 
127.0.0.1   link#5        UH       0     8  lo0
192.168.10.0/24 link#2    U        0     0  em0
192.168.10.10 link#2      UHS      0     0  lo0
```

`# ifconfig`

```
em0: flags=8843 <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
         options=9b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM>
         ether 00:0c:29:d9:4a:9c
         inet 192.168.10.10 netmask 0xffffff00 broadcast 192.168.10.255
         inet6 fe80::20c:29ff:fed9:4a9c%em0 prefixlen 64 scopeid 0x2
         nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
         media: Ethernet autoselect (1000baseT <full-duplex>)
         status:active
plip0: flags=8810<POINTOPOINT,SIMPLEX,MUTLICAST>metric 0 mtu 1500
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0:   flags=8049<UP,LOOPBACK RUNNING,MUTLICAST>metric 0 mtu 16384
           options=3<RXCSUM,TXCSUM>
           inet6 ::1 prefixlen 128
           inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
           inet 127.0.0.1 netmask 0xff000000
           nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
```


----------



## SirDice (Mar 19, 2013)

Your setup looks good. But it looks like the router on 192.168.10.1 doesn't know where to go next.


----------

