Created
August 25, 2022 07:39
-
-
Save santosh/293ac03b206b7df21d2faf46b34527c5 to your computer and use it in GitHub Desktop.
go-iptables examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
// if ipt, err := iptables.NewWithProtocol(iptables.ProtocolIPv4); err == nil { | |
// rule := []string{"-m", "ttl", "--ttl-eq", "1", "-p", "tcp", "-d", raddr.IP.String(), "--dport", fmt.Sprint(raddr.Port), "-j", "DROP"} | |
// if exists, err := ipt.Exists("filter", "OUTPUT", rule...); err == nil { | |
// if !exists { | |
// if err = ipt.Append("filter", "OUTPUT", rule...); err == nil { | |
// conn.iprule = rule | |
// conn.iptables = ipt | |
// } | |
// } | |
// } | |
// } | |
} | |
/* | |
Links: | |
https://github.com/Azure/azure-container-networking/blob/877970022a66b3d402d08aee0afd3089d9f617a2/cns/restserver/internalapi_linux.go | |
https://github.com/yunionio/cloudpods/blob/84cdeff92b0ec64642e202d5fbd4e7c892427ba8/pkg/lbagent/ovn.go#L446 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment