Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 09-24-2008, 12:15 AM   #1
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Rep: Reputation: 36
Setting a static IP address, but dynamically obtaining DNS config from a router

I am trying to do something similar as indicated at post 1187648, but when I do so, I can no longer resolve hosts. Is there a way to enable some of DHCP where I can have a static IP address, but everything else such as the DNS servers are automatically obtained from the gateway (which is my Linksys router)?

For example, when I had this in my /etc/network/interfaces file:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1

###iface eth1 inet dhcp
iface eth1 inet static
ifconfig shows that eth1's ip address is as it should be, but ping says unknown host. As far as I know, my router usually sets up the DNS servers for when only "iface eth1 inet dhcp" is in the /etc/network/interfaces file. I want Linux to still get DNS set properly from the gateway, but leave the IP address alone. Is there any way to do that?

Old 09-24-2008, 12:20 AM   #2
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
You need to put your nameserver IP(s) in /etc/resolv.conf.
Old 09-24-2008, 12:57 AM   #3
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If you really want a static IP, you may be able to tell the router to assign a certain IP based on the MAC address of your NIC.

ifconfig eth1

will give you the MAC (it calls it the HWaddr)
Old 09-28-2008, 12:33 PM   #4
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
Originally Posted by jay73 View Post
You need to put your nameserver IP(s) in /etc/resolv.conf.
Thanks. That is what I was trying to avoid: I wanted the "system" (Linux plus possibly the router's configuration) to figure out what those name servers are by way of DHCP, but leave the static IP address alone.

But after some tinkering, you are right: In my situation, I want that router to forward certain protocols only, and the only way it can do that without the router changing the target IP address dynamically is if I configure my target machine to not request a possibly varying IP address by way of DHCP.

Originally Posted by billymayday View Post
If you really want a static IP, you may be able to tell the router to assign a certain IP based on the MAC address of your NIC.
That would be ideal, and seemed the least invasive of the approaches. However, I searched twice through all of the configuration menus for my router, and could not find any such method to assign by MAC address. So I'm back to jay73's suggestion of having to manually modify /etc/resolv.conf with the nameservers.

Thanks to the both of you for your help!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Router gateway address being picked up as primary DNS address under SuSe Hubmasterflex Linux - Networking 13 10-18-2008 01:40 PM
Setting a static IP address thedp Slackware 4 05-02-2008 01:09 PM
Obtaining USB handles dynamically Glemu Programming 1 08-16-2005 12:55 PM
Eth0 set up for Static, obtaining DHCP address?! IndustrialGeek Linux - Networking 2 01-03-2005 12:39 AM
dynamically register ip address to windows 2000 dns PantherSE Linux - Networking 0 06-23-2004 12:38 PM

All times are GMT -5. The time now is 11:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration