LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 04-25-2009, 07:31 PM   #1
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Rep: Reputation: 15
Can anyone tell me the logic of hosts and resolv.conf?


Hi,

Let's say my 10.0.0.4 has ftp server, and it's domain name is ftp.com, and ftp.com is already mapped on it's external ip:75.0.0.1

assume ftp.com from any browser reaches to 75.0.0.1

so how this 10.0.0.4 takes this address and knows that 75.0.0.1 is actually 10.0.0.4 ??

i played with resolv.conf with no luck.

any help will be appreciated, with a little explanation as to why.


Thank you,
 
Old 04-25-2009, 07:39 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
Various services listen to incoming ports. Traditionally there is a gateway computer with the external WAN IP (e.g. a "router") which forwards TCP/IP packets to a host in the subnet based on the nature of the request. For example, An HTTP GET to port 80 goes to a predefined IP (on which the web server listens) in the local network by virtue of being on port 80.

I believe what you are asking about actually has nothing to do with the files you've brought up.

/etc/hosts is not that important if you have a properly configured DHCP server on the network. It's sort of a legacy file at this point, imho. (Disagreements?)

/etc/resolv.conf specified places to resolve hostnames into ip's, i.e. "oh, hostname is actually hostname.domainname.com". Or, "I'll ask the dns server at 33.44.55.66".
 
Old 04-25-2009, 07:48 PM   #3
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
This is something that would tend to be done in a gateway router / firewall device, rather than on the local machine.
  • 10.0.0.4 is a private IP address. No address beginning with a 10 is a valid internet address.
  • 75.0.0.1 is a valid internet address. This is the address that would be advertised for ftp.com by a DNS server.
  • The firewall/router would have at least two network interfaces. One would have the address 75.0.0.1, and the other would have an address in the 10.0.0.0 range.
  • It would use network address translation to translate between the two ip address ranges, and port forwarding to direct all incoming traffic on ports 20 and 21 (i.e. FTP) to the server with IP address 10.0.0.4 on the internal network.
  • There are two main advantages of this. The first is that it allows many machines on a private network to share one, or a few, external IP addresses (thus helping stave off the IP-address famine). The other is that those on the outside never see the real IP addresses of machines on the internal network, providing some security benefits.
  • The main function of resolv.conf is to provide the addresses of DNS servers to applications on a machine, while the hosts file allow names to be locally associated with IP addresses on that machine.
Hope this is reasonably clear .

Rob
 
Old 04-25-2009, 07:57 PM   #4
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks James, Rob,

So how exactly I can make 10.0.0.4 (internal) machine be aware of 75.0.0.1 (external)?

At the moment http://ftp.com is responding with a web page, I am assuming this is because Apache is listening to the port 80.

but if i ping 75.0.0.1 from another machine, or try to access ftp server (which is working locally) from outside, (firewall is set correctly), it doesn't respond.

I guess, 10.0.0.4 doesn't have any idea what to do when it receives 75.0.0.1 yet.

What files do i change? So that each and every port on the local machine is responding to external requests?

domain name : ftp.com
ext ip : 75.0.0.1
int ip : 10.0.0.4

Thanks,
 
Old 04-25-2009, 08:11 PM   #5
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
Quote:
Originally Posted by demia View Post
At the moment http://ftp.com is responding with a web page, I am assuming this is because Apache is listening to the port 80.
Yes- and because you're giving the protocol as "http" (which implies port 80). If you used a dedicated FTP client (or entered the URL as ftp://ftp.com in many browsers), it would attempt a connection on port 20/1.

Quote:
but if i ping 75.0.0.1 from another machine...
Pinging the external address shows little or nothing - only that ICMP echo-request packets are being dropped (most firewalls do this).

Quote:
...or try to access ftp server (which is working locally) from outside, (firewall is set correctly), it doesn't respond. I guess, 10.0.0.4 doesn't have any idea what to do when it receives 75.0.0.1 yet.
If you can make a connection using FTP from the internal network, at least the FTP server is running on the machine. 10.0.0.4 will never see anything with the address "75.0.0.1" on it. It is whichever device is doing the routing between the internet and your internal network that needs to know to route all traffic on port 20/1 to 10.0.0.4. How is your network connected up? What sort of device is sitting between you and the internet?

Rob

Last edited by Robhogg; 04-25-2009 at 08:12 PM.
 
Old 04-25-2009, 08:33 PM   #6
demia
LQ Newbie
 
Registered: Apr 2009
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks for pointing out that I was looking at the wrong direction. It was my proftpd server that was not responding, and i checked that there is a parameter you can set:
AllowForeignAddress on

and this was the problem. But it was nice to know about the things you mentioned.

Cheers,
 
  


Reply

Tags
hosts, nameserver, resolvconf


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
about resolv.conf kpachopoulos Linux - Newbie 2 03-03-2008 03:26 PM
hosts and resolv.conf files 60s TV Batman Linux - Networking 9 03-23-2007 01:09 AM
DNS Hosts.conf or resolv.conf problem mac_casey Suse/Novell 0 03-26-2006 10:21 AM
/etc/hosts, /etc/resolve.conf and /etc/host.conf config probs below_average Linux - Networking 1 12-08-2004 11:07 PM
/etc/resolv.conf Pedroski Linux - Networking 1 06-22-2004 11:03 AM


All times are GMT -5. The time now is 02:45 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration