TCP IP
sudo apt update && sudo apt install tcpdump -y
View TCP/IP traffic on an interface:
sudo tcpdump -i eth0 tcp
This shows TCP packets with source and destination addresses, ports, and flags. For IP traffic without a TCP filter:
sudo tcpdump -i eth0 ip
7. Use `tc` for traffic control based on TCP/IP principles
The `tc` (traffic control) tool in Linux works based on TCP/IP principles. The `tc ct` action communicates with the netfilter conntrack module to track connections, essential for stateful firewalling and NAT. View the current qdiscs:tc qdisc show
Add a netem qdisc to simulate delay:
sudo tc qdisc add dev eth0 root netem delay 100ms
Remove the qdisc again:
sudo tc qdisc del dev eth0 root
8. Check checksums with `tc-csum`
`tc-csum` recalculates checksums after modifying packet data, needed to keep TCP/IP packets correct. Add a csum action to a filter:sudo tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dst 192.168.1.1/32 action csum updateThis recalculates the checksum for packets to 192.168.1.1. Check the filter:
tc filter show dev eth0
Verification
Check whether TCP/IP works correctly on your system:ip addr show
Shows the IP addresses on your interfaces. Check connectivity:
ping -c 4 8.8.8.8
Shows ICMP echoes, which confirms that IP routing works. For TCP connectivity:
ss -tuln
Shows TCP and UDP listeners on your system. If these commands produce output, TCP/IP is running correctly.
Common problems
Problem: `tcpdump` shows no packets Cause: you have not selected the correct interface or lack root privileges. Solution: use `sudo` and check interfaces with `ip link show`. Select the correct interface, for example `tcpdump -i wlan0 tcp` for wifi.Problem: `tc qdisc add` returns "RTNETLINK answers: Operation not permitted" Cause: you do not have root privileges or the interface does not support the qdisc. Solution: use `sudo` and check that the interface is up with `ip link set eth0 up`.
Problem: `tc filter add` fails with a "match" error Cause: the filter syntax is incorrect. Solution: check the IP addresses and use the correct protocol. Consult the manual with `man tc-u32` for the full syntax.
The protocol suite continues to evolve through new RFCs and better implementations, but the core — the combination of TCP and IP — has remained unchanged since the migration on ARPANET in 1983.