I did a dumb thing, so bear with me.
While running a ufw command to add a rule, I did a Ctrl-C, this led to the problem of the following error being generated every time I try to use UFW:
ERROR: initcaps [Errno 2] iptables: Chain already exists. I have done a search and can't find anything on how to clean it up, but I did find this bug report at: ufw errors after ctr+c interupt
While I do see it has been confirmed, is there anything I can do to clean this up until it is fixed? Every time I try to add a rule I get that error.
Thanks in advance for any help provided.
Edit: BTW, I already tried saving the user.rules file, uninstalling UFW, reinstalling UFW, and moving the user.rules file back. I thought it might clean up iptables. No success.
2 Answers
This worked for me from here
sudo ufw disable sudo iptables -F sudo iptables -X sudo ip6tables -F sudo ip6tables -X sudo ufw enable I hope it is helpful to someone, one day.
2This is what I did to clean it up, if ufw is enabled, disable it. Then remove all of the ufw rules from iptables and ip6tables.
#! /usr/bin/env bash set -e set -o pipefail iptables --flush rules=($(iptables --list | grep Chain | grep -Eo "ufw-[a-z-]+" | xargs echo)) for i in "${rules[@]}" do iptables --delete-chain $i done ip6tables --flush rules6=($(ip6tables --list | grep Chain | grep -Eo "ufw6-[a-z-]+" | xargs echo)) for i in "${rules6[@]}" do ip6tables --delete-chain $i done 1