Documentation
¶
Index ¶
- Constants
- Variables
- func AddJumpRule(fromChainName, toChainName, tableName string) error
- func AddRules(rules *Rules) error
- func ConfigureFirewall(oldInterface, newInterface, bridgeName string) error
- func CreateStandardFilterTable(conn *nftables.Conn) error
- func CreateStandardNATTable(conn *nftables.Conn) error
- func CreateTableFromConfig(conn *nftables.Conn, config TableConfig) error
- func EnsureStandardFirewallInfrastructure(conn *nftables.Conn) error
- func NewChain(opts ...Option) (*nftables.Chain, *nftables.Table, error)
- func RemoveRules(rules *Rules) error
- type ChainConfig
- type NewRule
- func ForwardOutboundRule(chainName, tableName, hostIf, internalIf string) NewRule
- func ForwardReturnTrafficRule(chainName, tableName, hostIf, internalIf string) NewRule
- func MasqueradeRule(chainName, tableName, interfaceName string) NewRule
- func PortRule(port uint16, proto, chainName, tableName string) NewRule
- type Option
- func Create() Option
- func WithChainType(chainType nftables.ChainType) Option
- func WithHook(hook *nftables.ChainHook) Option
- func WithName(chainName string) Option
- func WithPolicy(policy *nftables.ChainPolicy) Option
- func WithPriority(priority *nftables.ChainPriority) Option
- func WithinTable(tableName string) Option
- type Rules
- type TableConfig
Constants ¶
View Source
const ( FilterTable = "filter" NATTable = "nat" InputChain = "INPUT" ForwardChain = "FORWARD" OutputChain = "OUTPUT" PreroutingChain = "PREROUTING" PostRoutingChain = "POSTROUTING" )
Variables ¶
View Source
var ( StandardFilterTable = TableConfig{ Name: FilterTable, Family: nftables.TableFamilyINet, Chains: []ChainConfig{ { Name: InputChain, Table: FilterTable, Create: true, Type: &[]nftables.ChainType{nftables.ChainTypeFilter}[0], Hook: nftables.ChainHookInput, Priority: nftables.ChainPriorityFilter, Policy: getChainPolicyAccept(), }, { Name: ForwardChain, Table: FilterTable, Create: true, Type: &[]nftables.ChainType{nftables.ChainTypeFilter}[0], Hook: nftables.ChainHookForward, Priority: nftables.ChainPriorityFilter, Policy: getChainPolicyAccept(), }, { Name: OutputChain, Table: FilterTable, Create: true, Type: &[]nftables.ChainType{nftables.ChainTypeFilter}[0], Hook: nftables.ChainHookOutput, Priority: nftables.ChainPriorityFilter, Policy: getChainPolicyAccept(), }, }, } StandardNATTable = TableConfig{ Name: NATTable, Family: nftables.TableFamilyIPv4, Chains: []ChainConfig{ { Name: PreroutingChain, Table: NATTable, Create: true, Type: &[]nftables.ChainType{nftables.ChainTypeNAT}[0], Hook: nftables.ChainHookPrerouting, Priority: nftables.ChainPriorityNATDest, Policy: getChainPolicyAccept(), }, { Name: PostRoutingChain, Table: NATTable, Create: true, Type: &[]nftables.ChainType{nftables.ChainTypeNAT}[0], Hook: nftables.ChainHookPostrouting, Priority: nftables.ChainPriorityNATSource, Policy: getChainPolicyAccept(), }, }, } )
Predefined standard table configurations
Functions ¶
func AddJumpRule ¶
func ConfigureFirewall ¶
func CreateStandardFilterTable ¶
CreateStandardFilterTable creates the standard filter table with INPUT, FORWARD, OUTPUT chains
func CreateStandardNATTable ¶
CreateStandardNATTable creates the standard NAT table with PREROUTING, POSTROUTING chains
func CreateTableFromConfig ¶
func CreateTableFromConfig(conn *nftables.Conn, config TableConfig) error
CreateTableFromConfig creates a table and its chains based on the provided configuration
func EnsureStandardFirewallInfrastructure ¶
EnsureStandardFirewallInfrastructure creates both filter and NAT tables
func RemoveRules ¶
Types ¶
type ChainConfig ¶
type Option ¶
type Option func(*ChainConfig)
func WithChainType ¶
func WithPolicy ¶
func WithPolicy(policy *nftables.ChainPolicy) Option
func WithPriority ¶
func WithPriority(priority *nftables.ChainPriority) Option
func WithinTable ¶
type TableConfig ¶
type TableConfig struct {
Name string
Family nftables.TableFamily
Chains []ChainConfig // Now using the unified ChainConfig
}
TableConfig defines the configuration for a complete table
Click to show internal directories.
Click to hide internal directories.