This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Adding static routes

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone think of an easy way to get my local IP Address for a specific network connection? I use several VPN's throughout the day, and when I sign on they change all my routes to send all traffic through them. So I run a batch file (I'm on Win 2K)with 2 lines like:
route change 0.0.0.0 MASK 0.0.0.0 222.22.2.2
(send all requests to my primary gateway)
route add 10.17.0.0 MASK 255.255.0.0 10.17.1.2
(only send requests to a 10.17 network through my VPN)
Well that's all fine and dandy except every time I sign on to the VPN I get a different address (10.17.1.2, 10.17.1.3 ...). I'd like to write a simple class to make the connection, get the IP Address assigned by that connection and then change the routes accordingly. I've tried java.net.InetAddress.getLocalHost() but that only returns my primary address. Is there any way to get an array of all the local IPs?
The only thing I can think of is to use Runtime to execute an ipconfig, and parse the results with a regex or something. Any ideas would be much appreciated.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do the following:
InetAddress.getAllByName(hostname);
You'll get an array of InetAddress objects which you can iterate over them
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic