Score:2

how to delete the grepped iptables

np flag

I am trying to delete all iptables created by calico in my k3s setup. I am using calico-script to delete but after running this script some cali- iptables I can see in iptables -S output, I want to delete them all

I can see iptables with cali- under iptables -S

 root@Ubuntu-18-VM:~# iptables -S  | grep -e 'cali-'
    cali-FORWARD
    cali-INPUT
    cali-OUTPUT
    cali-cidr-block
    cali-from-hep-forward
    cali-from-host-endpoint
    cali-from-wl-dispatch
    cali-from-wl-dispatch-5
    cali-fw-cali2847b154969
    cali-fw-cali4bb24809f90
    cali-fw-cali531f8f2e712
    cali-fw-cali5a82b3ff301
    cali-pri-_CVSZITRyIpEmH8AB6H
    cali-pri-_HayIXLB85hzHkIhWER
    cali-pri-_PTRGc0U-L5Kz7V6ERW
    cali-pri-_u2Tn2rSoAPffvE7JO6
    cali-pri-kns.kube-system
    cali-pro-_CVSZITRyIpEmH8AB6H
    cali-pro-_HayIXLB85hzHkIhWER
    cali-pro-_PTRGc0U-L5Kz7V6ERW
    cali-pro-_u2Tn2rSoAPffvE7JO6
    cali-pro-kns.kube-system
    cali-to-hep-forward

How can I delete these iptables after grepping so that in iptables -S all these doesn't come ?

pLumo avatar
in flag
I guess some of these are chains instead of rules. Can you edit your question and leave out the `-o` of `grep` and paste the result ?
pLumo avatar
in flag
Anyways, this is somehow a strange question. Why do you need this automated, can't you do it manually? You should maybe give us some surrounding information as why you need this to not trap into the [XY Problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem).
solveit avatar
np flag
Manually you mean one by one ? it will be difficult to delete though.
Score:2
in flag

Deleting calico-Iptables:

Use calico-policy and add below lines at the end of script:

echo "Flush remaining calico iptables"
iptables-save | grep -i cali | iptables -F

echo "Delete remaining calico iptables"
iptables-save | grep -i cali | iptables -X

This will delete all calico iptables when you check with iptables -S

Note: Run this script only after uninstalling K3S otherwise calico will keep on creating the iptables.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.