Score:1

How to delete the grepped iptables

ar flag

I have iptables starting from cali-

 root@Ubuntu-18-VM:~# iptables -S | grep -oP '(?<!^:)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
    cali-to-host-endpoint
    cali-to-wl-dispatch
    cali-to-wl-dispatch-5
    cali-tw-cali2847b154969
    cali-tw-cali4bb24809f90
    cali-tw-cali531f8f2e712
    cali-tw-cali5a82b3ff301
    cali-wl-to-host

How can I delete these 31 iptables ? After grep what delete command shall I add so that iptables -S command didn't show the cali- iptables ?

us flag
You cannot do in simple way like this. IPTables refuses to delete a chain if some other chain references it. This means that you have to first verify that there are no jumps to a particular chain before deleting the chain.
Nikita Kipriyanov avatar
za flag
I'll extend that suggestion. Change grep expression for it to catch `-j cali-[\S]+` first. Remove those rules. Then there'll be no references to your said chains, so you'll be able to flush and then remove them.
Score:1
th 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.

Deleting calicoctl:

Simply run sudo rm $(which calicoctl) command, it will find and delete the calicoctl.

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.