diff options
author | Nayana Bidari <nybidari@google.com> | 2020-02-18 11:30:42 -0800 |
---|---|---|
committer | Nayana Bidari <nybidari@google.com> | 2020-02-18 11:30:42 -0800 |
commit | b30b7f3422202232ad1c385a7ac0d775151fee2f (patch) | |
tree | 3b8de1ccfc8e6abbe7ccb5e35b3fc5832acad0ca /test/iptables/iptables_util.go | |
parent | fae3de21af7f50266565643c6283912b087b0f5a (diff) |
Add nat table support for iptables.
Add nat table support for Prerouting hook with Redirect option.
Add tests to check redirect of ports.
Diffstat (limited to 'test/iptables/iptables_util.go')
-rw-r--r-- | test/iptables/iptables_util.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/iptables/iptables_util.go b/test/iptables/iptables_util.go index 043114c78..5c9199abf 100644 --- a/test/iptables/iptables_util.go +++ b/test/iptables/iptables_util.go @@ -35,6 +35,16 @@ func filterTable(args ...string) error { return nil } +// natTable calls `iptables -t nat` with the given args. +func natTable(args ...string) error { + args = append([]string{"-t", "nat"}, args...) + cmd := exec.Command(iptablesBinary, args...) + if out, err := cmd.CombinedOutput(); err != nil { + return fmt.Errorf("error running iptables with args %v\nerror: %v\noutput: %s", args, err, string(out)) + } + return nil +} + // listenUDP listens on a UDP port and returns the value of net.Conn.Read() for // the first read on that port. func listenUDP(port int, timeout time.Duration) error { |