2

I have a computer with a NIC with two ports and a switch between them, and I'm trying to send data from one port to the other using netcat. I thought I could simply specify the source address (i.e. the source interface) with the -s switch, since the documentation explicitly states:

-s source
         Specifies the IP of the interface which is used to send the packets.  For UNIX-domain
         datagram sockets, specifies the local temporary socket file to create and use so that
         datagrams can be received.

Unfortunately it doesn't matter what I put after the -s in my command, the resulting output is always:

usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
  [-m minttl] [-O length] [-P proxy_username] [-p source_port]
  [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
  [-X proxy_protocol] [-x proxy_address[:port]]       [destination] [port]

I'm really out of ideas and would be happy if someone could tell me what the problem with the following commands is:

  • nc -s 10.0.0.1 -u 10.0.1.1 10000
  • nc -u -s 10.0.0.1 10.0.1.1 10000
  • netcat -s 10.0.0.1 -u 10.0.1.1 10000
  • netcat -u -s 10.0.0.1 10.0.1.1 10000
7
  • Which netcat is this? I think there's at least 3 different, yet similar acting programs out there named netcat.
    – user732
    Dec 11, 2019 at 13:35
  • 2
    It's out of the scope of netcat but just to indicate another problem you'll probably face. If you have those both addresses on same host than by default it's going to be routed via loopback interface. You can check it with ip route get 10.0.1.1 command.
    – pawel7318
    Dec 11, 2019 at 13:48
  • which linux version ? which package ? Dec 11, 2019 at 15:44
  • maybe nc is an alias?
    – user313992
    Dec 11, 2019 at 19:28
  • Ubuntu 18.04, where nc and netcat are both aliased to /bin/nc.openbsd
    – jangxx
    Dec 13, 2019 at 10:15

0

You must log in to answer this question.

Browse other questions tagged .