[BACK]Return to nc.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / nc

Annotation of src/usr.bin/nc/nc.1, Revision 1.95

1.95    ! schwarze    1: .\"     $OpenBSD: nc.1,v 1.94 2019/10/24 17:27:08 kn Exp $
1.1       deraadt     2: .\"
                      3: .\" Copyright (c) 1996 David Sacerdote
                      4: .\" All rights reserved.
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
                     14: .\" 3. The name of the author may not be used to endorse or promote products
                     15: .\"    derived from this software without specific prior written permission
                     16: .\"
                     17: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     18: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     19: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     20: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     21: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     22: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     23: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     24: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     25: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     26: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     27: .\"
1.95    ! schwarze   28: .Dd $Mdocdate: October 24 2019 $
1.3       aaron      29: .Dt NC 1
1.4       deraadt    30: .Os
1.1       deraadt    31: .Sh NAME
                     32: .Nm nc
1.28      jmc        33: .Nd arbitrary TCP and UDP connections and listens
1.2       deraadt    34: .Sh SYNOPSIS
1.1       deraadt    35: .Nm nc
1.70      jmc        36: .Op Fl 46cDdFhklNnrStUuvz
                     37: .Op Fl C Ar certfile
                     38: .Op Fl e Ar name
                     39: .Op Fl H Ar hash
1.47      jmc        40: .Op Fl I Ar length
1.1       deraadt    41: .Op Fl i Ar interval
1.70      jmc        42: .Op Fl K Ar keyfile
1.73      jca        43: .Op Fl M Ar ttl
                     44: .Op Fl m Ar minttl
1.47      jmc        45: .Op Fl O Ar length
1.77      beck       46: .Op Fl o Ar staplefile
1.42      djm        47: .Op Fl P Ar proxy_username
1.28      jmc        48: .Op Fl p Ar source_port
1.70      jmc        49: .Op Fl R Ar CAfile
1.95    ! schwarze   50: .Op Fl s Ar sourceaddr
1.69      beck       51: .Op Fl T Ar keyword
1.54      guenther   52: .Op Fl V Ar rtable
1.85      bluhm      53: .Op Fl W Ar recvlimit
1.6       aaron      54: .Op Fl w Ar timeout
1.33      djm        55: .Op Fl X Ar proxy_protocol
1.71      schwarze   56: .Op Fl x Ar proxy_address Ns Op : Ns Ar port
1.83      beck       57: .Op Fl Z Ar peercertfile
1.57      jeremy     58: .Op Ar destination
1.48      sobrado    59: .Op Ar port
1.1       deraadt    60: .Sh DESCRIPTION
                     61: The
1.6       aaron      62: .Nm
1.1       deraadt    63: (or
                     64: .Nm netcat )
1.57      jeremy     65: utility is used for just about anything under the sun involving TCP,
                     66: UDP, or
                     67: .Ux Ns -domain
                     68: sockets.
1.13      ericj      69: It can open TCP connections, send UDP packets, listen on arbitrary
                     70: TCP and UDP ports, do port scanning, and deal with both IPv4 and
                     71: IPv6.
1.7       aaron      72: Unlike
1.1       deraadt    73: .Xr telnet 1 ,
1.6       aaron      74: .Nm
1.1       deraadt    75: scripts nicely, and separates error messages onto standard error instead
1.6       aaron      76: of sending them to standard output, as
1.24      pvalchev   77: .Xr telnet 1
1.6       aaron      78: does with some.
1.1       deraadt    79: .Pp
                     80: Common uses include:
1.7       aaron      81: .Pp
                     82: .Bl -bullet -offset indent -compact
1.1       deraadt    83: .It
1.3       aaron      84: simple TCP proxies
1.1       deraadt    85: .It
1.28      jmc        86: shell-script based HTTP clients and servers
1.1       deraadt    87: .It
1.13      ericj      88: network daemon testing
1.1       deraadt    89: .It
1.33      djm        90: a SOCKS or HTTP ProxyCommand for
                     91: .Xr ssh 1
                     92: .It
1.1       deraadt    93: and much, much more
                     94: .El
                     95: .Pp
                     96: The options are as follows:
                     97: .Bl -tag -width Ds
