I’m doing some computer network homework and I’m supposed to develop some sort of Peer to Peer file sharing software, and when I wanna test it I need to run a few (5) instances on my linux/ubuntnu 11.10 . which means each one need to has a unique IP address. I heard I can do that but I dunno how. how can I have many IP addresses on a single computer? thanks
I’m doing some computer network homework and I’m supposed to develop some sort of
Share
I think you are talking about two different problems:
How to assign multiple IP addresses to a single machine? That is possible, that is a standard functionality of any modern operating system. And that is also off-topic on StackOverflow. In Linux the way to persistently configure it can be very distribution-specific.
ip addr add $IP_ADDRESS dev $INTERFACEis the general way, but won’t survive a reboot or network reconfiguration.How to allow an application instance use a selected one of the machine addresses? That is quite easy – you must bind your server socket to an address. Usually you will only provide a port number (the IP address set to
INADDR_ANYfor the standard C IPv4 socket API), but you can use any IP address on the machine there. Details depend on the API you are using.