{"id":19,"date":"2017-03-08T20:07:37","date_gmt":"2017-03-08T19:07:37","guid":{"rendered":"http:\/\/www.tomvst.be\/blog\/?p=19"},"modified":"2017-03-08T20:07:37","modified_gmt":"2017-03-08T19:07:37","slug":"dhcp-and-static-ip-on-a-single-interface-static-ip-disappears","status":"publish","type":"post","link":"https:\/\/www.tomvst.net\/blog\/2017\/03\/dhcp-and-static-ip-on-a-single-interface-static-ip-disappears\/","title":{"rendered":"DHCP and static IP on a single interface: static IP disappears"},"content":{"rendered":"<p>I recently migrated my Ubuntu Server to an OpenStack environment.\u00a0I needed two different IP-addresses, and it seemed me wise to keep the first (primary) IP-address assigned by DHCP, and then the second one static.<\/p>\n<p>&nbsp;<\/p>\n<p>Due to apparent OpenStack restrictions at my current provider, the easiest way was to assign both IP-addresses to the same adapter. As such, I configured them as follows (\/etc\/network\/interfaces):<\/p>\n<pre>auto eth0\r\niface eth0 inet dhcp\r\n\r\niface eth0 inet static\r\n address &lt;IP-address&gt;\r\n netmask 255.255.255.0\r\n broadcast &lt;broadcast address&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>That seemed to work all fine, and <strong>ip address show<\/strong>\u00a0properly displayed both addresses. Both could be used by Apache, Postfix,&#8230;<\/p>\n<p>&nbsp;<br \/>\nHowever, after irregular intervals, my webserver seemed to get disconnected. Rebooting the machine solved the issue until the next occurence. Restarting Apache, MySQL,&#8230; didn&#8217;t seem to help however, so they weren&#8217;t the culprit. Restarting only the network interface(s) however did the trick, so it had to do with the network setup. The static IP address seemed to disappear from the adapter, it wasn&#8217;t showing up anymore at all.<\/p>\n<p>&nbsp;<\/p>\n<p>The problem was lying with the DHCP Client, who seemed to reconfigure the interface at certain times, getting rid of the static IP address.<\/p>\n<p>&nbsp;<\/p>\n<p>As suggested by some forums, I added an alias section to my dhclient.conf (in \/etc\/dhcp\/). This however produced issues upon restarting the network interfaces:\u00a0<strong>ifup[2309]: RTNETLINK answers: File exists<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>The solution was to configure my setup as follows (note the things in bold):<\/p>\n<pre>auto eth0 <strong>eth0:0<\/strong>\r\niface eth0 inet dhcp\r\n\r\niface <strong>eth0:0<\/strong> inet static\r\n address &lt;IP-address&gt;\r\n netmask 255.255.255.0\r\n broadcast &lt;broadcast address&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>This actually solved the problem, without struggling with OpenStack, the DHCP client or having to reconfigure my Apache, Postfix, etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently migrated my Ubuntu Server to an OpenStack environment.\u00a0I needed two different IP-addresses, and it seemed me wise to keep the first (primary) IP-address&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-networking","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":5,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":24,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/posts\/19\/revisions\/24"}],"wp:attachment":[{"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tomvst.net\/blog\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}