1.13      ericj      98: .It Fl 4
1.89      schwarze   99: Use IPv4 addresses only.
1.13      ericj     100: .It Fl 6
1.89      schwarze  101: Use IPv6 addresses only.
1.70      jmc       102: .It Fl C Ar certfile
1.89      schwarze  103: Load the public key part of the TLS peer certificate from
                    104: .Ar certfile ,
                    105: in PEM format.
                    106: Requires
                    107: .Fl c .
1.69      beck      108: .It Fl c
1.89      schwarze  109: Use TLS to connect or listen.
                    110: Cannot be used together with any of the options
                    111: .Fl FuU .
1.32      markus    112: .It Fl D
                    113: Enable debugging on the socket.
1.29      tedu      114: .It Fl d
                    115: Do not attempt to read from stdin.
1.69      beck      116: .It Fl e Ar name
1.89      schwarze  117: Only accept the TLS peer certificate if it contains the
                    118: .Ar name .
                    119: Requires
                    120: .Fl c .
                    121: If not specified,
                    122: .Ar destination
                    123: is used.
1.64      djm       124: .It Fl F
                    125: Pass the first connected socket using
                    126: .Xr sendmsg 2
                    127: to stdout and exit.
                    128: This is useful in conjunction with
                    129: .Fl X
                    130: to have
                    131: .Nm
                    132: perform connection setup with a proxy but then leave the rest of the
1.65      jmc       133: connection to another program (e.g.\&
1.64      djm       134: .Xr ssh 1
                    135: using the
                    136: .Xr ssh_config 5
1.68      tobias    137: .Cm ProxyUseFdpass
1.64      djm       138: option).
1.89      schwarze  139: Cannot be used with
                    140: .Fl c
                    141: or
                    142: .Fl U .
1.70      jmc       143: .It Fl H Ar hash
1.89      schwarze  144: Only accept the TLS peer certificate if its hash returned from
                    145: .Xr tls_peer_cert_hash 3
                    146: matches
                    147: .Ar hash .
                    148: Requires
                    149: .Fl c
                    150: and cannot be used with
                    151: .Fl T Cm noverify .
1.13      ericj     152: .It Fl h
1.89      schwarze  153: Print out the
1.13      ericj     154: .Nm
1.89      schwarze  155: help text and exit.
1.47      jmc       156: .It Fl I Ar length
1.89      schwarze  157: Specify the size of the TCP receive buffer.
1.13      ericj     158: .It Fl i Ar interval
1.89      schwarze  159: Sleep for
                    160: .Ar interval
                    161: seconds between lines of text sent and received.
1.1       deraadt   162: Also causes a delay time between connections to multiple ports.
1.70      jmc       163: .It Fl K Ar keyfile
1.89      schwarze  164: Load the TLS private key from
                    165: .Ar keyfile ,
                    166: in PEM format.
                    167: Requires
                    168: .Fl c .
1.13      ericj     169: .It Fl k
1.89      schwarze  170: When a connection is completed, listen for another one.
                    171: Requires
                    172: .Fl l .
1.61      haesbaer  173: When used together with the
                    174: .Fl u
                    175: option, the server socket is not connected and it can receive UDP datagrams from
                    176: multiple hosts.
1.1       deraadt   177: .It Fl l
1.89      schwarze  178: Listen for an incoming connection rather than initiating a
1.7       aaron     179: connection to a remote host.
1.89      schwarze  180: Cannot be used together with any of the options
                    181: .Fl psxz .
1.36      jmc       182: Additionally, any timeouts specified with the
1.35      jmc       183: .Fl w
1.36      jmc       184: option are ignored.
1.73      jca       185: .It Fl M Ar ttl
1.74      jmc       186: Set the TTL / hop limit of outgoing packets.
1.73      jca       187: .It Fl m Ar minttl
1.74      jmc       188: Ask the kernel to drop incoming packets whose TTL / hop limit is under
1.73      jca       189: .Ar minttl .
1.62      sthen     190: .It Fl N
                    191: .Xr shutdown 2
                    192: the network socket after EOF on the input.
                    193: Some servers require this to finish their work.
1.1       deraadt   194: .It Fl n
1.94      kn        195: Do not perform domain name resolution.
                    196: If a name cannot be resolved without DNS, an error will be reported.
1.47      jmc       197: .It Fl O Ar length
1.89      schwarze  198: Specify the size of the TCP send buffer.
1.77      beck      199: .It Fl o Ar staplefile
1.89      schwarze  200: During the TLS handshake, load data to be stapled from
                    201: .Ar staplefile ,
                    202: which is expected to contain an OCSP response from an OCSP server in
