How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway’s IP?
This is somewhat easy in .NET if you know your way around. But how do you do it in Java?
Java doesn’t make this as pleasant as other languages, unfortunately. Here’s what I did:
This presumes that the gateway is the second token and not the third. If it is, you need to add an extra
st.nextToken();to advance the tokenizer one more spot.