LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
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?

Notices

Reply
 
Search this Thread
Old 09-24-2008, 12:15 AM   #1
bgoodr
Member
 
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:

Code:
# 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
  address 192.168.1.2
  netmask 255.255.255.0
  gateway 192.168.1.1
ifconfig shows that eth1's ip address is 192.168.1.2 as it should be, but ping www.google.com 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?

Thanks,
bgoodr
 
Old 09-24-2008, 12:20 AM   #2
jay73
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
billymayday
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
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
Quote:
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.

Quote:
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!

bgoodr
 
  


Reply


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 09:46 AM.

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