1.78      jmc       203: DER format.
1.89      schwarze  204: Requires
                    205: .Fl c
                    206: and
                    207: .Fl C .
1.42      djm       208: .It Fl P Ar proxy_username
                    209: Specifies a username to present to a proxy server that requires authentication.
                    210: If no username is specified then authentication will not be attempted.
                    211: Proxy authentication is only supported for HTTP CONNECT proxies at present.
1.28      jmc       212: .It Fl p Ar source_port
1.89      schwarze  213: Specify the source port
1.6       aaron     214: .Nm
1.1       deraadt   215: should use, subject to privilege restrictions and availability.
1.89      schwarze  216: Cannot be used together with
                    217: .Fl l .
1.70      jmc       218: .It Fl R Ar CAfile
1.89      schwarze  219: Load the root CA bundle for TLS certificate verification from
                    220: .Ar CAfile ,
                    221: in PEM format, instead of
1.69      beck      222: .Pa /etc/ssl/cert.pem .
1.89      schwarze  223: Requires
                    224: .Fl c .
1.1       deraadt   225: .It Fl r
1.89      schwarze  226: Choose source and/or destination ports randomly
1.13      ericj     227: instead of sequentially within a range or in the order that the system
1.21      ericj     228: assigns them.
1.28      jmc       229: .It Fl S
1.89      schwarze  230: Enable the RFC 2385 TCP MD5 signature option.
1.95    ! schwarze  231: .It Fl s Ar sourceaddr
        !           232: Set the source address to send packets from,
        !           233: which is useful on machines with multiple interfaces.
1.56      jeremy    234: For
                    235: .Ux Ns -domain
                    236: datagram sockets, specifies the local temporary socket file
                    237: to create and use so that datagrams can be received.
1.89      schwarze  238: Cannot be used together with
1.28      jmc       239: .Fl l
1.89      schwarze  240: or
                    241: .Fl x .
1.69      beck      242: .It Fl T Ar keyword
1.91      jmc       243: Change the IPv4 TOS/IPv6 traffic class value or the TLS options.
1.89      schwarze  244: .Pp
                    245: For TLS options,
1.69      beck      246: .Ar keyword
1.87      jmc       247: may be one of:
1.89      schwarze  248: .Cm noverify ,
1.70      jmc       249: which disables certificate verification;
1.89      schwarze  250: .Cm noname ,
1.75      beck      251: which disables certificate name checking;
1.89      schwarze  252: .Cm clientcert ,
1.75      beck      253: which requires a client certificate on incoming connections; or
1.89      schwarze  254: .Cm muststaple ,
1.76      jmc       255: which requires the peer to provide a valid stapled OCSP response
                    256: with the handshake.
1.89      schwarze  257: The following TLS options specify a value in the form of a
                    258: .Ar key Ns = Ns Ar value
                    259: pair:
                    260: .Cm ciphers ,
1.88      jsing     261: which allows the supported TLS ciphers to be specified (see
                    262: .Xr tls_config_set_ciphers 3
                    263: for further details);
1.89      schwarze  264: .Cm protocols ,
1.88      jsing     265: which allows the supported TLS protocols to be specified (see
                    266: .Xr tls_config_parse_protocols 3
                    267: for further details).
1.90      jmc       268: Specifying TLS options requires
1.89      schwarze  269: .Fl c .
1.70      jmc       270: .Pp
1.91      jmc       271: For the IPv4 TOS/IPv6 traffic class value,
1.69      beck      272: .Ar keyword
1.58      haesbaer  273: may be one of
1.89      schwarze  274: .Cm critical ,
                    275: .Cm inetcontrol ,
                    276: .Cm lowdelay ,
                    277: .Cm netcontrol ,
                    278: .Cm throughput ,
                    279: .Cm reliability ,
1.58      haesbaer  280: or one of the DiffServ Code Points:
1.89      schwarze  281: .Cm ef ,
                    282: .Cm af11 No ... Cm af43 ,
                    283: .Cm cs0 No ... Cm cs7 ;
1.58      haesbaer  284: or a number in either hex or decimal.
1.1       deraadt   285: .It Fl t
1.89      schwarze  286: Send RFC 854 DON'T and WON'T responses to RFC 854 DO and WILL requests.
1.7       aaron     287: This makes it possible to use
1.6       aaron     288: .Nm
1.7       aaron     289: to script telnet sessions.
1.28      jmc       290: .It Fl U
1.89      schwarze  291: Use
1.52      sobrado   292: .Ux Ns -domain
                    293: sockets.
