Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

With ifconfig, I am able to configure multiple IP addresses on a single network interface card. Why would I want to do that and how would I later utilize several addresses, e.g. how does software know which one to use?

I have only used network interfaces with a single IP address so far.

share|improve this question

3 Answers 3

up vote 12 down vote accepted

Some (but not all) reasons:

  • In order to host multiple SSL sites as already mentioned
  • Because you may be consolidating services from multiple hosts and you need to preserve the addresses
  • In order to use an IP address that can later be transferred to another host
  • To compensate for a host that's down at that moment by adding its IP address to another one
  • If you have multiple IP networks on the same physical/logical network/vlan it will prevent traffic from being exchanged via the gateway, speeding things up and reducing the load
  • In order to setup a device that has a default IP address and thus you need to add an address on the same network
  • In order to use different public IP addresses to avoid firewalls or to avoid being blacklisted in SPAM filters
  • In order to make things less obvious to external people. E.g. you may be running apache on IP address 1.2.3.4 and only allow SSH on 1.2.3.5. That way if someone attempts to attack the IP address behind a site he won't find SSH running.
  • In order to run the same service multiple times
  • In order to use different hostnames in reverse DNS lookups. E.g. if you're connecting from this hosts to something external and you want to be presented as two different domain/hostnames
  • In order not to expose commonality between services. E.g. if you host site1.example.com and site2.example.org and you map them on different IPs instead of using CNAMEs there won't be an obvious link between them
share|improve this answer

In the case of a web server it depends. If you have multiple virtual hosts then in apache for example, the server knows which IP to use from the VirtualHost block.

 <VirtualHost 10.10.10.1:80>
   ...
 </VirtualHost>

You can also have a VirtualHost listen on all available interfaces which apache is currtenly listening on (via the Listen directive eg. Listen *:80

 <VirtualHost *:80>
   ...
 </VirtualHost>

In the event you have multiple sites running on a server where multiple sites are SSL enabled. It is good to have a seperate IP for each site. This is because SSL certificates are exchanged before the HTTP headers are sent. If you have multiple vhosts on one IP then apache will not know which site you are trying to reach without the host header.

I'm sure there are many other use cases, this is a common one.

share|improve this answer
    
You forgot that SSL doesn't matter anymore and there is a way to overcome the limitation in TLS ;) –  0xC0000022L May 3 at 22:26

It's good idea to have separate ip for separate services, then when you'll have to migrate one of service to another hardware/location, there will be transparent for other components.

Some services use the same port number, then you have to have several ips to run this services on single server.

Also if you want to handle more simultanous connections than you have ephemeral port, you'll need more ip.

share|improve this answer
    
If I'm running a web server, how does it know which IP address to use? Does it install to use the main IP by default? –  Nickolai Leschov May 3 at 21:03
2  
It's configurable. By default it Listen or Binds to every IP on host. –  fazie May 3 at 21:06

Your Answer

 
discard

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.