delete from old interface before adding to new interface
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 10 Nov 2010 03:40:43 +0000 (14:40 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 10 Nov 2010 03:55:25 +0000 (14:55 +1100)
this stops the script from failing with an error if
both interfaces are specified as the same, which otherwise breaks and leads to an infinite recovery loop

config/events.d/10.interface

index c6b871f837c42145069942c2367bbf44b9e82e81..5b31fb81090e2e586f3dc745aac6e3cc814a8d98 100755 (executable)
@@ -244,14 +244,13 @@ case "$1" in
        iptables -D INPUT -i $oiface -d $ip -j DROP 2> /dev/null
        iptables -I INPUT -i $oiface -d $ip -j DROP
 
-       # we make sure the interface is up first
-       add_ip_to_iface $niface $ip $maskbits || {
+       delete_ip_from_iface $oiface $ip $maskbits || {
+               delete_ip_from_iface $niface $ip $maskbits
                iptables -D INPUT -i $oiface -d $ip -j DROP 2> /dev/null
                exit 1;
        }
 
-       delete_ip_from_iface $oiface $ip $maskbits || {
-               delete_ip_from_iface $niface $ip $maskbits
+       add_ip_to_iface $niface $ip $maskbits || {
                iptables -D INPUT -i $oiface -d $ip -j DROP 2> /dev/null
                exit 1;
        }