1.89      schwarze  294: Cannot be used together with any of the options
                    295: .Fl cFx .
1.1       deraadt   296: .It Fl u
1.89      schwarze  297: Use UDP instead of TCP.
                    298: Cannot be used together with
                    299: .Fl c
                    300: or
                    301: .Fl x .
1.56      jeremy    302: For
                    303: .Ux Ns -domain
                    304: sockets, use a datagram socket instead of a stream socket.
                    305: If a
                    306: .Ux Ns -domain
                    307: socket is used, a temporary receiving socket is created in
                    308: .Pa /tmp
                    309: unless the
                    310: .Fl s
                    311: flag is given.
1.54      guenther  312: .It Fl V Ar rtable
                    313: Set the routing table to be used.
1.1       deraadt   314: .It Fl v
1.89      schwarze  315: Produce more verbose output.
1.85      bluhm     316: .It Fl W Ar recvlimit
                    317: Terminate after receiving
                    318: .Ar recvlimit
                    319: packets from the network.
1.26      jmc       320: .It Fl w Ar timeout
1.59      fgsch     321: Connections which cannot be established or are idle timeout after
1.26      jmc       322: .Ar timeout
1.59      fgsch     323: seconds.
1.26      jmc       324: The
                    325: .Fl w
                    326: flag has no effect on the
                    327: .Fl l
                    328: option, i.e.\&
                    329: .Nm
                    330: will listen forever for a connection, with or without the
                    331: .Fl w
                    332: flag.
                    333: The default is no timeout.
1.43      jmc       334: .It Fl X Ar proxy_protocol
1.89      schwarze  335: Use
                    336: .Ar proxy_protocol
                    337: when talking to the proxy server.
1.33      djm       338: Supported protocols are
1.89      schwarze  339: .Cm 4
1.33      djm       340: (SOCKS v.4),
1.89      schwarze  341: .Cm 5
1.33      djm       342: (SOCKS v.5)
                    343: and
1.89      schwarze  344: .Cm connect
1.33      djm       345: (HTTPS proxy).
                    346: If the protocol is not specified, SOCKS version 5 is used.
1.71      schwarze  347: .It Fl x Ar proxy_address Ns Op : Ns Ar port
1.89      schwarze  348: Connect to
1.57      jeremy    349: .Ar destination
1.33      djm       350: using a proxy at
1.28      jmc       351: .Ar proxy_address
                    352: and
                    353: .Ar port .
                    354: If
                    355: .Ar port
1.33      djm       356: is not specified, the well-known port for the proxy protocol is used (1080
                    357: for SOCKS, 3128 for HTTPS).
1.82      jca       358: An IPv6 address can be specified unambiguously by enclosing
                    359: .Ar proxy_address
                    360: in square brackets.
1.89      schwarze  361: A proxy cannot be used with any of the options
                    362: .Fl lsuU .
1.84      jmc       363: .It Fl Z Ar peercertfile
1.89      schwarze  364: Save the peer certificates to
                    365: .Ar peercertfile ,
1.84      jmc       366: in PEM format.
1.89      schwarze  367: Requires
                    368: .Fl c .
1.1       deraadt   369: .It Fl z
1.89      schwarze  370: Only scan for listening daemons, without sending any data to them.
                    371: Cannot be used together with
                    372: .Fl l .
1.28      jmc       373: .El
1.35      jmc       374: .Pp
1.57      jeremy    375: .Ar destination
1.35      jmc       376: can be a numerical IP address or a symbolic hostname
                    377: (unless the
                    378: .Fl n
                    379: option is given).
1.57      jeremy    380: In general, a destination must be specified,
1.35      jmc       381: unless the
                    382: .Fl l
                    383: option is given
                    384: (in which case the local host is used).
1.57      jeremy    385: For
                    386: .Ux Ns -domain
                    387: sockets, a destination is required and is the socket path to connect to
                    388: (or listen on if the
                    389: .Fl l
                    390: option is given).
