Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a linux box with two IP addresses (say IP1, and IP2).

I have a server-process listening to a specific port (say 60000). Now, I want to run two copies of the server-process on the above linux box. How can I set up my system such that I can have process1 handle packets to IP1:60000 and have process2 handle packets to IP2:60000?

Or can I?

share|improve this question

Generally most daemons will have an option in the config to control which IP address and Port pair it will bind or listen on (see man 2 bind for the nitty-gritty C system call level details).

After you have changed the configuration and restarted the daemon, you can see what it is bound to using the netstat -ln command. Example output will be something like:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0    *               LISTEN means all IPs and the :22 means it is listening destination TCP port 22. The second column* means accepts all source IPs and source ports.

In your case you should see one row that has a local address like and another row with a local address like

If you there doesn't seem to be an option in the configuration file, it might be a command line switch for the daemon itself. In that case you might need to edit the start up file in /etc/init.d/whatever. This is usually not the case however.

share|improve this answer
But the process will still have the port bound on both IPs, and the second instance won't be able to bind the same port. – mfinni Mar 15 '11 at 14:37
@mfinni: Oh didn't read that quite right. Ya, iptables won't help. – Kyle Brandt Mar 15 '11 at 14:40

The process itself is generally in control of the IP addresses it listens on. For example, in Apache, you set up the listening IP in the <VirtualHosts> directive.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.