<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Nils Pascal Illenseer</title><link href="https://illenseer.eu/" rel="alternate"></link><link href="https://illenseer.eu/feeds/all.atom.xml/feeds/all.atom.xml" rel="self"></link><id>https://illenseer.eu/</id><updated>2013-03-12T00:30:00+01:00</updated><entry><title>I want my secondary IP addresses back…</title><link href="https://illenseer.eu/articles/i-want-my-secondary-ip-addresses-back/" rel="alternate"></link><published>2013-03-12T00:30:00+01:00</published><updated>2013-03-12T00:30:00+01:00</updated><author><name>Nils Pascal Illenseer</name></author><id>tag:illenseer.eu,2013-03-12:/articles/i-want-my-secondary-ip-addresses-back/</id><summary type="html">&lt;p&gt;…or better, they should not disappear at all.&lt;/p&gt;
&lt;p&gt;If you use more than one IP address in the same CIDR network on your Linux box, you may have noticed, that some addresses are labeled as ‘secondary’.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;inet 10.10.60.2/16 brd 10.10.255.255 scope global eth0 …&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;…or better, they should not disappear at all.&lt;/p&gt;
&lt;p&gt;If you use more than one IP address in the same CIDR network on your Linux box, you may have noticed, that some addresses are labeled as ‘secondary’.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;inet 10.10.60.2/16 brd 10.10.255.255 scope global eth0
inet 10.10.60.20/16 scope global secondary eth0
inet 10.10.60.21/16 scope global secondary eth0
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Outgoing traffic is routed through the primary IP address and the secondaries are ready to receive traffic. But if you remove the primary IP address &lt;code&gt;10.10.60.2&lt;/code&gt;, all secondary addresses are purged by default as well. This behavior is a little bit annoying and for most of us unexpected.&lt;/p&gt;
&lt;p&gt;One workaround would be to change the netmask to &lt;code&gt;/32&lt;/code&gt; for the secondary addresses, but that's just a workaround and will leave you with a somewhat unclean network setup.&lt;/p&gt;
&lt;p&gt;It is better to reconfigure your kernel (since ~2.6.12) to promote secondaries, if a primary address is removed. Just do&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/conf/all/promote_secondaries
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;or&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sysctl net.ipv4.conf.all.promote_secondaries=1
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;and on all devices secondaries get promoted, you can also promote only on a specific device  e.g. &lt;code&gt;eth0&lt;/code&gt; instead of &lt;code&gt;all&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To change this persistently add the following file&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;# /etc/sysctl.d/10-network-promote_secondaries.conf
net.ipv4.conf.all.promote_secondaries=1
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;or if you do not have a &lt;code&gt;/etc/sysctl.d&lt;/code&gt; directory, just add the line to your &lt;code&gt;/etc/sysctl.conf&lt;/code&gt;.&lt;/p&gt;</content><category term="IP"></category><category term="address"></category><category term="primary"></category><category term="secondary"></category><category term="network"></category></entry></feed>