LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-24-2006, 10:46 PM   #1
Slick666
Member
 
Registered: Feb 2006
Distribution: Ubuntu 8.04; Debian Etch
Posts: 167

Rep: Reputation: 33
Multiple addressing through hosts files


Hello all,

I'm starting this thread because I cannot find a thread on the topic nor answers on the web. What I am trying to do is be able to access a file server both inside and outside my network.
I have a Linux booting Laptop and I would like to use one name to access the same server. When I'm behind my router I can address my server by XXX@XXX.XXX.XXX.XXX and when I'm in front of my router I need to use my dns service name and access the server by XXX@XXX.XXX.org. I was hoping to be able to accomplish this by modifying my hosts file with multiple addresses associated with the same name.
The end result would be to access it by XXX@Server for example to access the server both behind and in front of my router.
Any information would be helpful. Thank you all for your feedback
 
Old 07-25-2006, 06:14 AM   #2
penguintutor
Member
 
Registered: Jun 2006
Location: UK
Distribution: Ubuntu, Mandriva, Redhat and Fedora
Posts: 118

Rep: Reputation: 15
nsswitch.conf should do what you want.

The /etc/nsswitch.conf file determines the search order for DNS.

The line (default, at least on ubuntu)
Code:
hosts:          files dns
says that it will first try looking in your hosts file and only if it isn't found there try a dns lookup.

If you reverse this to give
Code:
hosts:          dns files
Then it says first try dns and if that fails try your hosts file.

So by putting DNS first it will try a DNS lookup, and if that is unsuccessful it will then look at your hosts file.

So you just need the local IP address in your hosts.
 
Old 07-25-2006, 06:59 AM   #3
Slick666
Member
 
Registered: Feb 2006
Distribution: Ubuntu 8.04; Debian Etch
Posts: 167

Original Poster
Rep: Reputation: 33
Well I know my internal IP address and I've declared itstaticso it will not change. But as for my external ipit's dynamic. I use dyndns to locate my external IP and I use port forwarding to forward on the services I want to my server.

I can understand putting myinternal IP address in the hosts file
Server XXX.XXX.XXX.XXX
But I do not understant how the DNS will know where my specific ip address is. Espically if I use a name such as "Server"
 
Old 07-25-2006, 10:10 AM   #4
penguintutor
Member
 
Registered: Jun 2006
Location: UK
Distribution: Ubuntu, Mandriva, Redhat and Fedora
Posts: 118

Rep: Reputation: 15
You would need to have a DNS entry on the dyndns server which matches the one in the hosts file.

You will need to be using a fully qualified domain name, although you can include the domain portion in your search path.

If you had:
server.yourdyndnsdomain.com

and you had
domain yourdyndnsdomain.com
in your /etc/resolv.conf

then if you tried to connect to "server", it would attempt to find
server.yourdyndnsdomain.com (so if dns is available you go to the external interface), but if it can't find that using dns then it will see the server entry in your /etc/hosts file.
 
  


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
lighttpd: multiple virtual hosts? neocookie Linux - Software 8 03-27-2006 11:37 PM
Deploying sudo to multiple hosts rohang Linux - General 1 12-13-2005 11:21 PM
PGP across multiple hosts mr666white Linux - Security 4 08-22-2004 11:14 AM
RH:8 Multiple Hosts Problem ecroswell Linux - Newbie 9 03-17-2003 06:53 AM
multiple virtual hosts iquadri1 Linux - Networking 1 09-25-2001 11:12 AM

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

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration