LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 02-14-2013, 09:29 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Rep: Reputation: 45
Some theoretical questions (LAN).


Hi:

A number such as 192.168.1.2 if somehow mapped to a hardware address such as 34:4f:45:9c. It is also mapped to some hostname. Question: how do I know, given the IP, which the hostname is? Or the other way around: given the hostname find the IP?
 
Old 02-14-2013, 09:50 PM   #2
leehanken
LQ Newbie
 
Registered: Jan 2009
Posts: 14
Blog Entries: 1

Rep: Reputation: 7
Quote:
Originally Posted by stf92 View Post
Hi:

A number such as 192.168.1.2 if somehow mapped to a hardware address such as 34:4f:45:9c. It is also mapped to some hostname. Question: how do I know, given the IP, which the hostname is? Or the other way around: given the hostname find the IP?
The hardware address, also known as MAC address has six bytes. (your example only shows 4 bytes) This is not really related to your question.

Mapping between hostname and IP address happens through DNS (Domain Name System), basically a hierarchical table accessed by connecting to remote name servers. Hostnames and their corresponding addresses can also be stored in a local file called 'hosts'. In practice you can type: nslookup hostname.com OR nslookup 100.100.100.100 to try to discover this information.

The 'hosts' method is more likely for local IP addresses like 192.168.1.2, where as the DNS (accessed via a TCP/IP connection on port 53) will more likely for remote IP addresses like 100.100.100.100. Finding IP address from the host/domain name is known as a DNS lookup operation, whereas finding a hostname/domain from IP address is called a reverse DNS lookup.
 
Old 02-14-2013, 10:28 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Original Poster
Rep: Reputation: 45
Thank you very much. I ask because in /etc/rc.d/inet1.conf I put:

IPADDR[0]="192.168.0.2"

However, in /etc/hosts I only have
Code:
# For loopbacking.
127.0.0.1		localhost
127.0.0.1		darkstar.domain_name_2 darkstar

# End of hosts.
Is not 192.168.0.2 a local IP address?
 
Old 02-14-2013, 11:38 PM   #4
leehanken
LQ Newbie
 
Registered: Jan 2009
Posts: 14
Blog Entries: 1

Rep: Reputation: 7
In inet1.conf you are setting a static IP address for your computer.

In hosts you are naming your computer darkstar.

The address 127.0.0.1 is another way of saying 'the address of my computer as seen by itself'.

In fact you could address your computer as 192.168.0.2 or as 127.0.0.1 from itself. However, from another computer on the network, it has to be addressed as 192.168.0.2.

Thanks to hosts, your computer knows its own name. However, none of the other computers on the network will know its name, unless you put a line in their hosts file saying

Code:
192.168.0.2    darkstar
So yes, 192.168.0.2 is a local address in that it is relevant only to the local area network (LAN). It does not apply if you are outside the LAN. So from another person somewhere else on the internet it will not reach your computer.

I am simplifying a bit, for more information you could try http://en.wikipedia.org/wiki/Internet_protocol_address
 
Old 02-15-2013, 12:18 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Original Poster
Rep: Reputation: 45
However I myself, computer 192.168.0.2 can't see the IP<->hostname association from computer 192.168.0.2.
 
Old 02-15-2013, 12:55 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,246

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
1. I don't understand your last comment

2. each entry in /etc/hosts should have a unique ipaddr at the left hand side, and then 1 or more names/aliases on the same line, so combine those 127.0.0.1 records.

3. 127.0.0.1 is how the computer talks to itself. Its the same (internal) address on every computer and usually the basic entry is
Code:
127.0.0.1   localhost localhost.localdomain
4. 192.168.0.2 is the ipaddr of the machine from the external/LAN point of view
If you have an entry for it in the /etc/hosts file, it will recognise itself.
 
Old 02-15-2013, 01:07 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Original Poster
Rep: Reputation: 45
Alright. Now, has it any sense to issue, from machine A,

Code:
  
# ifconfig eth0 192.168.1.1 netmask 255.255.255.0
# route add default gw 192.168.1.1
and then to add this line to /etc/rc.d/rc.local?:

/sbin/ifconfig eth0:0 192.168.0.1 netmask 255.255.255.0
 
Old 02-15-2013, 02:44 PM   #8
leehanken
LQ Newbie
 
Registered: Jan 2009
Posts: 14
Blog Entries: 1

Rep: Reputation: 7
Hi stf92

This first line sets the computer's address to be 192.168.1.1:

Code:
# ifconfig eth0 192.168.1.1 netmask 255.255.255.0
The next line sets which computer/router will be contacted first for communicating to other computers:

Code:
# route add default gw 192.168.1.1
It does not make sense for the two addresses to be the same, because the computer will only be able to talk to itself.

Putting the following line in rc.local will set the IP address to 192.168.0.1 when the computer is booted:

Code:
/sbin/ifconfig eth0:0 192.168.0.1 netmask 255.255.255.0
Typically this is not needed because it is usually handled by rc.inet1

Regards Lee
 
Old 02-15-2013, 02:59 PM   #9
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,054

Rep: Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101Reputation: 1101
I think /etc/hosts is only for name to IP associations that you don't want to look up in the next higher level of DNS.

I assume you have some kind of home router which is acting as a DHCP server (associating those 192.168.???.??? addresses to Mac addresses) and a DNS server (keeping track of local machine names and caching results from a distant DNS server for names on the rest of the net) and doing address translation (between the real IP address assigned by your internet provider to your home network and all the 192.168 addresses that same router invents for that network).

Linux can do and/or override any of the above tasks. But you probably don't want it to. You probably want Linux to look to the home router for all of that.

Last edited by johnsfine; 02-15-2013 at 03:01 PM.
 
Old 02-15-2013, 04:03 PM   #10
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Original Poster
Rep: Reputation: 45
Thanks. Definitely what I now have is a modem provided by my ISP (DHCP), a router with a WAN port and several LAN ports and computers A and B. And all I want to do is to interconnect A, B and the router (router goes to the WAN of course). That is, what everybody has at home: two computers connected to Internet (only one IP) and with each other. I know the job is very easy but not how to do it, though I have learned some of the jargon (reading The Linux Network Administrator's Guide from TLDP). If I boot in Windows at least I'll be able to see it works, but the ideal would be to make it work with Linux.
 
Old 02-15-2013, 08:54 PM   #11
jefro
Guru
 
Registered: Mar 2008
Posts: 11,128

Rep: Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362Reputation: 1362
The name localhost is a very old way and is still used.
 
Old 02-15-2013, 09:04 PM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,071

Original Poster
Rep: Reputation: 45
Quote:
Originally Posted by jefro View Post
The name localhost is a very old way and is still used.
You mean 'rlogin darkstart@127.0.0.1? But I would be loging into myself?
 
  


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
[SOLVED] I have a partially theoretical question. abcde597 Programming 7 11-06-2012 04:13 PM
Theoretical reduction of O(n^3) to O(n) in certain cases Travis86 Programming 2 06-23-2010 05:30 PM
Theoretical Future?? nathanhillinbl Linux - Security 5 05-04-2007 01:43 AM
Theoretical considerations about switching between OS's holrin Linux - Laptop and Netbook 2 10-06-2006 06:49 PM
Theoretical Question jgr220 Linux - Security 3 03-29-2003 05:40 AM


All times are GMT -5. The time now is 09:58 AM.

Main Menu
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