You are not logged in.

#1 2009-11-03 10:01:10

ryeguy146
Member
Registered: 2009-10-28
Posts: 33

DHCP works, but no Static [Solved]

I'm having a terrible time with setting a static IP address using /etc/rc.conf, however, setting eth0 to use DHCP works perfectly. While using a static IP, I seem to be having problems accessing my nameservers, as defined in /etc/resolv.conf.head. If I switch back to DHCP and reset networking (sudo /etc/rc.d/network restart), then everything works fine again. Pinging a host while using static IP results in the following error:

ping: unknown host google.com

rc.conf line:

eth0="eth0 192.168.0.23 netmask 255.255.255.0 broadcast 192.168.0.255"

resolv.conf.head:

domain domain.actdsltmp
nameserver 216.165.129.158
nameserver 216.170.153.146

resolv.conf (created when using DHCP):

domain domain.actdsltmp
nameserver 192.168.0.1
nameserver 198.6.1.3

The output of route -n is the same in both cases.

I have absolutely no idea how to solve this problem. I've never run into any errors changing many other distros to use static IPs, I'm assuming that I'm just missing something. Any ideas on solving this problem? I've read that I can use netcfg to build a profile, and I may do so, but I'd love to know why this method isn't working.

Last edited by ryeguy146 (2009-11-03 19:55:47)

Offline

#2 2009-11-03 10:20:17

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,222
Website

Re: DHCP works, but no Static [Solved]

Install the 'dnsutils' package (you'll have to do this while using DHCP I'm guessing) and post the output of the following commands while you're on a static address:

dig google.com @216.165.129.158
dig google.com @216.170.153.146
ping 75.127.96.189

Last edited by fukawi2 (2009-11-03 10:21:09)

Offline

#3 2009-11-03 10:33:28

ryeguy146
Member
Registered: 2009-10-28
Posts: 33

Re: DHCP works, but no Static [Solved]

I appreciate the help. I ran these commands with my static IP.

dig google.com @216.165.129.158:

; <<>> DiG 9.6.1 <<>> google.com @216.165.129.158
;; global options: +cmd
;; connection timed out; no servers could be reached

dig google.com @216.170.153.146:

; <<>> DiG 9.6.1 <<>> google.com @216.170.153.146
;; global options: +cmd
;; connection timed out; no servers could be reached

ping 75.127.96.189:

connect: Network is unreachable

I just noticed that while I'm having problems, route -n is returning the following:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

Perhaps I need to add a static route while using static IP for external networks? I've never had to do anything like that before. If so, where can I find information on adding a static route to the table? While running DHCP, I see that the second line has been added in the output of route -n.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    202    0        0 eth0

Offline

#4 2009-11-03 16:05:46

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: DHCP works, but no Static [Solved]

I don't know much about these things so just to say that I use static IP but write my nameservers directly to resolv.conf. Never had a problem. Perhaps only when you are actually using dhcp does resolv.conf get overwritten (and resolv.conf.head comes into play)?

Offline

#5 2009-11-03 19:13:34

ryeguy146
Member
Registered: 2009-10-28
Posts: 33

Re: DHCP works, but no Static [Solved]

My problem with resolv.conf is that it is constantly overwritten, DHCP or Static. Since resolv.conf.head takes precedence over it, I keep my nameservers there. I probably won't have to do that once I get this all settled down, but switching back and forth is killing me slowly.

Offline

#6 2009-11-03 19:23:36

MadTux
Member
Registered: 2009-09-20
Posts: 553

Re: DHCP works, but no Static [Solved]

To prevent dhcp from overriding resolv.conf:

# Arguments to be passed to the DHCP client daemon
# DHCPCD_ARGS="-q"
DHCPCD_ARGS="-C resolv.conf -q"

See:
http://wiki.archlinux.org/index.php/Beg … .28DHCP.29

Offline

#7 2009-11-03 19:33:48

ryeguy146
Member
Registered: 2009-10-28
Posts: 33

Re: DHCP works, but no Static [Solved]

Well, thank you for that, but my .head is working just fine in that respect as well. I appreciate the resource though, I suppose I'll do some reading to see if I can solve my own problem. Right after I figure out mpd.

That was interesting. It was a single "!" that was tripping me up:

Dynamic IP:

ROUTES=(!gateway)

Static IP:

ROUTES=(gateway)

I'm quite sure that this has solved my problem. After restarting /etc/rc.d/network, I have the extra route. I thought that I was skilled enough in Linux not to need the beginner's section, but I suppose that it has information that is pertinent to Arch rather than general Linux knowledge. I've got some reading to do.

Thanks for the pointers guys. Case closed. I think.

Oh, and I fixed mpd too. Just mounting my NTFS partition with a bad fmask. Now, time to learn hotplugging with HAL!

Last edited by ryeguy146 (2009-11-03 19:55:24)

Offline

#8 2009-11-03 19:57:44

uwinkelvos
Member
Registered: 2009-06-07
Posts: 129

Re: DHCP works, but no Static [Solved]

Didi you setup a default route to the gateway in rc.conf?

rc.conf:

eth0="eth0 192.168.2.20 netmask 255.255.255.0 broadcast 192.168.2.255"
INTERFACES=(eth0)
gateway="default gw 192.168.2.1"
ROUTES=(gateway)

resolve.conf:

nameserver 192.168.2.1

Offline

#9 2009-11-03 21:13:20

ryeguy146
Member
Registered: 2009-10-28
Posts: 33

Re: DHCP works, but no Static [Solved]

No, I hadn't. I had assumed that simply changing the eth0 to static was enough, but I had to delete the "!" before the default gateway to add the route while using static IP. I'm all better now.

Offline

#10 2009-11-04 02:04:39

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: DHCP works, but no Static [Solved]

ryeguy146 wrote:

No, I hadn't. I had assumed that simply changing the eth0 to static was enough, but I had to delete the "!" before the default gateway to add the route while using static IP. I'm all better now.

Heh, I have ROUTES=(!gateway) on my server. I suppose our connection is different thus requiring a different setup - I use an adsl modem connected directly to the server. Every other computer on my lan (static IPs all the way) has the gateway activated to have internet access but my server is the gateway. No router used. You probably have a router somewhere.

Offline

Board footer

Powered by FluxBB