Skip to content

Network

Andrei Montchik edited this page Jul 1, 2024 · 14 revisions

Docs

Firewall

  • Check all installed firewall related packages: dpkg -l | grep firewall
  • Check the ufw (Uncomplicated Firewall) status: sudo ufw status
  • Configure ufw:
    1. Confirm the SSH port:
      1. Run the sudo netstat -tulna command and locate the line about tcp connection between the Host and Workstation IPs, something like this: tcp 0 0 162.250.126.142:22 76.16.6.193:37418 ESTABLISHED. The Hosts port is an SSH port, usually it is 22.
    2. Add the default SSH rule to ufw: sudo ufw allow ssh.
    3. Confirm that the rule is added to /etc/ufw/user.rules and /etc/ufw/user6.rules.

Util

iftop

The console app to visualize network bandwidth. Documentation

  • Install:
    1. sudo apt update; sudo apt install iftop
  • Run: sudo iftop
    • press p to display ports
    • press n to disable/enable DNS resolution
    • press t to toggle between transmitted only / received only and bi-directional traffic
    • columns on the right are 2, 10 and 40 sec averages, press 1, 2 or 3 to sort by them

Collection of networking tools.

netstat

  • Install: apt-get install net-tools
  • List of network interfaces: netstat -i
  • Review routing table: netstat -nr
  • Review multicast groups: netstat -g
  • Find out which apps are using the specific port:
    • sudo netstat -tuanp | grep 8003
    • ss -tuanp | grep 8003
    • lsof -i -P -n | grep LISTEN

Sends and receives data between two computers/netwioks via TCP or UDP.

  • Install: apt-get install netcat
  • Check connectivity: netcat -vz <ip or hostname> port

Captures network traffic.

  • List of available interfaces: tcpdump -D
  • Capture 5 packets from all NICs from the specific host and port and print the ASCII content of a packet: tcpdump -i any -nn -c 5 -A host <hostname> and port <port>
  • Capture packets on the mutlicast enabled core NIC and UDP port :tcpdump -i core -vv udp port <udp port>

ethtool

Check for dropped packets.

  • Run /sbin/ethtool -S s1p1 | grep drop
    • rx_noskb_drops - number of packets dropped when there are no further socket buffers to use.
    • port_rx_nodesc_drops - number of packets dropped when there are no further descriptors in the rx ring buffer to receive them.
    • port_rx_dp_di_dropped_packets - number of packets dropped because filters indicate the packets should be dropped. This can happen when packets don’t match any filter or the matched filter indicates the packet should be dropped.
  • The Ethernet bonding driver level: cat /proc/net/bonding/core

Tuning

Increase UDP r/w buffers size

  • Check:
sysctl net.core.rmem_default; \
sysctl net.core.rmem_max; \
sysctl net.core.wmem_default; \
sysctl net.core.wmem_max;
  • Update:
sudo sysctl -w net.core.rmem_default=134217728 \
sudo sysctl -w net.core.rmem_max=134217728; \
sudo sysctl -w net.core.wmem_default=134217728; \
sudo sysctl -w net.core.wmem_max=134217728;
  • Reload the sysctl service to pick up the change: sudo sysctl -p

CLI

  • Show list of all NICs: ip a
  • Show current connection status of NICs: nmcli device status
  • Show local IP: hostname -I
  • Show public IP from external source: https://ifconfig.me/
  • Turn WIFI on/off: sudo nmcli radio wifi [on|off]

Clone this wiki locally