# Static IP Problems

## computerguy769

I am Having Some Troubles Getting A Static IP working on one of my machines. 

Here's My ifconfig

```

eth0      Link encap:Ethernet  HWaddr 00:50:8D:58:7D:96

          inet addr:192.168.1.107  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:229699 (224.3 Kb)  TX bytes:47694 (46.5 Kb)

          Interrupt:17 Base address:0x4000

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:132 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:0

          RX bytes:11463 (11.1 Kb)  TX bytes:11463 (11.1 Kb)

```

and my route output

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

loopback        *               255.0.0.0       U     0      0        0 lo

default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

```

Now Those are the ones I have when I am attempting to use a statc IP

I can define a static Ip Manually by using 

```

ifconfig eth0 192.168.1.107 netmask 255.255.255.0

route add default gw 192.168.1.1

```

Now I can Get On with dhcp  this is my ifconfig

```

eth0      Link encap:Ethernet  HWaddr 00:50:8D:58:7D:96

          inet addr:192.168.1.107  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:1245479 (1.1 Mb)  TX bytes:169735 (165.7 Kb)

          Interrupt:17 Base address:0x4000

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:170 errors:0 dropped:0 overruns:0 frame:0

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

          collisions:0 txqueuelen:0

          RX bytes:149 (14.3 Kb)  TX bytes:14739 (14.3 Kb)

```

and my route

```

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

loopback        *               255.0.0.0       U     0      0        0 lo

default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

```

It's Just annoying to have to set my IP settings manually please help

----------

## linuxbum

Did you setup the /etc/conf.d/net file?

this is where static IP can be setup.

See file /etc/conf.d/net.example

edit the net file and is should work for you.

```

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "192.168.10.9 netmask 255.255.255.0 broadcast 192.168.10.255" )

routes_eth0=( "default via 192.168.10.1" )

```

The Handbooks explains this as well.

----------

## computerguy769

Just tried that

Here's the file It Still does Not Work

```

#This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

#Sets Domain Name Up

#Sets Up ETH0

config_eth0=( "192.168.1.107 netmask 255.255.255.0 broadcast 192.168.1.255" )

routes_eth0=( "default gw 192.168.1.1" )

```

I didn't Put the domain in here for security reason

It isn't fixed so please help

----------

## computerguy769

Someone Please Help Me 

I Am tired of resetting the settings manually

----------

## timeBandit

Please define "doesn't work." What you've posted so far isn't exposing the problem.

Please post the output of these two commands:

```
ping -c4 192.168.1.1

nslookup gentoo.org
```

when you are configured with DHCP, and again when you are configured with a static IP.

----------

## ratmonkey

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8#doc_chap2

----------

## linuxbum

Computerguy

You asked for a static IP not DHCP which do you want?

Did you also run rc-update command?

```

rc-upate add net.eth0 default

```

----------

## 0x001A4

I'm not too sure if this helps, but when I set my static IP in /etc/conf.d/net  I need to leave out the broadcast or it doesnt work.

```
config_eth0=( "192.168.0.100 netmask 255.255.255.0" )

routes_eth0=( "default gw 192.168.0.1" )
```

----------

## robdinardo

Newbie here... Similar problem.  I followed the documentation and tried both dhcp and static.  Could it be a routing issue?  I am able to ping internal IP addresses fine.  Also...

```
ping -c 3 www.gentoo.org
```

returns 

```

PING www.gentoo.org (38.99.64.201) 56(84) bytes of data

FROM 20.4.120.1 icmp_seq 2 Destination Host Unreachable

FROM 20.4.120.1 icmp_seq 3 Destination Host Unreachable

... etc

```

Notice the ip address from the ping, 38.99.64.201 - that is gentoo.org!  Does that mean that it reads the DNS server, but not the internet?  Also, does the MAC address from my network card need to be added to the firewall / gateway to be allowed to 'see' the internet?

Here is more information:

entering

```
ifconfig
```

returns

```

Kernel IP Routing Table 

Destination   Gateway     Genmask        Flags   Metric  Ref  Use  Iface 

20.4.120.0    *           255.255.255.0  U       0       0    0    eth0 

loopback      *           255.0.0.0      U       0       0    0    lo 

default       20.4.120.1  0.0.0.0        UG      0       0    0    eth0 

```

I need this to work to continue the installation.  Please help.

----------

## timeBandit

 *robdinardo wrote:*   

> Newbie here... Similar problem.  ...  Could it be a routing issue?  I am able to ping internal IP addresses fine.  Also...
> 
> ```
> PING www.gentoo.org (38.99.64.201) 56(84) bytes of data
> 
> ...

 

That's exactly right. It's able to contact a nearby nameserver and get the IP for gentoo.org, but when it tries to send to that IP it can't find a working route to the target host's network ("Destination Host Unreachable").

 *Quote:*   

