Question

I am trying to find a way that I can effectively change the IP and netmask of the computer that my programs are running on. I have to be able to maintain communications with a "box" that the user has access to and can change the IP of that box (but not that of the Linux host). Luckily the box broadcasts its IP over a multicast address. I am able to read that address and communicate to whatever IP the box is broadcasting. However, my problem is that when the box changes IPs outside of the subnet of the Linux host, I lose connectivity (as I would expect to happen).

As a result, I need a quick and dirty way to to change the IP and netmask of the Linux host when it detects that the IP being broadcast is outside it's subnet. I am aware that I can modify/edit the /etc/networking/interfaces file, but I was hoping to have something "live" where I wouldn't need to restart the networking interface or Linux host. Additionally, I would like to maintain all sockets that I have currently open during the change. My main issue is that I have a slew of connections run by other applications that cannot be corrupted as a result of the IP changeover. Also, if possible, I'd like to avoid having to redo having to run the multicast route add command for Linux after the host IP changeover.

Is there anything that I can do to satisfy these requirements? Thanks.

Was it helpful?

Solution

You don't want to change the IP address of the interface, you want to add an additional IP address and subnet to the interface. Search your Linux system documentation for IP Alias functionality.

Here's the HOWTO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top