Networking Cheat Sheet

Iptables

Redirect port 443 to port 3000 (tcp)

iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3000

Delete a redirect

Just have to use the -D option:

iptables -t nat -D PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3000

netstat

List open ports

sudo netstat -tulpn | grep LISTEN

Rsync

Use a different port than ssh’s default (22):

rsync -av -e 'ssh -p PORT' source user@host:/path/to/dest