{"id":838,"date":"2017-07-28T12:43:35","date_gmt":"2017-07-28T12:43:35","guid":{"rendered":"https:\/\/newdelhihosting.co.in\/blog\/?p=838"},"modified":"2024-10-22T10:51:55","modified_gmt":"2024-10-22T10:51:55","slug":"how-to-find-public-ip-address-on-linux","status":"publish","type":"post","link":"https:\/\/www.newdelhihosting.co.in\/blog\/how-to-find-public-ip-address-on-linux\/","title":{"rendered":"How  to find Public IP Address on Linux?"},"content":{"rendered":"<p>There are many ways to find public IP address on Linux.Here Step by Step instruction to find public ip on linux.<br \/>\n<strong>What is IP Address?<\/strong><\/p>\n<p>An IP address is used to identify devices.Each device is connected through an IP address.<\/p>\n<p><strong>Dig<\/strong> command is a network administrator command line tool for determining public IP address and for network troubleshooting. To find a public IP address, open your terminal application on Linux and enter the following command<\/p>\n<pre>$ dig +short myip.example.com @resolver1.example.com<\/pre>\n<p>The output will be like<\/p>\n<pre>11.11.11.11<\/pre>\n<p><strong>Find IP address using Host Command:-<\/strong><\/p>\n<pre>$ host myip.example.com resolver1.example.com<\/pre>\n<p>The output will be like as bellow<\/p>\n<pre>Using domain server:\r\nName: resolver1.example.com\r\nAddress: 11.11.11.11#50\r\nAliases: \r\n\r\nmyip.example.com has address 11.11.11.11\r\n......<\/pre>\n<p><strong>Find IP address using Google Server:-<\/strong><\/p>\n<pre>$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'\"' '{ print $2}'<\/pre>\n<p>The output will be like as bellow<\/p>\n<pre>11.34.111.11<\/pre>\n<p><strong>Store IP address in a shell variable:-<\/strong><br \/>\nThe bellow command is used to store the IP address in a shell variable<\/p>\n<pre>$ myip=\"$(dig +short myip.example.com @resolver1.example.com)\"\r\n$ echo \"My WAN\/Public IP address: ${myip}\"<\/pre>\n<p>The output will be like as bellow<\/p>\n<pre>My WAN\/Public IP address: 11.11.11.11<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways to find public IP address on Linux.Here Step by Step instruction to find public ip on linux. What is IP Address? An IP address is used to identify devices.Each device is connected through an IP address. Dig command is a network administrator command line tool for determining public IP address and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":844,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-838","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"jetpack_featured_media_url":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-content\/uploads\/2017\/07\/fe-publicip.jpg","_links":{"self":[{"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/posts\/838"}],"collection":[{"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/comments?post=838"}],"version-history":[{"count":5,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/posts\/838\/revisions"}],"predecessor-version":[{"id":845,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/posts\/838\/revisions\/845"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/media\/844"}],"wp:attachment":[{"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/media?parent=838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/categories?post=838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.newdelhihosting.co.in\/blog\/wp-json\/wp\/v2\/tags?post=838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}