Networking Hacks

From
Jump to: navigation, search

Networking Hacks[edit]

Often it becomes necessary to debug low-level network connections such as raw UDP or TCP connections. Two immensely useful tools to do this are tcpdump and netcat:

firewalld[edit]

On some systems (such as Fedora workstation) the firewall-daemon firewalld comes with a strict set of rules active.

To list the current state, type: firewall-cmd --list-all To list open ports, type: firewall-cmd --list-ports To add an additional port, type: firewall-cmd --add-port=80/tcp

These commands were taken from https://docs.fedoraproject.org/en-US/quick-docs/firewalld/

Sending and Receiving Data[edit]

Sending Data via UDP: create a server: netcat -u IP PORT type and enter to send data The server is terminated either via Ctrl + D or Ctrl + C

sending data via TCP: create a server: netcat IP PORT type and enter to send data The server is terminated either via Ctrl + D or Ctrl + C

Receive data via UDP: netcat -u -l PORT terminate via Ctrl + C

Receive data via TCP netcat -l PORT terminate via Ctrl + C

Monitoring of existing connections / packets[edit]

In order to monitor tcp/udp packages, tcpdump can be employed:

sudo tcpdump -i wlp61s0 udp port 52001 -vv

Here wlp61s0 corresponds to the interface (in this case: wifi) and UDP specifies the protocol. -vv controls the level of verbosity (e.g. detail)