Wednesday, May 7, 2008

Multiple IP addresses on FreeBSD on the same NIC

Sometimes you need more than one address aliased to a network interface on a server. for instance if you want to use ssl pages in apache
each ssl certificate should have its own IP address and each VirtualHost that runs on port 443 should have a unique IP address.
You can get around thins by changing the port from 443 to something like


vhost info


vhost info


But you are not using default ports and it might be a problem out in the real world sure you could do the above in side your own network

Anyway thats not what this is about this is to Alias other IP's to your NIC on your FreeBSD server

all you have to do is edit the /etc/rc.conf file
ifconfig_em0="inet media 100baseTX mediaopt full-duplex netmask"
ifconfig_em0_alias0=" netmask 0xffffffff"
ifconfig_em0_alias1=" netmask 0xffffffff"
ifconfig_em0_alias2=" netmask 0xffffffff"
ifconfig_em0_alias3=" netmask 0xffffffff"

Thats it.
The Netmask of 0xffffffff is fine you can use it as per the example

Now all you have to do is run /etc/netstart
and all the IP's and the server will respond.

This way you can also get your web server to Listen on one IP and if you have other services running like Mail and FTP they can all have their own IP address.

No comments:

Joe's Store