# Static IP Adress Problems [SOLVED]

## jwickens

I have two gentoo computers, the first one was easy to set up a static adress on. here is the conf.d/net file for that computer:

```

dns_domain_lo="WickenzNetwork"

config_eth0=( "192.168.1.104" )

routes_eth-=( "default via 192.168.1.1" )

```

and here is the ifconfig output for that computer: 

```

eth0      Link encap:Ethernet  HWaddr 00:40:05:09:C1:EC

          inet addr:192.168.1.104  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:16771123 errors:0 dropped:0 overruns:0 frame:0

          TX packets:33365344 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:2643654022 (2521.1 Mb)  TX bytes:4163499207 (3970.6 Mb)

          Interrupt:10 Base address:0x8000

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:87 errors:0 dropped:0 overruns:0 frame:0

          TX packets:87 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:4732 (4.6 Kb)  TX bytes:4732 (4.6 Kb)

```

The second computer works fine with dhcpd, but when I try to set up a static ip address for that computer, I can ping the computers behind the NAT router, but I cannot ping any computrs outside the network (like www.google.com) and get a unknown host error message.

```

 ping www.google.com

ping: unknown host www.google.com

```

```

 ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=9.41 ms

64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.90 ms

64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.92 ms

^[64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.91 ms

64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.838 ms

64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=0.822 ms

64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=1.90 ms

64 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=1.90 ms

^X64 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=1.89 ms

64 bytes from 192.168.1.1: icmp_seq=10 ttl=64 time=1.90 ms

--- 192.168.1.1 ping statistics ---

10 packets transmitted, 10 received, 0% packet loss, time 9006ms

rtt min/avg/max/mdev = 0.822/2.443/9.413/2.361 ms

```

here is the second computer's conf.d/net file:

```

dns_domain_lo="WickenzNetwork"

config_eth0=( "192.168.1.108" )

routes_eth0=( "default via 192.168.1.1" )

```

the output of ifconfig w/ static ip config:

```

eth0      Link encap:Ethernet  HWaddr 00:30:48:21:BA:E1

          inet addr:192.168.1.108  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::230:48ff:fe21:bae1/64 Scope:Link

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:8492625 errors:1 dropped:0 overruns:1 frame:2

          TX packets:5982067 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1337748705 (1275.7 Mb)  TX bytes:3145535272 (2999.8 Mb)

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:478392 errors:0 dropped:0 overruns:0 frame:0

          TX packets:478392 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:42896562 (40.9 Mb)  TX bytes:42896562 (40.9 Mb)

```

and output of ifconfig wtih dchpd (the conf.d/net has its lines commeted out and eth0 is restarted):

```
eth0      Link encap:Ethernet  HWaddr 00:30:48:21:BA:E1

          inet addr:192.168.1.108  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::230:48ff:fe21:bae1/64 Scope:Link

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:8492736 errors:1 dropped:0 overruns:1 frame:2

          TX packets:5982211 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1337758871 (1275.7 Mb)  TX bytes:3145556946 (2999.8 Mb)

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:478410 errors:0 dropped:0 overruns:0 frame:0

          TX packets:478410 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:42898002 (40.9 Mb)  TX bytes:42898002 (40.9 Mb)

```

and pinging computers outside the network works again with dhcpd:

```

PING www.l.google.com (64.233.161.104) 56(84) bytes of data.

64 bytes from od-in-f104.google.com (64.233.161.104): icmp_seq=1 ttl=243 time=52.9 ms

64 bytes from od-in-f104.google.com (64.233.161.104): icmp_seq=2 ttl=243 time=35.4 ms

64 bytes from od-in-f104.google.com (64.233.161.104): icmp_seq=3 ttl=243 time=37.0 ms

--- www.l.google.com ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2018ms

rtt min/avg/max/mdev = 35.435/41.800/52.963/7.919 ms

```

The two computers are connected to a Linkseys Wireless-G Broadband Router(WRT54G) with ethernet cables(not the wireless connection) and wtih NAT enabled.

I need static ip adresses so the port forwarding feature of the router doesnt rely on dhcp.

I have tried and tried again, but I am at my wit's end.   :Sad: 

All help is appreciated.Last edited by jwickens on Sat Feb 24, 2007 2:21 am; edited 3 times in total

----------

## serge.2k

