Is the default gateway always the last line in the routing table of Redhat Linux 6 x86

I have multiple NICs on my Redhat 6 x86_64 server and as part of my script I have to determine which NIC is the default gateway on each server since there are lots of static routes over the other NICS. I always see the default gateway as the last line in the routing table but is that logic flawed and I just run net stat -rn | tail -1 | awk '{print $8}' but I'm not sure if that logic is up to par and I'm going to have to tally it up with what's in /etc/sysconfig/network as the gateway.
lolaferrariAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
The default gateway is the one with address 0.0.0.0 with netmask 0.0.0.0
And your milage in the order may vary..., netstat in my system show it as the first route....

ip route show  | grep default
or use:
ip route get 1.1.1.1  
(in stead of 1.1.1.1 you could use ANY public address.

The ip route get will get ANY route used for the address provided....
ip route get help give more info.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lolaferrariAuthor Commented:
Fabulous answer! That was an enormous help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.