Firewall API¶
Firewall configuration classes.
FirewallConfig¶
FirewallConfig
¶
Bases: UCISection
Firewall configuration manager.
Source code in src/wrtkit/firewall.py
FirewallZone¶
FirewallZone
¶
Bases: UCISection
Represents a firewall zone configuration.
Source code in src/wrtkit/firewall.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
with_name(value)
¶
with_input(value)
¶
with_output(value)
¶
with_forward(value)
¶
with_masq(value)
¶
with_mtu_fix(value)
¶
with_network(network_name)
¶
Add a network to this zone (returns new copy).
with_networks(networks)
¶
with_default_policies(input_policy='ACCEPT', output_policy='ACCEPT', forward_policy='ACCEPT')
¶
Set default policies for the zone (returns new copy).
Source code in src/wrtkit/firewall.py
FirewallForwarding¶
FirewallForwarding
¶
Bases: UCISection
Represents a firewall forwarding rule.
Source code in src/wrtkit/firewall.py
with_src(value)
¶
Usage Example¶
from wrtkit import UCIConfig
from wrtkit.firewall import FirewallZone, FirewallForwarding
config = UCIConfig()
# Create a LAN zone
lan_zone = FirewallZone("lan")\
.with_name("lan")\
.with_input("ACCEPT")\
.with_output("ACCEPT")\
.with_forward("ACCEPT")\
.with_network("lan")
config.firewall.add_zone(lan_zone)
# Create a WAN zone
wan_zone = FirewallZone("wan")\
.with_name("wan")\
.with_input("REJECT")\
.with_masq(True)\
.with_mtu_fix(True)\
.with_network("wan")
config.firewall.add_zone(wan_zone)
# Create a forwarding rule
forwarding = FirewallForwarding("fwd_lan_wan")\
.with_src("lan")\
.with_dest("wan")
config.firewall.add_forwarding(forwarding)