You are not logged in.

#1 2009-10-20 00:05:02

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

trying to setup static ip but /etc/resolv.conf keeps getting rewritten

Just like the tile says, I am trying to configure a static ip. Everything works great after I modify /etc/rc.conf and run /etc/rc.d/network restart, but as soon as I reboot /etc/resolv.conf gets rewritten and I lose my dns resolution.  (I can connect to any of the local machines but I can't ping www.google.com)

heres my /etc/rc.conf

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime", any other value will result
#   in the hardware clock being left untouched (useful for virtualization)
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.UTF-8"
HARDWARECLOCK="UTC"
TIMEZONE="America/New_York"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
#MOD_BLACKLIST=() #deprecated
MODULES=(acpi-cpufreq)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="arch"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="dhcp"
eth0="eth0 192.168.1.51 netmask 255.255.255.0 broadcast 192.168.1.255"
INTERFACES=(eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(gateway)
 
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(main)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng network netfs crond hal alsa sensors powernowd)

here is my /etc/resolv.conf while Im using dhcp, so I know I have my entires right.

# Generated by dhcpcd from eth0
# /etc/resolv.conf.head can replace this line
domain myhome.westell.com
nameserver 192.168.1.1
# /etc/resolv.conf.tail can replace this line

heres my custom /etc/resolv.conf before it gets rewritten

domain myhome.westell.com
nameserver 192.168.1.1

here is is after a reboot

# Generated by dhcpcd from eth0
# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line

I would just remove dhcpcd or even just edit my /etc/conf.d/dhcpcd file to stop this from happening but I still need to use dhcp on different wireless networks.  What should I do?

Last edited by tjwoosta (2009-10-20 00:06:16)

Offline

#2 2009-10-20 00:17:08

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

Check out netcfg -- it's very simple and is flexible across multiple networks and static/dynamic ip's.

Scott

Offline

#3 2009-10-20 01:06:58

mawhii
Member
Registered: 2009-07-04
Posts: 18

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

It looks like you can put your custom settings under /etc/resolv.conf.head to override dhcp settings (or resolv.conf.tail if you want dhcp to take precedence).

i've never tried that, so I may just be plain wrong..

edit: i can't spell.

Last edited by mawhii (2009-10-20 01:07:29)

Offline

#4 2009-10-20 02:37:56

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

mawhii wrote:

It looks like you can put your custom settings under /etc/resolv.conf.head to override dhcp settings (or resolv.conf.tail if you want dhcp to take precedence).

i've never tried that, so I may just be plain wrong..

edit: i can't spell.

Ok, now Im confused.  You were right and I just tried putting my settings in /etc/resolv.conf.tail but still no luck.  This time when I rebooted and checked resolv.conf all the setting were correct, it appended my setting to the end of the file and everything looked good, but dns is still not working. I can connect to my routers web interface fine, and I can ssh to other machines on the local network, and I can acess nfs shares, but I can't ping google it just immediatly says unkonwn host. What could I be doing wrong here?


Check out netcfg -- it's very simple and is flexible across multiple networks and static/dynamic ip's.

Scott

This looks great, its just what I need. Im trying it right now to see if it will solve my problem but im not sure now that I fixed resolv.conf and dns is still not working its making me think maybe Im doing something else wrong.  I just dont understand.  Hopefully netcfg works.

Offline

#5 2009-10-20 03:02:08

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

If you use netcfg, you never have to touch resolv.conf. All your settings are in the /etc/network.d/profilename files. For example, my profile for home wireless w/ static ip is:

CONNECTION="wireless"
ESSID="firecat4153"
INTERFACE="wlan0"
DESCRIPTION="Automatically generated profile"
#IWCONFIG="rate 54M mode managed"
SCAN="yes"
IP="static"
IFOPTS="192.168.0.104 netmask 255.255.255.0 broadcast 192.168.0.255"
GATEWAY="192.168.0.1"
DNS1="208.67.222.222"
DNS2="208.67.220.220"
DNS3="192.168.0.1"
TIMEOUT="10"
SECURITY="wpa"
KEY="wirelesskey"

and for a standard wired dhcp connection:

CONNECTION="ethernet"
DESCRIPTION="A very basic ethernet profile, using dhcp"
INTERFACE=eth0
IP="dhcp"
DHCP_TIMEOUT=10

Scott

Offline

#6 2009-10-20 03:21:45

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

firecat53:

DNS1="208.67.222.222"
DNS2="208.67.220.220"
DNS3="192.168.0.1"

Which tool generated this config? DNS3 was never supported, so that one isn't being used at all. While DNS1 and DNS2 still work, the new suggested syntax is simpler.

DNS=("208.67.222.222" "208.67.220.220" "192.168.0.1")

Cheers,
James

Offline

#7 2009-10-20 03:57:25

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

@iphitus -- huh, well I've been using this config for almost a year, and honestly haven't thought about it in a long time smile I couldn't tell you where I got that from....other than prob somewhere here on the forums or the wiki. In any case, I changed it and it works fine. It was working the other way too, for the DNS1 and 2, but now I see that it adds the third DNS stanza to resolv.conf as well.

Thanks!
Scott

Offline

#8 2009-10-20 04:14:02

gog
Member
Registered: 2009-10-13
Posts: 103

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

You don't need to install netcfg for this. dhcpcd has a runtime option for disabling overwriting resolv.conf. See networking wiki.

Offline

#9 2009-10-20 05:10:46

bruce
Member
Registered: 2008-11-27
Posts: 57

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

does your nameserver work when you use nslookup? eg `nslookup google.com 192.168.1.1`?
also, could i suggest adding entries for opendns to your /etc/resolv.conf.tail after your local one?
"
domain myhome.westell.com
nameserver 192.168.1.1
nameserver 208.67.222.222 #opendns
nameserver 208.67.220.220 #opendns
"
works nicely as a backup if your somewhere with a dodgy dns etc

Offline

#10 2009-10-20 14:55:34

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

bruce wrote:

does your nameserver work when you use nslookup? eg `nslookup google.com 192.168.1.1`?
also, could i suggest adding entries for opendns to your /etc/resolv.conf.tail after your local one?
"
domain myhome.westell.com
nameserver 192.168.1.1
nameserver 208.67.222.222 #opendns
nameserver 208.67.220.220 #opendns
"
works nicely as a backup if your somewhere with a dodgy dns etc

Yep, I just tried and it works fine when I use nslookup but web browser and ping still dont work. I can use googles ip 74.125.53.100 and everything works, but not the domain name.  As for opendns Id really just like to get my standard dns to work for now, I know it should work because I use it on all the other computers plus it works with dhcp. After I figure out what Im doing and whats going wrong Im probably going to setup my router to use opendns.

[tj@arch ~]$ nslookup google.com 192.168.1.1
Server:         192.168.1.1
Address:        192.168.1.1#53

Non-authoritative answer:
Name:   google.com
Address: 74.125.53.100
Name:   google.com
Address: 74.125.67.100
Name:   google.com
Address: 74.125.45.100

[tj@arch ~]$

I still havn't got around to seeing if I can get it to work with netcfg, it was late last night and I fell asleep. Ill try it now and post back with the results.

Offline

#11 2009-10-20 15:26:19

tjwoosta
Member
Registered: 2008-12-18
Posts: 453

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

Ok , I just got it working with netcfg

I just used the default ethernet-static example except I changed ADDR to suit my needs

CONNECTION="ethernet-iproute"
DESCRIPTION="A basic static ethernet connection using iproute"
INTERFACE="eth0"
IP="static"
ADDR="192.168.1.51"
GATEWAY="192.168.1.1"
DNS=("192.168.1.1")

Then I just commented out network in the DAEMONS and added net-profile

DAEMONS=(syslog-ng !network net-profiles netfs crond hal alsa sensors powernowd)

Now can anybody help me figure out why it works with netcfg but not with the standard rc.conf network setup ?   Everything is exactly the same, wtf?

Last edited by tjwoosta (2009-10-20 15:28:34)

Offline

#12 2009-10-20 22:21:24

bruce
Member
Registered: 2008-11-27
Posts: 57

Re: trying to setup static ip but /etc/resolv.conf keeps getting rewritten

your gateway in your rc.conf (in your first post) is 192.168.0.1, but in you netcfg one its 192.168.1.1... could it have been that? (ie a typo?)

Offline

Board footer

Powered by FluxBB