LinuxQuestions.org
Visit Jeremy's Blog.
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 12-02-2003, 01:03 PM   #1
mikeyt_333
Member
 
Registered: Jun 2001
Location: Up in the clouds
Distribution: Fedora et al.
Posts: 353

Rep: Reputation: 30
127.0.0.1 Entry in Zone file and /etc/hosts, will this cause probs?


I have a domain, I'll call it X in the post, that I am using htdig on to spider through the site and compile a search db. The problem is, htdig access the system through eth0, and I am trying to prevent this, I want it to connect locally but use the same FQDN. So I thought I could add an A entry in X's zone file refering it to 127.0.0.1, as well as add an entry to /etc/hosts which connects 127.0.0.1 to X, so here's what I have in both those files:

/var/named/X.hosts:

X. IN A yy.yy.yy.yy
X. IN A 127.0.0.1

/etc/hosts:

127.0.0.1 localhost
127.0.0.1 X
yy.yy.yy.yy ns1.X
yy.yy.yy.yy X

(Where yy.yy.yy.yy is the public IP.)

My hypothesis behind this is that htdig will now resolv X to 127.0.0.1, and not have to connect through the eth0 connection, just the lo device. Is this correct? Would this screw anything up as far as addressing goes, or resolving? Is there an easier way to do this? Thanks in advance!

Mike.
 
Old 12-02-2003, 01:51 PM   #2
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
It will only work half the time because the BIND resolver will do round-robin.
 
Old 12-02-2003, 02:06 PM   #3
mikeyt_333
Member
 
Registered: Jun 2001
Location: Up in the clouds
Distribution: Fedora et al.
Posts: 353

Original Poster
Rep: Reputation: 30
how can I make this occur permanently? Would Iptables be the best bet?
 
Old 12-02-2003, 02:25 PM   #4
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
You can try putting your new entry at the top of the /etc/hosts file (just 127... X) and /etc/hosts might take the first match (test it to make sure). I'm pretty certain that hosts resolution will just take first match and won't look for others. BIND will do round-robin no matter what, though so you might as well yank that stuff out of your zone file. Besides, if you're making that zone available to Internet client then you're going to cause them grief (half the time your site will resolve to the IP of the loopback adaptor so instead of your site, they'll get nothing).

You can also read up on BIND "views" to implemention split-horizon DNS. What that would do is give one IP to the outside world, but a different IP to a small set of hosts or networks that you define.
 
Old 12-02-2003, 02:30 PM   #5
mikeyt_333
Member
 
Registered: Jun 2001
Location: Up in the clouds
Distribution: Fedora et al.
Posts: 353

Original Poster
Rep: Reputation: 30
I think the best way to handle it will be iptables, what I did was added this nat rule:

iptables -t nat -A OUTPUT -d X -j DNAT --to-destination 127.0.0.1

that way it won't matter what the system resolves the DN as, when it tries to access the public IP it will be routed to lo. What do you think?
 
Old 12-02-2003, 02:33 PM   #6
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
You'll break any service that you need to access on your machine that isn't also running on loopback.
 
Old 12-02-2003, 02:40 PM   #7
mikeyt_333
Member
 
Registered: Jun 2001
Location: Up in the clouds
Distribution: Fedora et al.
Posts: 353

Original Poster
Rep: Reputation: 30
Well, it looks like this kind of thing happens naturally anyways, I setup a logging on the packets accessing that interface from internally, and nothing is logged, so my guess is that it is translated automatically.
 
Old 12-02-2003, 02:51 PM   #8
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
If you define it that way in /etc/hosts, then yes.
 
  


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
hosts file IP 127.0.0.2 Steve Riley SUSE / openSUSE 4 02-14-2012 11:34 AM
HOST name in HOSTS file (127.0.0.1) fipeso Linux - Networking 1 05-05-2005 06:22 AM
/etc/hosts entry? batard Linux - Newbie 5 03-25-2005 01:22 PM
hosts MX entry twistedpair Linux - Networking 1 01-10-2004 03:01 AM
hosts entry for a lan unit with no dns entry linxtc Linux - Networking 1 10-03-2003 08:05 AM

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

All times are GMT -5. The time now is 07:54 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