At some point while working on a Salt formula to deploy pfring, I got to a point where I wanted to set promiscuous mode on an interface automatically. I wasn’t exactly sure how to go about it on RHEL/CentOS 7. So many things have changed so I set out to do a quick google search. I found my Google foo was not very strong and searched for several solutions. As you might expect, I wasn’t able to find a suitable solution very easily. I eventually came across an article on an arch Linux forum that lead me to my solution. I thought I would write a quick blog post so I don’t forget as there is one addition I made, which allows the service to be stopped as well.
On RedHat or CentOS 7 create a new service file at /usr/lib/systemd/system/netcfg@.service
Add in the following contents:
[Unit] Description=Control promiscuous mode for interface %i After=network.target [Service] Type=oneshot ExecStart=/sbin/ip link set %i promisc on ExecStop=/sbin/ip link set %i promisc off RemainAfterExit=yes [Install] WantedBy=multi-user.target
When you start or stop the service, pass in the name of the interface you want to enable/disable promiscuous mode on.
Turn on: systemctl start netcfg@eth1 Turn off: systemctl stop netcfg@eth1
Automatically enable at boot.
systemctl enable netcfg@eth1
REF: https://gist.github.com/awidegreen/6008629
REF: https://wiki.archlinux.org/index.php/Network_configuration