Netcat: Difference between revisions
From wikinotes
No edit summary |
(→Usage) |
||
Line 13: | Line 13: | ||
= Usage = | = Usage = | ||
<blockquote> | <blockquote> | ||
== Common Flags == | |||
<blockquote> | |||
< | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nc \ | nc \ | ||
Line 24: | Line 21: | ||
-z # check if reachable \ | -z # check if reachable \ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Common Flags --> | |||
== Port Testing == | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
nc -vz x.x.x.x 80 # ipv4 confirm port 80 open | |||
nc -6 -vz xxxx:xxxx:xxx:xx::xxx::xxxx 80 # ipv6 confirm port 80 open | |||
</syntaxhighlight> | |||
</blockquote><!-- Port Testing --> | |||
== Listen/Send on Port == | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
nc -l -p 6001 # Listen to port 6001 on localhost | nc -l -p 6001 # Listen to port 6001 on localhost | ||
Line 30: | Line 38: | ||
echo "hello" | nc 127.0.0.1 6001 # Send test 'hello' to port 6001 on localhost | echo "hello" | nc 127.0.0.1 6001 # Send test 'hello' to port 6001 on localhost | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Listen/Send on Port --> | |||
== Listen/Send on FIFO == | |||
<blockquote> | |||
<syntaxhighlight lang="bash"> | |||
mkfifo /var/temp.sock | |||
nc -U /var/temp.sock # listen on fifo | |||
</syntaxhighlight> | |||
</blockquote><!-- Listen/Send on sockfile --> | |||
</blockquote><!-- Usage --> | </blockquote><!-- Usage --> |
Latest revision as of 03:15, 8 August 2021
netcat is a tool for using and testing TCP.
NOTE:
netcat has been superceeded by ss
Install
pacman -S openbsd-netcat
Usage
Common Flags
nc \ -u # send udp packets \ -v # verbose \ -z # check if reachable \Port Testing
nc -vz x.x.x.x 80 # ipv4 confirm port 80 open nc -6 -vz xxxx:xxxx:xxx:xx::xxx::xxxx 80 # ipv6 confirm port 80 openListen/Send on Port
nc -l -p 6001 # Listen to port 6001 on localhost echo "hello" | nc 127.0.0.1 6001 # Send test 'hello' to port 6001 on localhostListen/Send on FIFO
mkfifo /var/temp.sock nc -U /var/temp.sock # listen on fifo