{"id":396,"date":"2012-11-29T00:38:05","date_gmt":"2012-11-28T19:38:05","guid":{"rendered":"http:\/\/kennywu.info\/?p=396"},"modified":"2013-02-01T08:59:12","modified_gmt":"2013-02-01T03:59:12","slug":"how-to-find-my-external-ip-address","status":"publish","type":"post","link":"http:\/\/kennywu.info\/?p=396","title":{"rendered":"How to find my external IP address"},"content":{"rendered":"<p>If you computers are sitting behind a router\/firewall, then running Ipconfig would not give you the external IP address. One can use http:\/\/www.whatsmyip.org\/ for ad-hoc queries, but if you want to automate the checks you might want something simpler and easier to parse. The followings are the options I found.<\/p>\n<ul>\n<li><a href=\"http:\/\/automation.whatismyip.com\/n09230945.asp\" title=\"http:\/\/automation.whatismyip.com\/n09230945.asp\" target=\"_blank\">http:\/\/automation.whatismyip.com\/n09230945.asp<\/a><br \/>This is the page they specifically provided for automation and the good thing is you do not have to worry about parsing.<\/li>\n<li><a href=\"http:\/\/checkip.dyndns.com\" title=\"checkip.dyndns.com\" target=\"_blank\"> http:\/\/checkip.dyndns.com<\/a><br \/>The return that they give back to you is short and easy to work with.<\/li>\n<li><a href=\"http:\/\/www.domaintools.com\/research\/my-ip\/myip.xml\" title=\"http:\/\/www.domaintools.com\/research\/my-ip\/myip.xml\" target=\"_blank\">http:\/\/www.domaintools.com\/research\/my-ip\/myip.xml<\/a><br \/>The most comprehensive one, it gives you all the network related info in XML format.<\/li>\n<\/ul>\n<p>The c# code to find out your external IP:<\/p>\n<pre lang=\"csharp\">\r\npublic string GetPublicIP() {\r\n    String direction = \"\";\r\n    WebRequest request = WebRequest.Create(\"http:\/\/checkip.dyndns.org\/\");\r\n    using (WebResponse response = request.GetResponse())\r\n    using (StreamReader stream = new StreamReader(response.GetResponseStream())) {\r\n        direction = stream.ReadToEnd();\r\n    }\r\n\r\n    \/\/Search for the ip in the html\r\n    int first = direction.IndexOf(\"Address: \") + 9;\r\n    int last = direction.LastIndexOf(\"<\/body>\");\r\n    direction = direction.Substring(first, last - first);\r\n\r\n    return direction;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you computers are sitting behind a router\/firewall, then running Ipconfig would not give you the external IP address. One can use http:\/\/www.whatsmyip.org\/ for ad-hoc queries, but if you want to automate the checks you might want something simpler and &hellip; <a href=\"http:\/\/kennywu.info\/?p=396\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[83],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-internet","tag-ip-address"],"_links":{"self":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396"}],"version-history":[{"count":8,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":405,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/396\/revisions\/405"}],"wp:attachment":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}