Networking

Networking

February 25, 2020
Software
Tech, Networking, Troubleshooting

Debugging #

Monitor Sockets #

ss

  • Get all outbound TCP connections to a HOST:PORT combination ss -it | grep SOME_PORT_NUMBER

Monitor TCP Connections #

netstat

  • Get all TCP connections on a host netstat -t

    • Observe the Send-Q and Recv-Q to see how many bytes are waiting to be read/written
    • -o adds timer info and connection state
  • Get Summary, good starting point to see if there are dropped packets netstat -s

Monitor TCP Packets #

tcpdump

  • Monitor all packets on eth0 in verbose mode tcpdump -vvi eth0

Benchmarking HTTP requests #

httpstat

NAT Box #

netstat-nat

Port Forwarding #

Local Port Forward Access a port on a remote server accessible via a gateway

ssh -f userName@gateway -L localMachinePort:remoteHost:remoteMachinePort -N

  • gateway is the middle server accessible from the host
  • remoteHost is the server accessible through gateway
  • localMachinePort is the port on your local machine from where the command is run
  • remoteMachinePort is the port on the remoteHost to connect to

References #

TCP Keepalive #

  • Purpose of keepalive is;
    • detect a peer who has disappeared abruptly
    • prevent intermediate components from getting rid of a connection (eg. NAT idle timeout )