When working with network applications, it comes in handy to be able to see open ports and connections and to be able to interact with ports on different hosts for testing purposes. In this section, we will be looking at some basic commands for networking and in what situations they might come in handy.
The first command is netstat
:
netstat -plnt
This will show all open ports on our host. You can see here that we only have one open port on a default Ubuntu desktop installation, which is port 53
. We can look this up in the special file /etc/services
. This file contains all basic port numbers for programs and protocols. We see here port 53
is the DNS server:
Just by analyzing the output, we cannot determine which program is listening on this port, because this process is not owned by our current user. That's why the PID/Program Name column is empty. If we run the same command again with sudo
, we see that this process is named dnsmasq
and, if we want more information...