Linux Routing Multiple IPs

I added some more IPs to a server today and it changed the default outgoing IP. Looking at route -n it became obvious that the gateway for the new IPs became the default gateway. This messed up a bunch of webservices that are stupidly tied to IP (not my fault) that I hadn't specified the outgoing IP in the config (ok, my fault).

Rather than fix my mistake which would've taken awhile, I fixed the routing table. First step is add back the old gateway if it's missing:

route add default gw 22.22.22.22

Verify it added by route -n and then delete the wrong route:

route del -net 0.0.0.0 gw 11.11.11.11

This got my IP back to the one listed for eth0 in ifconfig. If it hadn't worked (ie: used the IP on eth0:0 instead) then I would've used the new (relative to route) ip command from the iproute2 package. The Linux Advanced Routing & Traffic Control Howto has a ton of info and examples on using the iproute2 package. Here's an untested example:

ip route add default via 192.168.1.5 dev eth0 src 192.168.1.15