cheat-fork-echo/cheat/cheatsheets/nc
Chris Lane 6b8ecd6b5c Cherry-picking changes from #185
@zhujian0805 contributed some excellent cheatsheets in #185, but some
binary files seem to have gotten mixed into the commit as well. This
commit cherry-picks the cheatsheet file changes from that PR while
leaving behind the cruft.

Also performed minor editing on some of the cheatsheets.
2014-10-19 11:43:43 -04:00

20 lines
1,003 B
Text

# To open a TCP connection to port 42 of host.example.com, using port 31337 as the source port, with a timeout of 5 seconds:
nc -p 31337 -w 5 host.example.com 42
# To open a UDP connection to port 53 of host.example.com:
nc -u host.example.com 53
# To open a TCP connection to port 42 of host.example.com using 10.1.2.3 as the IP for the local end of the connection:
nc -s 10.1.2.3 host.example.com 42
# To create and listen on a UNIX-domain stream socket:
nc -lU /var/tmp/dsocket
# To connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4, port 8080. This example could also be used by ssh(1); see the ProxyCommand directive in ssh_config(5) for more information.
nc -x10.2.3.4:8080 -Xconnect host.example.com 42
# The same example again, this time enabling proxy authentication with username "ruser" if the proxy requires it:
nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42
# To choose the source IP for the testing using the -s option
nc -zv -s source_IP target_IP Port