coreos / go-iptables

Go wrapper around iptables utility
Apache License 2.0
1.11k stars 257 forks source link

feat: add DeleteById function #112

Closed Adam0Brien closed 2 months ago

Adam0Brien commented 1 year ago

Fix: #97 feat: users now have the option to delete a specific rule.

Rule numbers can be found by using the following command: sudo iptables -t nat -L PREROUTING -n --line-number

Example usage:


        table := "nat"
    chain := "PREROUTING"
    ruleIDToDelete := 2

    // Use the DeleteById function to delete the rule.
    result, err := iptables.DeleteById(table, chain, ruleIDToDelete)
    if err != nil {
        fmt.Printf("Error: %v\n", err)
    } else {
        fmt.Println(result)
    }