26

I'd like to know all the connections my system is making to the internet. I tried netstat but that shows a lot of connections - all of which aren't applicable I think. Can it be displayed like top does for processes ?

I'm a little security conscious and would like to know all the incoming and outgoing connections happening on my system.

1
  • Usually all you need is sudo ss -tulpn. For Apache, you might want to configure mod_status Feb 19 at 21:36

2 Answers 2

41

Using netstat

Warning: Netstat is considered deprecated.

netstat by itself monitors all major protocols including TCP and UDP on every port.

If you want to display TCP and UDP connections:

netstat -t -u 

If you want to display that continuously:

netstat -t -u -c 

Similar to top

  1. nethogs - shows a list of the top processes that use bandwidth

  2. jnettop - shows list of top connections

  3. iftop - shows list of top connections with bandwidth bars

GUI Interface (just in case):

  1. Ntop

  2. Netactview

1
  • 1
    typo: nethlogs -> nethogs, jnettot->jnettop
    – James Yang
    Mar 12, 2017 at 4:07
2

Using ss

You may try ss as well, it's more advanced than netstat.

  • ss --tcp -all

    List all TCP connections (including those with non-established state, e.g. SYN-SENT, LISTEN, and TIME-WAIT). Read more about TCP states transition in RFC793.

    State                    Recv-Q               Send-Q                             Local Address:Port                                 Peer Address:Port     
    LISTEN                   0                    4096                                   127.0.0.1:5672                                      0.0.0.0:*    
    ESTAB                    0                    0                                    192.168.1.4:57310                               35.157.63.229:443  
    ESTAB                    0                    0                                      127.0.0.1:43764                                   127.0.0.1:8080 
    CLOSE-WAIT               1                    0                                    192.168.1.4:34554                              142.250.186.33:443  
    CLOSE-WAIT               1                    0                                    192.168.1.4:34564                              142.250.186.33:443  
    
  • ss --tcp --all --processes

    Include information about the owner process of the connections (e.g., process name and PID)

  • ss state established '( dport = :ssh or sport = :ssh )'

    Display all established SSH connections.

  • ss --options state fin-wait-1 '( sport = :https )' dst 193.233.7/24

    List all the TCP sockets in state FIN-WAIT-1 for network 193.233.7/24 and look at their timers with --options, which shows timer information.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .