title: How to find network interface name
body: <p>I have a bash script that runs on a variety of different Ubuntu Linux machines. Its job is to find out the LAN IPv4 address of the localhost.</p>
  
  <p>The script is using </p>
  
  <pre><code>ip addr show eth0 | sed -n '/inet /{s/^.*inet \([0-9.]\+\).*$/\1/;p}'
  </code></pre>
  
  <p>which is fine, but some machines for some reason use eth1 instead of eth0. I would like to be able to discover the LAN iface name, so I can substitute it in here instead of eth0.</p>
  
  <p>Of course, if you can come up with a different oneliner that does the same thing, all good.</p>