LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Frequently used Linux Networking Commands (https://www.linuxquestions.org/questions/linux-newbie-8/frequently-used-linux-networking-commands-4175637285/)

gracylayla 08-28-2018 03:45 AM

Frequently used Linux Networking Commands
 
1. netstat:

This command is used to display the contents of the /proc/net files. This command works with the Linux network subsystem and will let you know on the status of the ports if they are open, closed, waiting or masquerade connections. This provides various other information based on using the many options that these commands provide with.

2. tcpdump:

This is a sniffer command, basically a program that targets on capturing the packets of a networking interface and also does the interpretation of these for you. This command understands all the basic internet protocols and it can also be used to save the entire packets for inspection that can be always performed later.

3. ping:
This command derives its name after the sound of an active sonar system and performs a similar activity on a Linux networking system as well. This command is used to send echo requests to a host that we specify in conjunction with this command and further lists the responses that are received from the round trip time.

PING (Packet INternet Groper) command is the best way to test connectivity between two nodes. To stop a ping to a host, we may use the keyboard keys CTRL + C together to break it.

ping 10.76.56.16

Using ping /smbmount/ssh or any other UNIX system programs with a fully qualified domain name (FQDN) instead of an IP address will work out if and only if, these computers are listed in your /etc/hosts file or else it won’t.

4. hostname:
This command lets the system or network administrator know the hostname of the computer that they are logged into. This may sometimes be called as host as well.

5. traceroute:
This command is used to know the route of a packet. This command will list all the series of hosts through which the packets have gone through or traveled through on its way to the specified destination. There are many graphical equivalents to this command/program and one of such commands is xtraceroute.

Traceroute command usage can be as follows:
traceroute machine_name or ip

6. tracepath:
The command tracepath does a similar function to that of traceroute but differs mostly on the fact that the tracepath command doesn’t take complicated options.

tracepath machine_name or ip

7. findsmb:
The findsmb command is used to list down all the information about machines that do respond to the SMB name queries. To take an example, the windows based machines which share their hard disks.

This command will list down all possible machines and to control over the output that you see, you may want to specify a particular subnet to query upon to retrieve machines pertaining to it alone.

8. nmap:
This command is a very sophisticated network tool that is used to query for machines (either local or remote machines) to check whether they are UP and Running, and if so, on what ports are open on these machines. This command/tool can be safely understood as a network exploration tool and also a security scanner.

The command usage is pretty simple, as shown as below:

nmap machine_name

This would query on the machine name that is provided on what ports are kept open. nmap is a wonderful and the most powerful tool for which documentation is available on the nmap site itself.

MensaWater 08-28-2018 02:40 PM

I'd add lsof to that list and generally use it in place of netstat for everything but listing route table.

lsof -i @host : port

Where host is the IP or hostname and port is the port you want to examine for that host. You can do it without the @host if you just want to see what is using the port "lsof -i : port". You can also use lsof to specify the PID in which you're interested to see what connections it has: "lsof -p<PID> -i". Of course you can use "lsof -i" to see all hosts and ports.

lsof is "list open files" and had more uses beyond networking. I find it an invaluable tool for day to day troubleshooting and analysis.

Also tools such as "ifconfig" and "ip" for looking at interfaces configured and other information.

Tools like "ethtool" to look at settings (speed/duplex etc...) on interfaces as well as to change advertised settings for autonegotiation.

scasey 08-28-2018 02:55 PM

Quote:

Originally Posted by gracylayla (Post 5896902)
Using ping /smbmount/ssh or any other UNIX system programs with a fully qualified domain name (FQDN) instead of an IP address will work out if and only if, these computers are listed in your /etc/hosts file or else it won’t.

Nice summary of commands. Only one comment: FQDN's will also work in place of an IP address if the FQDN resolves via DNS. The Domain Name System's purpose is to retrieve the IP address for a domain name.

DennyY 08-29-2018 12:17 PM

Frequently used Linux Networking Commands
 
Thank you for the summary!

May I add ifup and ifdown to enable/disable network interface.

Thanks again,
Denny




Quote:

Originally Posted by gracylayla (Post 5896902)
1. netstat:

This command is used to display the contents of the /proc/net files. This command works with the Linux network subsystem and will let you know on the status of the ports if they are open, closed, waiting or masquerade connections. This provides various other information based on using the many options that these commands provide with.

2. tcpdump:

This is a sniffer command, basically a program that targets on capturing the packets of a networking interface and also does the interpretation of these for you. This command understands all the basic internet protocols and it can also be used to save the entire packets for inspection that can be always performed later.

3. ping:
This command derives its name after the sound of an active sonar system and performs a similar activity on a Linux networking system as well. This command is used to send echo requests to a host that we specify in conjunction with this command and further lists the responses that are received from the round trip time.

PING (Packet INternet Groper) command is the best way to test connectivity between two nodes. To stop a ping to a host, we may use the keyboard keys CTRL + C together to break it.

ping 10.76.56.16

Using ping /smbmount/ssh or any other UNIX system programs with a fully qualified domain name (FQDN) instead of an IP address will work out if and only if, these computers are listed in your /etc/hosts file or else it won’t.

4. hostname:
This command lets the system or network administrator know the hostname of the computer that they are logged into. This may sometimes be called as host as well.

5. traceroute:
This command is used to know the route of a packet. This command will list all the series of hosts through which the packets have gone through or traveled through on its way to the specified destination. There are many graphical equivalents to this command/program and one of such commands is xtraceroute.

Traceroute command usage can be as follows:
traceroute machine_name or ip

6. tracepath:
The command tracepath does a similar function to that of traceroute but differs mostly on the fact that the tracepath command doesn’t take complicated options.

tracepath machine_name or ip

7. findsmb:
The findsmb command is used to list down all the information about machines that do respond to the SMB name queries. To take an example, the windows based machines which share their hard disks.

This command will list down all possible machines and to control over the output that you see, you may want to specify a particular subnet to query upon to retrieve machines pertaining to it alone.

8. nmap:
This command is a very sophisticated network tool that is used to query for machines (either local or remote machines) to check whether they are UP and Running, and if so, on what ports are open on these machines. This command/tool can be safely understood as a network exploration tool and also a security scanner.

The command usage is pretty simple, as shown as below:

nmap machine_name

This would query on the machine name that is provided on what ports are kept open. nmap is a wonderful and the most powerful tool for which documentation is available on the nmap site itself.


dugan 08-29-2018 12:19 PM

ipaddr (to get the IPv4 address) is quite useful too.


All times are GMT -5. The time now is 07:16 AM.