1.35      jmc       391: .Pp
1.48      sobrado   392: .Ar port
1.93      jmc       393: can be specified as a numeric port number or as a service name.
1.92      tedu      394: Port ranges may be specified as numeric port numbers of the form
1.89      schwarze  395: .Ar nn Ns - Ns Ar mm .
1.35      jmc       396: In general,
                    397: a destination port must be specified,
                    398: unless the
                    399: .Fl U
1.57      jeremy    400: option is given.
1.28      jmc       401: .Sh CLIENT/SERVER MODEL
                    402: It is quite simple to build a very basic client/server model using
                    403: .Nm .
                    404: On one console, start
                    405: .Nm
                    406: listening on a specific port for a connection.
                    407: For example:
                    408: .Pp
                    409: .Dl $ nc -l 1234
                    410: .Pp
                    411: .Nm
                    412: is now listening on port 1234 for a connection.
                    413: On a second console
                    414: .Pq or a second machine ,
                    415: connect to the machine and port being listened on:
                    416: .Pp
                    417: .Dl $ nc 127.0.0.1 1234
                    418: .Pp
                    419: There should now be a connection between the ports.
                    420: Anything typed at the second console will be concatenated to the first,
                    421: and vice-versa.
                    422: After the connection has been set up,
                    423: .Nm
                    424: does not really care which side is being used as a
                    425: .Sq server
                    426: and which side is being used as a
                    427: .Sq client .
                    428: The connection may be terminated using an
                    429: .Dv EOF
                    430: .Pq Sq ^D .
                    431: .Sh DATA TRANSFER
                    432: The example in the previous section can be expanded to build a
                    433: basic data transfer model.
                    434: Any information input into one end of the connection will be output
                    435: to the other end, and input and output can be easily captured in order to
                    436: emulate file transfer.
                    437: .Pp
                    438: Start by using
                    439: .Nm
                    440: to listen on a specific port, with output captured into a file:
                    441: .Pp
                    442: .Dl $ nc -l 1234 \*(Gt filename.out
                    443: .Pp
                    444: Using a second machine, connect to the listening
                    445: .Nm
                    446: process, feeding it the file which is to be transferred:
                    447: .Pp
1.66      jmc       448: .Dl $ nc -N host.example.com 1234 \*(Lt filename.in
1.28      jmc       449: .Pp
                    450: After the file has been transferred, the connection will close automatically.
                    451: .Sh TALKING TO SERVERS
                    452: It is sometimes useful to talk to servers
                    453: .Dq by hand
                    454: rather than through a user interface.
                    455: It can aid in troubleshooting,
                    456: when it might be necessary to verify what data a server is sending
                    457: in response to commands issued by the client.
                    458: For example, to retrieve the home page of a web site:
1.40      jmc       459: .Bd -literal -offset indent
1.55      guenther  460: $ printf "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80
1.40      jmc       461: .Ed
1.28      jmc       462: .Pp
                    463: Note that this also displays the headers sent by the web server.
                    464: They can be filtered, using a tool such as
                    465: .Xr sed 1 ,
                    466: if necessary.
                    467: .Pp
                    468: More complicated examples can be built up when the user knows the format
                    469: of requests required by the server.
                    470: As another example, an email may be submitted to an SMTP server using:
                    471: .Bd -literal -offset indent
                    472: $ nc localhost 25 \*(Lt\*(Lt EOF
                    473: HELO host.example.com
1.44      jmc       474: MAIL FROM:\*(Ltuser@host.example.com\*(Gt
                    475: RCPT TO:\*(Ltuser2@host.example.com\*(Gt
1.28      jmc       476: DATA
                    477: Body of email.
                    478: \&.
                    479: QUIT
                    480: EOF
                    481: .Ed
                    482: .Sh PORT SCANNING
                    483: It may be useful to know which ports are open and running services on
                    484: a target machine.
                    485: The
                    486: .Fl z
                    487: flag can be used to tell
1.22      markus    488: .Nm
1.39      jmc       489: to report open ports,
                    490: rather than initiate a connection.
1.28      jmc       491: For example:
                    492: .Bd -literal -offset indent
1.39      jmc       493: $ nc -z host.example.com 20-30
1.28      jmc       494: Connection to host.example.com 22 port [tcp/ssh] succeeded!
                    495: Connection to host.example.com 25 port [tcp/smtp] succeeded!
                    496: .Ed
                    497: .Pp
                    498: The port range was specified to limit the search to ports 20 \- 30.
                    499: .Pp
                    500: Alternatively, it might be useful to know which server software
                    501: is running, and which versions.
                    502: This information is often contained within the greeting banners.
                    503: In order to retrieve these, it is necessary to first make a connection,
                    504: and then break the connection when the banner has been retrieved.
                    505: This can be accomplished by specifying a small timeout with the
                    506: .Fl w
                    507: flag, or perhaps by issuing a
                    508: .Qq Dv QUIT
                    509: command to the server:
                    510: .Bd -literal -offset indent
                    511: $ echo "QUIT" | nc host.example.com 20-30
                    512: SSH-1.99-OpenSSH_3.6.1p2
                    513: Protocol mismatch.
                    514: 220 host.example.com IMS SMTP Receiver Version 0.84 Ready
                    515: .Ed
1.1       deraadt   516: .Sh EXAMPLES
1.37      jmc       517: Open a TCP connection to port 42 of host.example.com, using port 31337 as
1.28      jmc       518: the source port, with a timeout of 5 seconds:
                    519: .Pp
1.37      jmc       520: .Dl $ nc -p 31337 -w 5 host.example.com 42
1.69      beck      521: .Pp
1.88      jsing     522: Open a TCP connection to port 443 of www.example.com, and negotiate TLS with
                    523: any supported TLS protocol version and "compat" ciphers:
                    524: .Pp
                    525: .Dl $ nc -cv -T protocols=all -T ciphers=compat www.example.com 443
                    526: .Pp
1.70      jmc       527: Open a TCP connection to port 443 of www.google.ca, and negotiate TLS.
1.88      jsing     528: Check for a different name in the certificate for validation:
1.69      beck      529: .Pp
1.88      jsing     530: .Dl $ nc -cv -e adsf.au.doubleclick.net www.google.ca 443
1.28      jmc       531: .Pp
1.37      jmc       532: Open a UDP connection to port 53 of host.example.com:
1.28      jmc       533: .Pp
1.37      jmc       534: .Dl $ nc -u host.example.com 53
1.28      jmc       535: .Pp
1.37      jmc       536: Open a TCP connection to port 42 of host.example.com using 10.1.2.3 as the
1.28      jmc       537: IP for the local end of the connection:
                    538: .Pp
1.37      jmc       539: .Dl $ nc -s 10.1.2.3 host.example.com 42
1.28      jmc       540: .Pp
1.51      sobrado   541: Create and listen on a
1.52      sobrado   542: .Ux Ns -domain
1.57      jeremy    543: stream socket:
1.28      jmc       544: .Pp
                    545: .Dl $ nc -lU /var/tmp/dsocket
1.33      djm       546: .Pp
1.37      jmc       547: Connect to port 42 of host.example.com via an HTTP proxy at 10.2.3.4,
1.38      jmc       548: port 8080.
                    549: This example could also be used by
                    550: .Xr ssh 1 ;
                    551: see the
                    552: .Cm ProxyCommand
                    553: directive in
                    554: .Xr ssh_config 5
                    555: for more information.
1.33      djm       556: .Pp
1.37      jmc       557: .Dl $ nc -x10.2.3.4:8080 -Xconnect host.example.com 42
1.42      djm       558: .Pp
                    559: The same example again, this time enabling proxy authentication with username
                    560: .Dq ruser
                    561: if the proxy requires it:
                    562: .Pp
                    563: .Dl $ nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42
1.1       deraadt   564: .Sh SEE ALSO
1.38      jmc       565: .Xr cat 1 ,
                    566: .Xr ssh 1
1.15      smart     567: .Sh AUTHORS
1.89      schwarze  568: Original implementation by
                    569: .An *Hobbit* Aq Mt hobbit@avian.org .
1.28      jmc       570: .br
                    571: Rewritten with IPv6 support by
1.63      schwarze  572: .An Eric Jackson Aq Mt ericj@monkey.org .
1.39      jmc       573: .Sh CAVEATS
1.60      lum       574: UDP port scans using the
1.39      jmc       575: .Fl uz
1.60      lum       576: combination of flags will always report success irrespective of
                    577: the target machine's state.
                    578: However,
                    579: in conjunction with a traffic sniffer either on the target machine
                    580: or an intermediary device,
                    581: the
                    582: .Fl uz
                    583: combination could be useful for communications diagnostics.
                    584: Note that the amount of UDP traffic generated may be limited either
                    585: due to hardware resources and/or configuration settings.