iptables

package
v1.4.2-0...-da62487 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Append Action = "-A"
	Delete Action = "-D"
	Insert Action = "-I"
	Nat    Table  = "nat"
	Filter Table  = "filter"
	Mangle Table  = "mangle"
)

Variables

View Source
var (
	ErrIptablesNotFound = errors.New("Iptables not found")
)

Functions

func Exists

func Exists(table Table, chain string, rule ...string) bool

Check if a rule exists

func Raw

func Raw(args ...string) ([]byte, error)

Call 'iptables' system command, passing supplied arguments

func RemoveExistingChain

func RemoveExistingChain(name string, table Table) error

Types

type Action

type Action string

type Chain

type Chain struct {
	Name   string
	Bridge string
	Table  Table
}

func NewChain

func NewChain(name, bridge string, table Table) (*Chain, error)

func (*Chain) Forward

func (c *Chain) Forward(action Action, ip net.IP, port int, proto, destAddr string, destPort int) error

Add forwarding rule to 'filter' table and corresponding nat rule to 'nat' table

func (c *Chain) Link(action Action, ip1, ip2 net.IP, port int, proto string) error

Add reciprocal ACCEPT rule for two supplied IP addresses. Traffic is allowed from ip1 to ip2 and vice-versa

func (*Chain) Output

func (c *Chain) Output(action Action, args ...string) error

Add linking rule to an OUTPUT chain

func (*Chain) Prerouting

func (c *Chain) Prerouting(action Action, args ...string) error

Add linking rule to nat/PREROUTING chain.

func (*Chain) Remove

func (c *Chain) Remove() error

type ChainError

type ChainError struct {
	Chain  string
	Output []byte
}

func (*ChainError) Error

func (e *ChainError) Error() string

type Table

type Table string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL