-   General (
-   -   Some theoretical questions (LAN). (

stf92 02-14-2013 09:29 PM

Some theoretical questions (LAN).

A number such as 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?

leehanken 02-14-2013 09:50 PM


Originally Posted by stf92 (Post 4891945)


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 OR nslookup to try to discover this information.

The 'hosts' method is more likely for local IP addresses like, where as the DNS (accessed via a TCP/IP connection on port 53) will more likely for remote IP addresses like 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.

stf92 02-14-2013 10:28 PM

Thank you very much. I ask because in /etc/rc.d/inet1.conf I put:


However, in /etc/hosts I only have

# For loopbacking.                localhost                darkstar.domain_name_2 darkstar

# End of hosts.

Is not a local IP address?

leehanken 02-14-2013 11:38 PM

In inet1.conf you are setting a static IP address for your computer.

In hosts you are naming your computer darkstar.

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

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

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:    darkstar
So yes, 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

stf92 02-15-2013 12:18 AM

However I myself, computer can't see the IP<->hostname association from computer

chrism01 02-15-2013 12:55 AM

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 records.

3. is how the computer talks to itself. Its the same (internal) address on every computer and usually the basic entry is
Code:  localhost localhost.localdomain
4. 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.

stf92 02-15-2013 01:07 AM

Alright. Now, has it any sense to issue, from machine A,


# ifconfig eth0 netmask
# route add default gw

and then to add this line to /etc/rc.d/rc.local?:

/sbin/ifconfig eth0:0 netmask

leehanken 02-15-2013 02:44 PM

Hi stf92

This first line sets the computer's address to be


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


# route add default gw
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 when the computer is booted:


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

Regards Lee

johnsfine 02-15-2013 02:59 PM

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.

stf92 02-15-2013 04:03 PM

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.

jefro 02-15-2013 08:54 PM

The name localhost is a very old way and is still used.

stf92 02-15-2013 09:04 PM


Originally Posted by jefro (Post 4892701)

You mean 'rlogin darkstart@ But I would be loging into myself?
