title: Linux command for public ip address
body: <p>I want command to get Linux machine(amazon) <code>external</code>/<code>public</code> IP Address.</p>
  
  <p>I tried <code>hostname -I</code> and other commands from blogs and stackoverflow like </p>
  
  <pre><code>ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
  </code></pre>
  
  <p>and many more. But they all are giving me <code>internal</code> IP Address.</p>
  
  <p>Then I found some sites which provides API for this.</p>
  
  <p>Example : <code>curl http://ipecho.net/plain; echo</code></p>
  
  <p>But I don't want to rely on third party website service. So, is there any command line tool available to get <code>external</code> IP Address?</p>