]> git.proxmox.com Git - pve-firewall.git/blame_incremental - README
generate_group_rules : fix check of security group
[pve-firewall.git] / README
... / ...
CommitLineData
1Experimental software, only used for testing!
2=============================================
3
4
5Quick Intro
6===========
7
8VM firewall rules are read from /etc/pve/firewall/<VMID>.fw
9
10Security group rules are read from /etc/pve/firewall/groups.fw
11
12Host firewall rules are read from /etc/pve/local/host.fw
13
14You can find examples in the example/ dir
15
16
17Use the following command to mange the firewall:
18
19To test the firewall configuration:
20
21./pvefw compile
22
23To start or update the firewall:
24
25./pvefw start
26
27To update the firewall rules (the firewall is not started if it
28is not already running):
29
30./pvefw update
31
32To stop the firewall:
33
34./pvefw stop
35
36
37Implementation details
38======================
39
40We write iptables rules directly, an generate the following chains
41as entry points in the 'forward' table:
42
43PVEFW-INPUT
44PVEFW-OUTPUT
45PVEFW-FORWARD
46
47We do not touch other (user defined) chains.
48
49Each VM can have its own firewall definition file in
50
51/etc/pve/firewall/<VMID>.fw
52
53That file has a section [RULES] to define firewall rules.
54
55Format is: TYPE ACTION IFACE SOURCE DEST PROTO D-PORT S-PORT
56
57* TYPE: IN|OUT|GROUP
58* ACTION: action or macro
59* IFACE: vm network interface (net0 - net5), or '-' for all interfaces
60* SOURCE: source IP address, or '-' for any source
61* DEST: dest IP address, or '-' for any destination address
62* PROTO: see /etc/protocols
63* D-PORT: destination port
64* S-PORT: source port
65
66A rule for inbound traffic looks like this:
67
68IN SSH(ACCEPT) net0
69
70Outbound rules looks like:
71
72OUT SSH(ACCEPT)
73
74Problems
75===================
76
77There are a number of restrictions when using iptables to filter
78bridged traffic. The physdev match feature does not work correctly
79when traffic is routed from host to bridge:
80
81 * when a packet being sent through a bridge entered the firewall on another interface
82 and was being forwarded to the bridge.
83
84 * when a packet originating on the firewall itself is being sent through a bridge.
85
86So we disable the firewall if we detect such case (bridge with assigned IP address).
87You can enable it again (if you do not care) by setting "allow_bridge_route: 1" in "host.fw".
88
89The correct workaround is to remove the IP address from the bridge device, and
90use a veth device which is plugged into the bridge:
91
92---/etc/network/interfaces----
93
94...
95
96auto vmbr0
97iface vmbr0 inet manual
98 bridge_ports bond0
99 bridge_stp off
100 bridge_fd 0
101
102# this create the veth device and plug it into vmbr0
103auto pm0
104iface pm0 inet static
105 address 192.168.10.10
106 netmask 255.255.255.0
107 gateway 192.168.10.1
108 VETH_BRIDGETO vmbr0
109
110auto vmbr1
111iface vmbr1 inet manual
112 bridge_ports none
113 bridge_stp off
114 bridge_fd 0
115
116# setup masqueraded bridge port vmbr1/pm1 using pm0
117# NOTE: this needs kernel 3.10.0 or newer (for conntrack --zone)
118auto pm1
119iface pm1 inet static
120 address 10.10.10.1
121 netmask 255.255.255.0
122 VETH_BRIDGETO vmbr1
123 VETH_MASQUERADE pm0
124
125...
126
127--------------------------------
128