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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-24-2008, 12:15 AM
|
#1
|
Member
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[567] x86_64, Ubuntu 17.10 x86_64
Posts: 221
Rep:
|
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
|
|
|
09-24-2008, 12:20 AM
|
#2
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
|
You need to put your nameserver IP(s) in /etc/resolv.conf.
|
|
|
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:
|
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)
|
|
|
09-28-2008, 12:33 PM
|
#4
|
Member
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[567] x86_64, Ubuntu 17.10 x86_64
Posts: 221
Original Poster
Rep:
|
Quote:
Originally Posted by jay73
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
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
|
|
|
All times are GMT -5. The time now is 07:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|