- Blog
- Howtos
- anything generator
- apache
- asterisk
- autofs
- autoload
- automount
- backup db
- callcentric
- centos
- chumby
- cipher list
- cookies
- ctags
- dns
- dovecot
- glue fleece
- hacking
- httpd
- IE
- iFrame
- ip
- ispconfig
- javascript
- lighttpd
- linux
- media player
- move networks
- mysql
- mysqldiff
- mythtv
- Network Solutions
- openssl
- osx
- os x
- P3P Compact Policy
- php
- postfix
- proftpd
- proxy
- python
- route
- ruby
- screen scraping
- shell
- shell scripts
- slapd
- smb
- ssh
- sshfs
- SSLCertificateChainFile
- sslv2
- stunnel
- suphp
- taglist
- telnet
- trace
- verisign
- vi
- vsftpd
- Scripts
- About
Linux Routing Multiple IPs
Submitted by adam on Tue, 2009-01-20 13:18.
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
