Determining Host Default Route Based Upon IP Address

B

Brian Mac

hi all,

i'm in the early stages of developing a cross-platform utility to
allow end users of an in-house application to diagnose 'application'
issues. one aspect i'm trying to account for is network problems and
this is where i'm running into some issues...

i know how to find ip address information and display routing tables
on windows and various flavors of unix. i can display the ip address
easily enough using pure ruby but i'm really struggling finding a
super clean way to determine the default route based upon current ip
address. basically i'm thinking of:

1. getting host's ip address
2. getting subnet mask
3. creating array of all default routes
4. iterating thru array of default routes to find default route for
current ip and returning that value

i would love to hear if i'm taking the way-wrong road to get to where
i want to go. any help is greatly appreciated.

thanks!
brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top