Hm... are you sure you set up the DNS servers? Dhcpcd sets them up automatically, but in static ip configurations they need to be configured manually

Try to ping www.google.com 's IP address.

If that works, then your /etc/resolv.conf is missing the DNS servers. Edit it to add them.

----------

## NeddySeagoon

jwickens,

Welcome to Gentoo.

A few things - you should not assign static IP addresses that are in the range that your dhcp server will also assign.

Look at the dhcp set up in your router and assign static addresses outside of its dhcp range.

DHCP allows you to bind an IP to a MAC address, so you have a static IP but everything is set up by DHCP.

Since you have then same IP 192.168.1.108 both statically and with DHCP, the DHCP server will know it didn't assign it and may not be happy to route it. Routing does not occur for IPs on the same subnet.

It could also be your /etc/resolv.conf in error. That file is used to tell the network where to find a nameserver.

Can you 

```
ping 64.233.187.99
```

thats google.com by IP address. If that works, you have a name resolution issue.

Post the output of

```
route
```

and the content of /etc/resolv.conf

----------

## jwickens

Thank you for the help. Yes, my problem was that I did not edit resolv.conf to add the DNS servers. (pinging the numerical ip adress for google did work.) I don't know how to find the DNS server ip adresses so I just copied the nameservers from the computer that could look up domains. Thanks for the tips, now I can rest easy that my server wont be hidden from me suddenly because of an ip adress change.[/code]

----------

## NeddySeagoon

jwickens,

Your router probably runs a caching DNS server, so its IP will probably work.

If the nameservers you have copied have public IPs, they are probably your ISP nameservers, which will be right for you anyway.

----------

## dol-sen

I am having similar problems.  But mine is due to lo overwriting my /etc/resolv.conf blowing away my nameserver settings.  I never had this problem using the old configuration method/syntax.

Do you know how to fix that one, or a good idea where to look?

----------

## NeddySeagoon

dol-sen,

As a get you going put 

```
nameserver 4.2.2.1
```

into /etc/resolv.conf 

Thats a public nameserver.

Now you can get on the internet, go to your ISPs site and look up the nameservers you are supposed to use.

Youshould have two or three, in case one breaks. Use your ISPs nameservers when you know what they are.

----------

## dol-sen

I have a back-up copy of resolv.conf with the nameservers defined.  My problem is when I start eth0 resolv.conf gets overwritten by the lo interface and it does not contain any nameservers.   I even tried to write protect it, but it gets overwritten anyway.  I have this box currently set for dhcp so that it works for now without interruption.  I want it configured statically so I can do some other things later. 

As I said the old configuration method/style did not have this problem.

here is /etc/conf.d.net, I've tried several variations.

```
#dns_domain_lo="weezapoppin.dol-sen.ca"

#nis_domain_lo="weezapoppin.dol-sen.ca"

#config_eth0=( "192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255" )

#routes_eth0=( "default gw 192.168.0.1" )

#dhcp_eth0="nodns nontp nonis"

config_eth0=( "dhcp" )
```

I want to point dyndns to this location as "weezapoppin.dol-sen.ca".  my primary location being at home "dol-sen.ca"

----------

## NeddySeagoon

dol-sen,

You need the 

```
dhcp_eth0="nodns"
```

option so your nameservers are not overwritten.

It looks like your dhcp server is not set up to provide the nameserver entries.

----------

## nobody13

 *NeddySeagoon wrote:*   

> dol-sen,
> 
> You need the 
> 
> ```
> ...

 

This worked for me but got overwritten when I added: dns_domain_lo="homenetwork"

Is there a way to just specify my nameserver in /etc/conf.d/net so when I make changes, resolv.conf won't have to be edited? Or did I miss something else that needs to be configured to find it automaticly?

----------

## NeddySeagoon

nobody13,

Leave dns_domain_lo="homenetwork" out of the net file and make the correct entries in resolv.conf

----------

## nobody13

ok, thanks

----------

## mimosinnet

I have cretated a HOWTO in the gentoo wiki from te contents of this post as I found it really useful and not covered elsewhere. I have a limited understanding of what has been discussed here, so I would very much appreciate if any of the participants in the post (or anybody else) could have a look at the howto and correct or improve it. You can find the HOWTO here: http://gentoo-wiki.com/HOWTO_static_ip_with_dhcp_router

----------

