Monday 19 January 2009

Tip of the Day: Easily Close a Port in Linux

You can easily see what are the ports in use with the command:

nmap localhost

Or:

nmap <YOUR_IP>

The output can be something like:

$ nmap localhost

Starting Nmap 4.62 ( http://nmap.org ) at 2009-01-19 23:45 EET
Interesting ports on localhost (127.0.0.1):
Not shown: 1711 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
111/tcp open rpcbind
113/tcp open auth

Nmap done: 1 IP address (1 host up) scanned in 0.066 seconds

To close a port, you can use the following command as root:

fuser -k 80/tcp

Which will close port 80 (used by the web server).

No comments: