Joel Bastos bio photo

Joel Bastos

Automation engineer with a keen interest on devops culture, geek by definition and curious by nature

Email Twitter LinkedIn Github
If you use Firestarter you know the huge bummer that is restarting your settings upon a change of the working interface.
Here's a little script I've made to automatically change the running network interfaces on the firewall. Enjoy ;)
Note: My interfaces are eth0 and wlan0, make the correct modifications to comply with your requirements.

#!/bin/sh

while true; do
INTERFACE=0

ifconfig eth0 |grep -q "inet addr"
if [ $? = 0 ];
then
sed -i 's/wlan0/\eth0/' /etc/firestarter/configuration
else
sed -i 's/eth0/\wlan0/' /etc/firestarter/configuration
INTERFACE=1
fi

iptables -L |grep -q DROP
if [ $? != 0 ];
then firestarter -s > /dev/null
if [ $INTERFACE = 0 ];
then
echo "$(date) -- firestarter running on eth0" >> /var/log/messages
else
echo "$(date) -- firestarter running on wlan0" >> /var/log/messages
fi
fi

sleep 5

done