2009-08-13

Extract DHCP dynamic IP

A previous article has explained how to extract static IP using a batch. But if your computer has a dynamic IP assigned by DHCP server, how can you get your IP? ipconfig? let's see.



Look! You just got an useless local IP 192.168.x.x.
  • Where is your current WAN IP? Click here. Now you got a your real IP, at right now.
  • Why this happens? See the explanation here. The reason is your router. It determines the IP in WAN, but you or your code can only get it a LAN IP from it.
  • How let your script get the WAN IP? Try this! "curl http://whatismyip.com/automation/n09230945NL.asp". Of course, you need to install the curl at first.
  • How to let your code get WAN IP? Use libcurl.

No comments:

Post a Comment