Howto Configure Extra IPs (on any distribution)

From Unixshell# community wiki

Jump to: navigation, search

Create a script like the one below and have your system run it upon startup - I use Slackware and call the script from rc.local.

#!/bin/bash
#setting up IP alias interfaces
echo "Setting IP Aliases ..."
/sbin/ifconfig eth0:0 xxx.xxx.xxx.xxx
/sbin/ifconfig eth0:1 xxx.xxx.xxx.xxx
/sbin/ifconfig eth0:2 xxx.xxx.xxx.xxx
/sbin/ifconfig eth0:3 xxx.xxx.xxx.xxx
/sbin/ifconfig eth0:4 xxx.xxx.xxx.xxx
#setting up the routes
echo "Setting IP routes ..."
/sbin/route add -host xxx.xxx.xxx.xxx eth0:0
/sbin/route add -host xxx.xxx.xxx.xxx eth0:1
/sbin/route add -host xxx.xxx.xxx.xxx eth0:2
/sbin/route add -host xxx.xxx.xxx.xxx eth0:3
/sbin/route add -host xxx.xxx.xxx.xxx eth0:4


Note: it seems that you must restart your VPS after a new IP address is added to your plan, otherwise the new IP address won't work.

Personal tools