Re: multiple loopback devices?
The reason for the "invalid connection" message is probably due
to how nc handles incoming connections.
Doing
nc -l -p 1000 127.0.0.1
makes it bind to port 1000 on any attached interface, and it only
accepts connections from source address 127.0.0.1.
It will not bind to port 127.0.0.1 only as one could assume.
From /usr/doc/netcat/README page ~188:
Listen mode will cause netcat to wait for an inbound connection, and then the
same data transfer happens. Thus, you can do "nc -l -p 1234 < filename" and
when someone else connects to your port 1234, the file is sent to them whether
they wanted it or not. Listen mode is generally used along with a local port
argument -- this is required for UDP mode, while TCP mode can have the system
assign one and tell you what it is if -v is turned on. If you specify a target
host and optional port in listen mode, netcat will accept an inbound connection
only from that host and if you specify one, only from that foreign source port.
In verbose mode you'll be informed about the inbound connection, including what
address and port it came from, and since listening on "any" applies to several
possibilities, which address it came *to* on your end. If the system supports
IP socket options, netcat will attempt to retrieve any such options from an
inbound connection and print them out in hex.
Doing a:
$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:1000 0.0.0.0:* LISTEN
...
verifies the behaviour.
Regards,
/Karl
-----------------------------------------------------------------------
Karl Hammar Aspö Data karl@kalle.csb.ki.se
Lilla Aspö 2340 +46 173 140 57 Networks
S-742 94 Östhammar +46 10 270 26 67 Computers
Sweden Consulting
-----------------------------------------------------------------------
From: bronson@rinspin.com (Scott Bronson)
Subject: Re: multiple loopback devices?
Date: Fri, 13 Apr 2001 20:59:43 -0700
> On Thu, Apr 05, 2001 at 12:57:25PM +0200, Karl Hammar wrote:
> > Something like:
> > # ifconfig lo:1 127.0.0.2
>
> _Exactly_ like that. Thanks, Karl!
>
> One question...
>
> lo Link encap:Local Loopback
> inet addr:127.0.0.1 Mask:255.255.255.0
> UP LOOPBACK RUNNING MTU:3904 Metric:1
> RX packets:203 errors:0 dropped:0 overruns:0 frame:0
> TX packets:203 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:0
> RX bytes:39674 (38.7 Kb) TX bytes:39674 (38.7 Kb)
>
> lo:1 Link encap:Local Loopback
> inet addr:127.1.0.1 Mask:255.255.255.0
> UP LOOPBACK RUNNING MTU:3904 Metric:1
>
> The following works:
>
> (term 1) elle:/home/bronson# nc -l -p 1000 127.1.0.1
> (term 2) bronson@elle:~$ nc 127.1.0.1 1000
>
> But this error baffles me:
>
> (term 1) elle:/home/bronson# nc -l -p 1000 127.1.0.1
> (term 2) bronson@elle:~$ nc 127.0.0.1 1000
> (term 1) invalid connection to [127.0.0.1] from (UNKNOWN) [127.0.0.1] 2254
>
> So, even though they're separate addresses and netmasks, they still
> conflict with each other somehow. Am I making a silly mistake here?
> Thanks,
>
> - Scott
...
Reply to: