Routing for multi-homed public IP interfaces

Jasun -

Typically a Joyent VirtualMachine does not need more than one public interface.  You will have to request an additional public interface by contacting Joyent Support.

Public interfaces will be added on different subnets.  You will have to set routing rules so that packets are routed to appropriate gateways when you have multi-homed interfaces.  The following script can be updated and called from /etc/rc.local to set up the required routing:


NOTE: Do not place the script in your /etc/rc.local till you test it.  It is recommended that you test this script first by running it in a root shell on a test system.  The reason is that if your routing is not correct and you are unable to access your system. You can reboot the system from to regain access.



# first subnet with \## notation for gateway
# interface that the first subnet is on
# gateway for first subnet

# second subnet with \## notation for gateway
# interface that the second subnet is on
# gateway for second subnet

#Set up the first subnet's routing table (we'll name it 70)

/sbin/ip route flush table 70
/sbin/ip route add table 70 to $first_subnet dev $first_interface
/sbin/ip route add table 70 to default via $first_gateway dev $first_interface

#Set up the second subnet's routing table (we'll call it 80)

/sbin/ip route flush table 80
/sbin/ip route add table 80 to $second_subnet dev $second_interface
/sbin/ip route add table 80 to default via $second_gateway dev $second_interface

#Create the rules to choose what table to use. Choose based on source IP
#We need to give the rules different priorities; for convenience name priority
#after the table

/sbin/ip rule add from $first_subnet table 70 priority 70
/sbin/ip rule add from $second_subnet table 80 priority 80

#Flush the cache to make effective
/sbin/ip route flush cache

# Test new routes

ping -c 3 -I $first_interface

ping -c 3 -I $second_interface

Have more questions? Submit a request


Article is closed for comments.