Open Network Ports
It is important to know which ports are open on your computer. Ubuntu has a few tools to check this.
nmap
$ sudo nmap -T Aggressive 127.0.0.1 -p 1-65535
That will provide output similar to this:
Starting Nmap 4.53 ( http://insecure.org ) at 2008-12-08 12:57 EST
Interesting ports on localhost (127.0.0.1):
Not shown: 64995 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
Nmap done: 1 IP address (1 host up) scanned in 2.674 seconds
netstat
$ sudo netstat -ln --ip
The output could be something like this:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:47724 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
udp 0 0 0.0.0.0:48790 0.0.0.0:*
udp 0 0 0.0.0.0:46247 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
udp 0 0 0.0.0.0:111 0.0.0.0:*
raw 0 0 0.0.0.0:1 0.0.0.0:* 7
lsof
$ sudo lsof +M -i4
You will get an output like this:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
portmap 4897 daemon 3u IPv4 13280 UDP *:111[portmapper]
portmap 4897 daemon 4u IPv4 13285 TCP *:111[portmapper] (LISTEN)
avahi-dae 5619 avahi 14u IPv4 14176 UDP *:5353
avahi-dae 5619 avahi 15u IPv4 14177 UDP *:48790
master 6400 root 11u IPv4 14925 TCP *:25 (LISTEN)
dhclient 6690 dhcp 6u IPv4 15927 UDP *:68
rpc.statd 9913 statd 6u IPv4 42812 UDP *:761
rpc.statd 9913 statd 8u IPv4 42819 UDP *:46247[status]
rpc.statd 9913 statd 9u IPv4 42822 TCP *:47724[status] (LISTEN)
cupsd 10062 root 2u IPv4 43034 TCP 127.0.0.1:631 (LISTEN)
fuser
Fuser, does help, but is not like the previous tools. With fuser you can also kill the process which is listening on a given port.
$ sudo fuser -v 3143/tcp
The output is:
USER PID ACCESS COMMAND
3143/tcp: www-data 2763 F.... apt-cacher
If you need to kill the process enter
$sudo fuser -vk 3143/tcp
Linux is incredible for designers, but is too hard to use for a common person, anyway once you learn how to use it you fall in love with linux immediately
ReplyDelete