Script not working after 2.2.x upgrade



  • This is a script to reset states on a specific alias and it used to work under 2.1.x. When I went to 2.2.x it gives an error. Here it is:

    for i in pfctl -t ALIAS -Ts
    do
            echo "Killing states from/to $i"
            pfctl -k $i
    done

    Any ideas?



  • Probably not until you tell us what the error message actually says…...



  • https://doc.pfsense.org/index.php/How_can_I_see_the_full_PF_ruleset
    So … pfctl -sa : I have these tables:

    TABLES:
    APx
    DVR
    DiskStation
    PowerEdge
    bogons
    bogonsv6
    snort2c
    sshlockout
    virusprot
    webConfiguratorlockout

    This works for me :

    pfctl -t APx -Ts
       192.168.2.2
       192.168.2.3
       192.168.2.4
       192.168.2.5
    
    

    because I have a table named 'APx'.

    I created a script file named test.sh:

    #!/bin/sh
    for i in `pfctl -t APx -Ts`
    do
            echo "Killing $i"
            pfctl -k $i
    done
    
    

    (+ chmod +x test.sh)
    and it worked :

    sh test.sh
    Killing 192.168.2.2
    killed 0 states from 1 sources and 0 destinations
    Killing 192.168.2.3
    killed 0 states from 1 sources and 0 destinations
    Killing 192.168.2.4
    killed 0 states from 1 sources and 0 destinations
    Killing 192.168.2.5
    killed 0 states from 1 sources and 0 destinations
    
    

    So, what is it that you didn't tell us ;)



  • You're right, I did it again and it worked this time. weird.
    I think it might have been because I left off the #!/bin/sh, don't know.