23

On Ubuntu, how do I get a list of network connections my computer has made in the last few days? Is there a easy way to do this?

guntbert
  • 12,914
  • 37
  • 45
  • 86
Saqib Ali
  • 825
  • 2
  • 8
  • 16
  • for future cases, you can set up your system as described in [there](http://www.cyberciti.biz/faq/linux-tcpip-connection-monitor-howto/). – sazary Jan 30 '13 at 20:59

2 Answers2

35

You can't get ended connections unless you were logging them. To get the current connections:

# sudo netstat -tupn

This will show the current opened source and destination ports with IPs.

To get more details about the contents of the connections, install tcpdump if it's not installed and run:

# sudo tcpdump -X -i eth0 

And you can run that in the background and write the output to a file.

Islam
  • 590
  • 5
  • 5
1

If you are loooking for a list of ports you can use:

netstat -tupn | grep -E ":(22|80|8000) .*"

or

netstat -tupn | grep -E ":(22|80|8000) .*ESTABLISHED"
Gonzalo
  • 121
  • 4