views:

20

answers:

1

I have interfaces lo, eth0, and eth0:1.

progA creates a listen socket, and binds it to port p on INADDR_ANY.

Simultaneously, I would like to use ncat to port forward, listening on the same port p, but only on the IP address associated with eth0:1. As expected, ncat is failing with "address already in use".

What I would like to be able to do is: have progA bind its listen socket to the addresses associated with interfaces lo and eth0, but not to the address associated with eth0:1, leaving that address open for ncat to bind to.

Is there an alternative to INADDR_ANY that allows binding to multiple interfaces and/or multiple IP addresses?

+1  A: 

You need to separately bind to each of the individual interfaces using different sockets. Alternatively, you could write a program using libpcap to capture packets on eth0:1 and forward them. Packet capturing lets you observe an interface without actually binding to it.

John Kugelman