10 useful DNS settings and network management commands in Linux
You can easily manage the commands used for network and DNS settings from the command screen. In this article you will find information about the most used basic network management commands in Linux and how to edit DNS settings.
1. Network connection and IP configuration: ifconfig
The ifconfig command allows you to check and change the network connections and IP configuration settings available in the system.
ifconfig
First, you see the eth0 information. eth0 is the section that displays information about your Ethernet card. If other Ethernet cards are connected to the system, they will be named eth1 and eth2.
lo represents the computer itself, i.e. localhost.
If you are using a wireless network environment, you can also view wlan0. wlan0 means wireless network card.
Instead of using the ifconfig command in this way, you can list each desired information. For example, if you just want to list Ethernet card information, the command ifconfig eth0 should suffice.
ifconfig eth0 eth0: flags=4163mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe00::000:00xx:xx00:0x00 prefixlen 64 scopeid 0x20 ether 08:00:00:0:0x:00 txqueuelen 1000 (Ethernet) RX packets 11 bytes 3310 (3.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 25 bytes 3050 (2.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
For example, you saw above that eth0's local IP address is 10.0.2.15. To change this IP address to 10.0.2.13, enter the following command:
sudo ifconfig eth0 10.0.2.13
With ifconfig, you can change the information here, as well as adjust the info tags you encounter in the output. The ifconfig card_name down command can remove the desired tag from the display, you can redisplay it with the ifconfig card_name up command.
sudo ifconfig lo download
As can be seen from the output, the down parameter makes the lo tag now invisible.
sudo ifconfig lo up
2. One kind of control mechanism: ping
The ping command checks if communication is established between the target and your system. For example, you can query the speed of communication between you and Google.
ping google.com
While doing this, the author ended the process with Ctrl + C after the 5th query packet. If you use a command like ping -c 4 google.com, you're only sending 4 packets. question. The process will end after the number of query packets is exhausted.
ping -c 4 google.com PING google.com (216.58.206.174) 56(84) bytes of data. 64 bytes from sof02s27-in-f14.1e100.net (216.58.206.174): icmp_seq=1 ttl=111 time=79.0 ms 64 bytes from sof02s27-in-f14.1e100.net (216.58.206.174): icmp_seq=2 ttl =111 time=73.5 ms 64 bytes from sof02s27-in-f14.1e100.net (216.58.206.174): icmp_seq=3 ttl=111 time=72.7 ms 64 bytes from sof02s27-in-f14.1e100.net (216.58.206.174 ): icmp_seq=4 ttl=111 time=75.1 ms --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3014ms rtt min/avg/max/mdev = 72.710/75.089/ 79.030/2.432 ms
3. IP routing table: route
The route command allows you to view the contents of the IP routing table on the system. You can type route -n in the console to do this.
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.2.1 0.0.0.0 UG 100 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
The gateway address here is the forwarding address used when transmitting from the local network to the Internet.
4. Forward tracking for a specific target: traceroute
The traceroute command tells you which host the packet sent to a particular destination went through. This time, let's take the destination address www.makeuseof.com as an example.
traceroute www.makeuseof.com traceroute to www.makeuseof.com (54.157.137.27), 30 hops max, 60 byte packets 1 10.0.2.1 (10.0.2.1) 0.430 ms 0.326 ms 0.414 ms 2 * * * 3 * * * 4 * * * 5 * * * 6 * * * 7 * * * 8 * * * 9 * * * 10 * * * 11 * * *
As you can see, to be able to be directed to the desired address, a request is first sent to the address 10.0.2.1. You can use the traceroute command to view such routing paths and find out any routing problems occurring in the network.
5. Domain information: whois
The whois query contains information such as when the domain was created, how long the domain is, etc. Let's take google.com as an example of a whois query.
whois google.com Domain Name: GOOGLE.COM Registry Domain ID: 2138514_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.markmonitor.com Registrar URL: http://www.markmonitor.com Updated Date: 2019-09-09T15:39:04Z Creation Date: 1997-09-15T04:00:00Z Registry Expiry Date: 2028-09-14T04:00:00Z Registrar: MarkMonitor Inc. Registrar IANA ID: 292 Registrar Abuse Contact Email: [email protected] Registrar Abuse Contact Phone: +1.2083895740 Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited Domain Status: clientTransferProhibited https://icann.org/epp# clientTransferProhibited Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited Domain Status: serverTransferProhibited https://icann.
Plus, you can avoid having to use the command screen by using the best sites to look up free whois information.
6. Get information about target address: host
The host command allows you to get information about the destination address. With the host command, you can access the domain name from the IP address and the IP address from the domain name.
7. View DNS records: dig
The dig (domain information groper) command is a common Linux network command used to look up DNS records.
dig google.com ; <<>> DiG 9.17.21-1-Debian <<>> google.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<
Alternatively, you can check NS (Nameserver) records with the dig command. You can use the -t NS command for this.
dig google.com -t NS ; <<>> DiG 9.17.21-1-Debian <<>> google.com -t NS ;; global options: +cmd ;; Got answer: ;; ->>HEADER<
8. IP-MAC address match: arp
The arp command displays the tables that store the IP-MAC address mappings.
arp Address HWtype HWaddress Flags Mask Iface 10.0.2.1 ether 52:54:00:12:35:00 C eth0 10.0.2.3 ether 08:00:27:66:24:25 C eth0
9. Connections made by the system: tcpdump
The tcpdump command allows you to instantly see the connections made by the system and the connections made to the system.
# tcpdump tcpdump: verbose output suppressed, use -v[v]. for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 19:44:59.746452 IP 10.0.2.15.48657 > homerouter .cpe.domain: 14329+ A? www.makeuseof.com. (37) 19:44:59.746574 IP 10.0.2.15.48657 > homerouter.cpe.domain: 39924+ AAAA? www.makeuseof.com. (37) 19:44:59.770573 IP 10.0.2.15.44391 > homerouter.cpe.domain: 44735+ A? content-signature-2.cdn.mozilla.net. (53) 19:44:59.770685 IP 10.0.2.15.44391 > homerouter.cpe.domain: 31664+ AAAA? content-signature-2.cdn.mozilla.net. (53)
Alternatively, if you want to follow the links directly without address resolution, you can use the tcpdump -n command.
# tcpdump -n tcpdump: verbose output suppressed, use -v[v]. for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 19:47:41.327149 IP 10.0.2.15.43892 > 192.168.1.1.53: 44991+ A? content-signature-2.cdn.mozilla.net. (53) 19:47:41.327574 IP 10.0.2.15.43892 > 192.168.1.1.53: 46778+ AAAA? content-signature-2.cdn.mozilla.net. (53) 19:47:41.425041 IP 192.168.1.1.53 > 10.0.2.15.43892: 44991 5/0/0 CNAME d2nxq2uap88usk.cloudfront.net., A 18.66.248.5, A 18.66.248.48, A 18.66.248.112, A 18.66.248.105 (157) 19:47:41.425042 IP 192.168.1.1.53 > 10.0.2.15.43892: 46778 9/0/0 CNAME d2nxq2uap88usk.cloudfront.net., AAAA 2600:9000:224a:e400:a: da5e:7900:93a1, AAAA 2600:9000:224a:1c00:a:da5e:7900:93a1, AAAA 2600:9000:224a:9400:a:da5e:7900:93a1, AAAA 2600:9000:224a:8200:a :da5e:7900:93a1, AAAA 2600:9000:224a: c00:a:da5e:7900:93a1, AAAA 2600:9000:224a:8e00:a:da5e:7900:93a1, AAAA 2600:9000:224a:9a00:a:da5e:7900:93a1, AAAA 2600:9000:224a :a400:a:da5e:7900:93a1 (317) 19:47:42.470901 IP 10.0.2.15.44369 > 192.168.1.1.53: 28874+ A? safebrowsing.googleapis.com. (45)
10. DNS Settings
Compared to other operating systems, setting up DNS on Linux is quite easy. To do this, you can make some changes to the etc/resolutionv.conf file where DNS information is stored.
# cat etc/resolv.conf # Generated by NetworkManager nameserver 192.168.1.1
If you want to add a new DNS here, you can use the echo command.
# echo nameserver 8.8.8.8 > etc/resolv.conf # echo nameserver 8.8.4.4 >> etc/resolv.conf
After making these additions, when you review the etc/resolutionv.conf file, you will see that the desired changes have been made.
# cat etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4
Inside the /etc/ directory, there is another file called hosts that acts as a domain nameserver. This file is checked when performing domain name resolution in the system.
# cat etc/hosts 127.0.0.1 localhost 127.0.1.1 kali # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters
Linux is one of the most widely used operating systems. Knowing the exact commands used in Linux will be very beneficial in saving time and effort. When configuring the Linux network and looking for any possible problems in the network, you can use the Linux network commands mentioned above.
You should read it
- How to use the which command in Linux
- 20+ essential Linux security commands
- How to use the stat command on Linux
- 14 interesting Linux commands in Terminal
- Basic Linux commands everyone needs to know
- The Cat command in Linux
- How to use the last command in Linux
- How to use ss command on Linux
- 11 uses of ps command in Linux
- Instructions for using zforce command on Linux
- How to limit access to su command in Linux
- 12 things Linux is easier to do in the command line than graphical software
Maybe you are interested
What is a matrix in MATLAB? Commands and usage
How to use the file search command on Windows, find saved files
Why is tldr command better than man command in Linux?
Should I use PowerShell or Command Prompt?
What to do when open command window here does not appear?
How to switch users on the Linux command line