LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-15-2007, 10:10 PM   #1
stormrider_may
Member
 
Registered: Sep 2005
Distribution: Debian
Posts: 304

Rep: Reputation: 30
Forcing DNS to resolve to an IP


Hello,

I have a Debian system where i must dynamic change the DNS resolution of a domain.

I have done a little script that changes file /etc/hosts ( so the domain ip changes too ) but i have seen that this change take a while to become available.

How can i force the reload of /etc/hosts?

Is there any other solution to this problem?

Quick explain: on a first moment, the system must "talk" with the dns server ( in my case 192.168.0.1 ) to find out the domains ip. On other moment, the system must resolve the domain to a specified IP, without asking the dns server.

Thanks.
 
Old 07-15-2007, 10:45 PM   #2
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
I'm not sure how to flush DNS in linux, but I think if you restart your network service it will flush out the dns. So in your script, just add something like:

/etc/init.d/networking restart

Of course this will cause you to lose network connection for a second or two.

Do you have a DNS server? IN general, a DNS server can update its record, especially if you have DHCP installed on your network.
 
Old 07-16-2007, 06:28 AM   #3
stormrider_may
Member
 
Registered: Sep 2005
Distribution: Debian
Posts: 304

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Micro420
Do you have a DNS server? IN general, a DNS server can update its record, especially if you have DHCP installed on your network.
Yes, i have a DNS server on my network. But your tip worked ( at least on shell ).

The problem now is on firefox, since it access the old DNS even after clearing cache and reloading the page. Do you any ideas of how can i force firefox to read /etc/hosts again?

Thanks for you help.
 
  


Reply



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
dns client cannot resolve on dns server jtvillegas Linux - Software 3 03-12-2016 03:30 PM
Can't Resolve DNS IP shipon_97 Linux - Networking 1 08-25-2006 10:51 PM
DNS can't resolve gmail.com but can resolve everything else? TongueTied Linux - Networking 2 01-24-2006 03:39 AM
DNS Resolve? b0rgri0t Slackware 1 01-04-2006 02:00 PM
slow DNS resolve phkhoury Slackware 3 12-21-2003 12:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration