title: Change and sync hostname / ip address changes on debian linux
body: <p><strong>For changing static ip address</strong>, i set the contents of <code>/etc/network/interfaces</code> to</p>
  
  <pre><code>auto lo
  iface lo inet loopback
  
  allow-hotplug eth0
  iface eth0 inet static
  address &lt;newaddress&gt;
  netmask &lt;netmask&gt;
  gateway &lt;gateway&gt;
  dns-nameservers &lt;dns1&gt; &lt;dns2&gt;
  </code></pre>
  
  <p>then do <code>ifdown eth0 &amp;&amp; ifup eth0</code></p>
  
  <p><strong>For changing the hostname</strong>, i do the following actions</p>
  
  <p>execute <code>hostname &lt;newname&gt;</code></p>
  
  <p>set contents of <code>/etc/hostname</code> to <code>&lt;newname&gt;</code></p>
  
  <p>replace <code>&lt;oldname&gt;</code> with <code>&lt;newname&gt;</code> in <code>/etc/hosts</code></p>
  
  <p><strong>Issues</strong></p>
  
  <p>Both ip address and host name changes don't take effect.</p>
  
  <p>If I change the ip address and ping the hostname, it still resolves to the oldaddress</p>
  
  <p>If I change the hostname and ping the new hostname, it cannot resolve to an ip</p>
  
  <p>If I change the hostname and ping the old hostname, it is still available and resolved the current ip address.</p>
  
  <p>I restart the machine and it still behaves the same way.</p>
  
  <p>What am I missing?</p>
  
  <p>Could the parent network play any role in this?</p>
  
  <p>Also note that my machine thinks the hostname is updated after I change it.</p>