Search code examples
c++network-programmingipgateway

Get gateway's IP address


Let I've an URL, for instance http://www.google.com/. I want to know all of gateway's IP addresses for package's path. Is it possible to do? If yes, please give me a pointing.


Solution

  • When you are outside of a local network (for example you are outside of google local network) then there is no such a thing like gateway IP of an IP. If you mean a default gateway, then read this for more info.

    As an outside host which needs to connect to google.com you just can convert that domain to an corresponding IP address. To do this, you can use gethostbyname.