GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.