> [D]oes the MAC address from my network card need to be added to the firewall / gateway to be allowed to 'see' the internet? Here is more information:
> 
> ```
> Kernel IP Routing Table 
> 
> ...

 

That's quite possible. Your routing table seems OK--but I was expecting to see a private IP subnet, like 99.99% of the people who post here, not a Class A network. Ask the adminstrator of your gateway if anything needs to be opened up for you, and confirm you've configured the correct IP and subnet mask.

----------

## robdinardo

Thanks TimeBandit.  Please excuse the ignorance, but what do mean by having the gateway admin see if anything needs to be "opened up" ?  

Do you mean a port? If so, which port?  

Should I add the MAC address of the network card somewhere?

Would there be a way to find out which port is being used to try to get past the gateway?  

By the way, we are using ISA as the firewall and we connect via a proxy for our http - and I did:

```
export http_proxy="http://20.4.120.15:8080"
```

prior to my previous post.

Thank you.

----------

## timeBandit

 *robdinardo wrote:*   

> Please excuse the ignorance, but what do mean by having the gateway admin see if anything needs to be "opened up"?
> 
> Do you mean a port? If so, which port?  
> 
> Should I add the MAC address of the network card somewhere?

 Conceptually, that's what I was referring to--allowing traffic from your specific MAC or IP address to get through the firewall or proxy. Which brings us to my own area of ignorance  :Smile: , namely how to do so. I have only anecdotal experience in this area so I'll defer to others who have practical knowledge.

 *Quote:*   

> Would there be a way to find out which port is being used to try to get past the gateway?

 It will vary depending on the service you're trying to contact. An HTTP request will try to connect on port 80, outgoing mail usually on 25 (SMTP), secure shell (SSH) on 22, etc. When possible (allowed), it's easiest to start with unrestricted access to establish basic connectivity.

 *Quote:*   

> By the way, we are using ISA as the firewall and we connect via a proxy for our http - and I did:
> 
> ```
> export http_proxy="http://20.4.120.15:8080"
> ```
> ...

 You're now outside my experience again. The presence of a proxy is a complicating factor. Proxies in general are not limited to HTTP--it's possible you may have to go through the proxy for all Internet access, instead of the gateway you're using now. For example, the gateway could be allowing DNS requests from any client on the local net (so you can resolve gentoo.org), and denying all other traffic unless it comes from the proxy (so you can't connect to gentoo.org). I don't know whether that's common or wacky, but it's possible.

I hope others can chime in with more guidance for you, but you may need to involve your network administrator(s) in this project. If they're running a tight ship, your box might never reach the outside world without authorization and some help (in terms of what values to configure and where).

----------

## computerguy769

Sorry For The Delay (school You Know)

I am trying to get a static IP address, I need it for a web server I am using a Linksys WRT54G router.

I had it working before Last time I had gentoo installed (the drive with the / partition died no raid 1  :Sad:  ) 

This Is What I am getting on a ping

```

ping -c 3 www.gentoo.org

ping: unknown host www.gentoo.org

```

This Is All On Static

Pinging My Router

```

ping -c4 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=1.10 ms

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

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

64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.770 ms

```

nslookup

```

nslookup gentoo.org

bash: nslookup: command not found

```

This is on Dynamic

Pinging My router

```

ping -c4 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=0.740 ms

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

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

64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.749 ms

--- 192.168.1.1 ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3005ms

rtt min/avg/max/mdev = 0.740/0.746/0.749/0.019 ms

```

nslookup

```

nslookup gentoo.org

bash: nslookup: command not found

```

And Yes They Are Bolth Identical

I have been using gentoo for about two years and have never had this problem before.

BTW: I have had my /etc/conf.d/net setup by the book

----------

## timeBandit

*******

EDIT: I misread your output. Please emerge net-dns/bind-tools and then run those two nslookup commands again (with and without DHCP).

*******

--- Skip this for now, I'm leaving it here in case it turns out to be correct.   :Smile: 

Ok, that's encouraging and what I hoped to see. You can at least reach your router but you're not resolving any names.

So the next two steps:

1. Can you reach any further than your router?

```
ping -c3 38.99.64.201
```

That's the IP of Gentoo's web server. If that works your routing table is OK.

2. Please post the contents of /etc/resolv.conf. Odds are, you're just missing the nameserver entry.

--- OK, start reading again:   :Wink: 

Incidentally, referring to an earlier post: when you assign a static IP to your machine, choose a host number that is not in the range managed by your router's DHCP server. Don't reuse the same host address you received via DHCP (which looks to be 192.168.1.107). For example, if your router gives addresses from 192.168.1.100-199 to DHCP clients, you should choose your static host address from either the 192.168.1.2-99 or 192.168.1.200-254 range. The router will know nothing of your static IP assignments, so it's up to you to avoid its DHCP range when choosing static addresses. Otherwise, if you plug in a DHCP client like a laptop, your router might issue an address you've already assigned to a host.

----------

## computerguy769

Okay This IS on dhcp

nslookup

```

