Getting my ip address

后端 未结 12 1169
走了就别回头了
走了就别回头了 2020-12-16 23:34

I have a computer on a small network, so my ip is 192.168.2.100.

I am trying to get my real ip. I download the no-ip client but that just seems like a lot of trouble

12条回答
  •  旧巷少年郎
    2020-12-17 00:15

    Your computer has no information on any NAT or routing that takes place between it and the internet except which hop is the next one (usually your router's internal ip). It simply doesn't know at which hop the internal address gets translated into which public address.

    Therefore there is no simple function or method you can call, in any language.

    The only two ways are to ask someone else. How?:

    • Ask your NAT router (because it itself does the translation to a public ip) by fetching and parsing the right page on your router's admin site. Arguably most reliable, and fair.
    • Ask an external host how it sees you, by fetching and parsing a public service such as http://dynamic.zoneedit.com/checkip.html. An example in VB script is here.

提交回复
热议问题