set default route for virtual IP address

Is there a way to set a default route for a virtual IP on a linux box?
mw-hostingAsked:
Who is Participating?
 
The--CaptainConnect With a Mentor Commented:
None of the above is going to work, unless of course you are talking about adding the *same* gateway to your virtual IP, which would make no sense (because it's completely unecessary).  

If you want to use a *different* gateway for your virtual IP (which is the only thing that makes sense), you need to implement policy routing to use a different default route based upon your source IP.

Something like this:

ip route add ExternalNet/ExternalCIDR dev eth0 src MyVirtualIP table MyNewTable
ip route add default via MyNewDefaultGw table MyNewTable
ip route add 127.0.0.0/8 dev lo table MyNewTable
ip rule add from MyVirtualIP table MyNewTable

That might not be exactly it, but you get the idea...

Cheers,
-Jon
0
 
avilovCommented:
did you try to specify
GATEWAY=

in ifcfg.ethx.y?  (x is a yor phisical interface where virtual IP is configured and y is VLAN # for that virtual IP)
0
 
mccrackyCommented:
If you tell us how you set the virtual IP it would help us answer your question.  If you are using the sysconfig files, you just need to put in the GATEWAY parameter like mentioned above.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mw-hostingAuthor Commented:
I did it via Webmin.
0
 
avilovCommented:
if you can telnet/ssh to that server. the file you need to change is in


/etc/sysconfig/network-scripts  

directory

the file name will be like ifcfg.ethx.y?  (x is a yor phisical interface where virtual IP is configured and y is VLAN # for that virtual IP)
0
 
mccrackyCommented:
in webmin is there a place to set the Gateway?
0
 
mw-hostingAuthor Commented:
Just netmask, broadcast, MTU.
0
 
The--CaptainCommented:
Thanks for the recognition.  Linux rules in so many ways, but the main reason I love it is because it is so flexible - it can do almost *anything* as far as networking is concerned (and far more than any other OS or IOS of which I know) if you just know how to configure it (and tcpdump, strace, and gdb are at the ready to diagnose anything the logs won't tell you ;-)

In any case, I'm glad to see you using linux as a router - too few people do <cisco rant deleted>

-Jon
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.