nslookup gentoo.org

Server:         68.87.74.162

Address:        68.87.74.162#53

Non-authoritative answer:

Name:   gentoo.org

Address: 204.74.99.100

```

ping

```

ping -c3 38.99.64.201

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

64 bytes from 38.99.64.201: icmp_seq=1 ttl=40 time=122 ms

64 bytes from 38.99.64.201: icmp_seq=2 ttl=40 time=123 ms

64 bytes from 38.99.64.201: icmp_seq=3 ttl=40 time=121 ms

--- 38.99.64.201 ping statistics ---

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

rtt min/avg/max/mdev = 121.464/122.728/123.870/1.026 ms

```

/etc/resolv.conf

```

Generated by dhcpcd for interface eth0

nameserver 192.168.1.10

nameserver 68.87.74.162

nameserver 68.87.68.162

```

This Is On Static 192.168.1.107

nslookup

```

nslookup gentoo.org

;; connection timed out; no servers could be reached

```

ping

```

ping -c3 38.99.64.201

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

64 bytes from 38.99.64.201: icmp_seq=1 ttl=40 time=122 ms

64 bytes from 38.99.64.201: icmp_seq=2 ttl=40 time=123 ms

64 bytes from 38.99.64.201: icmp_seq=3 ttl=40 time=122 ms

--- 38.99.64.201 ping statistics ---

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

rtt min/avg/max/mdev = 122.399/122.748/123.389/0.536 ms

```

/etc/resolv.conf

```

# Generated by net-scripts for interface lo

domain seanhalvorson.info

```

On Static 192.168.1.10

nslookup

```

nslookup gentoo.org

;; connection timed out; no servers could be reached

```

ping

```

ping -c3 38.99.64.201

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

64 bytes from 38.99.64.201: icmp_seq=1 ttl=40 time=121 ms

64 bytes from 38.99.64.201: icmp_seq=2 ttl=40 time=123 ms

64 bytes from 38.99.64.201: icmp_seq=3 ttl=40 time=123 ms

--- 38.99.64.201 ping statistics ---

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

rtt min/avg/max/mdev = 121.734/122.879/123.664/0.876 ms

```

/etc/resolv.conf

```

# Generated by net-scripts for interface lo

domain seanhalvorson.info

```

----------

## robdinardo

Hey timeBandit!  What you said about going through the proxy gave me an idea.   

I did "net-setup" and used the proxy IP as the default gateway address and I am now able to ping outside successfully.  Thank you for giving me that idea!

So now I will be able to continue my install.  I guess if I wanted to use this box (eventually) as a web server, it would have to be accessable in a DMZ or something...

Anyway... thank you and Merry Christmas / Happy Holidays / Happy New Year

 :Very Happy: 

----------

## Ast0r

 *computerguy769 wrote:*   

> Okay This IS on dhcp
> 
> nslookup
> 
> ```
> ...

 

You aren't setting your nameserver when you are using a static IP address. Open /etc/resolv.conf and add these lines

```
nameserver 192.168.1.10

nameserver 68.87.74.162

nameserver 68.87.68.162
```

----------

## timeBandit

 *robdinardo wrote:*   

> Hey timeBandit!  What you said about going through the proxy gave me an idea.   
> 
> I did "net-setup" and used the proxy IP as the default gateway address and I am now able to ping outside successfully.  Thank you ... and Merry Christmas / Happy Holidays / Happy New Year
> 
> 

 

Outstanding! Same to you.  :Very Happy: 

@computerguy769:

Do what Ast0r said and you should be good to go. However, I wonder about this: *computerguy769 wrote:*   

> /etc/resolv.conf
> 
> ```
> # Generated by net-scripts for interface lo
> 
> ...

 That "generated by" line is a little worrisome. Are you using a script or tool to set up your static IP configuration, or was this a one-time generated file that you copied over /etc/resolv.conf?

If there's a script involved, you may need to configure that script to add the nameserver lines. Otherwise, if you re-run it, they could be wiped out (and you'll be stuck again if you forgot this thread  :Wink:  ).

----------

## UberLord

Lession #1

If you set dns_domain_lo="foo" then you should also put dns_servers_lo="1.2.3.4"

----------

## timeBandit

 *UberLord wrote:*   

> Lession #1
> 
> If you set dns_domain_lo="foo" then you should also put dns_servers_lo="1.2.3.4"

 

Thanks. As you may have guessed, I configured my system years ago and haven't disturbed it since.   :Very Happy: 

----------

## computerguy769

I have gotten it working with the resolv.conf

Now to deal with the script

(The Computer is a web server)

I need it to basically attend to itself (including power outages happens often here ~2times a week)

Do any of you know how to take care of the script that timebandit was talking about I still need to set something manually

new /etc/conf.d/net

```

#Sets Up ETH0

config_eth0=( "192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255" )

routes_eth0=( "default gw 192.168.1.1" )

```

----------

