Two pf questions

David Mehler dave.mehler at
Tue Mar 28 17:54:24 UTC 2017


Thanks for your reply. Your first invocation of sort did it. To get
the final results I added the -n numeric option and it worked just

For reference my complete script is:

# Daily sort unique hits in both the fail2ban and bruteforce tables

# If there is a global system configuration file, suck it in.
if [ -r /etc/defaults/periodic.conf ]
    . /etc/defaults/periodic.conf

case "$daily_sorttable_enable" in
echo "Sorting unique entries in the fail2ban and bruteforce tables"
cp /etc/pf/bruteforce /tmp/foobar.txt
 pfctl -t bruteforce -T show >> /tmp/foobar.txt
 sort -u -n /tmp/foobar.txt > /etc/pf/bruteforce
cp /etc/pf/fail2ban /tmp/foobar1.txt
 pfctl -t fail2ban -T show >> /tmp/foobar1.txt
 sort -u -n /tmp/foobar1.txt > /etc/pf/fail2ban
echo "Removing temporary files"
rm /tmp/foobar.txt /tmp/foobar1.txt
echo "Restarting pf"
pfctl -f /etc/pf.conf

exit $rc

Any ideas on the nat reflection?


On 3/28/17, Ralf Mardorf via freebsd-questions
<freebsd-questions at> wrote:
> On Tue, 28 Mar 2017 11:35:01 +0200, Ralf Mardorf wrote:
>>On Tue, 28 Mar 2017 11:19:59 +0200, Ralf Mardorf via freebsd-questions
>>>cp /etc/pf/bruteforce /tmp/foobar.txt
>>>pfctl -t bruteforce -T show >> /tmp/foobar.txt
>>>sort -u /tmp/foobar.txt > /etc/pf/bruteforce
>>>>If so, the above example with "sort -u" still might be good.
>>>            ^^^^^^^^^^^^^
>>>            ^^^^^^^^^^^^^ the above with the cp to a backup file
>>>>in addition within a loop until the exit status $? of the last
>>>>command is 0, to ensure that /etc/pf/bruteforcen doesn't get lost, if
>>>>something should went wrong.
>>More clear, something similar to this:
>>cp /etc/pf/bruteforce /tmp/foobar.txt && \
>>pfctl -t bruteforce -T show >> /tmp/foobar.txt && \
>> sort -u /tmp/foobar.txt > /etc/pf/bruteforce
>> check_exit_status
> My apologies, it's not my day today ;).
> I don't know if the exit status available after
>   sort -u /tmp/foobar.txt > /etc/pf/bruteforce
> is from "sort" and/or ">", at least
>   sort -u /tmp/foobar.txt | tee /etc/pf/bruteforce
> ensures that it's the status returned from "tee", but I suspect ">"
> works, too.
> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list