Difference between revisions of "Network Tools in Linux"
(→x) |
(→DNS Lookup) |
||
Line 24: | Line 24: | ||
192.168.19.101 handy lg200 |
192.168.19.101 handy lg200 |
||
192.168.19.1 netgear |
192.168.19.1 netgear |
||
− | |||
</pre> |
</pre> |
||
+ | |||
+ | In this example we have defined 3 names in the 192.168.19.0/24 network. You can add alias names after the first name. It is also good to have the name of your own computer defined. Also the loopback interface should be named <q>localhost</q>. In the above example we also name the IPv6 address (::1) to be localhost. |
Revision as of 08:10, 27 March 2020
Motivation
We have learned the basics of how a network works. Now lets look at more tools that help you debug and troubleshoot network issues.
DNS Lookup
When you go to a website you do not need to remember the IP address. You use a name for that. e.g. you go to www.google.com. In order to find the associated IP address you need to lookup that name. The tools for that are: host nslookup or dig. For simple lookups I prefer host, while the other tools will give you more detailed information of how the lookup worked.
host www.google.com www.google.com has address 172.217.16.196 www.google.com has IPv6 address 2a00:1450:4001:817::2004
Sometimes you want to define aliases for certain hosts. Especially in your private network at home you will not want to run your own DNS system. A simple file that relates IP addresses to names will be sufficient to make your life easiser. This is the /etc/hosts file where you can add names to your IP addresses. E.g. your hosts file could look like this:
$ cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback 192.168.19.27 laptop1 acer 192.168.19.101 handy lg200 192.168.19.1 netgear
In this example we have defined 3 names in the 192.168.19.0/24 network. You can add alias names after the first name. It is also good to have the name of your own computer defined. Also the loopback interface should be named localhost
. In the above example we also name the IPv6 address (::1) to be localhost.