Monday, June 22, 2015

HOWTO : Flush IP Address From Network Interface On Ubuntu 14.04.2 LTS Server

I am running Croissants - Intrusion Detection and Prevention System on Ubuntu 14.04.2 LTS Server. Recently Ubuntu update kills the networking features that making no IP address interface to fetch IP address. Even making the interface in promiscuous mode still fetches IP address on that mode. That would drop the performance of the Croissants with more than one IP address with the same subnet in the same system. After try and error, the workaround is as the following.

sudo nano /etc/network/flush-ip

ip addr flush dev p2p1
ip addr flush dev p4p1
ip -6 addr flush dev p2p1
ip -6 addr flush dev p4p1

* where p2p1 and p4p1 are the incoming and outgoing interfaces for Croissants

sudo chmod +x /etc/network/flush-ip

Create a cron job to flush the ipv4 and ipv6 address on every 15 minutes interval :

sudo crontab -e

Append the following line to the file :

*/5 * * * * /etc/network/flush-ip

To double check the cron job entry :

sudo crontab -l

The interfaces should be looking like this :

The ipv4 and ipv6 addresses of p2p1 and p4p1 have been deleted.

That's all! See you.