]>
Commit | Line | Data |
---|---|---|
1 | ifdef::manvolnum[] | |
2 | PVE({manvolnum}) | |
3 | ================ | |
4 | include::attributes.txt[] | |
5 | ||
6 | NAME | |
7 | ---- | |
8 | ||
9 | pve-firewall - The PVE Firewall Daemon | |
10 | ||
11 | ||
12 | SYNOPSYS | |
13 | -------- | |
14 | ||
15 | include::pve-firewall.8-synopsis.adoc[] | |
16 | ||
17 | ||
18 | DESCRIPTION | |
19 | ----------- | |
20 | endif::manvolnum[] | |
21 | ||
22 | ifndef::manvolnum[] | |
23 | {pve} Firewall | |
24 | ============== | |
25 | include::attributes.txt[] | |
26 | endif::manvolnum[] | |
27 | ||
28 | // Copied from pve wiki: Revision as of 08:45, 9 November 2015 | |
29 | ||
30 | Proxmox VE Firewall provides an easy way to protect your IT | |
31 | infrastructure. You can easily setup firewall rules for all hosts | |
32 | inside a cluster, or define rules for virtual machines and | |
33 | containers. Features like firewall macros, security groups, IP sets | |
34 | and aliases help making that task easier. | |
35 | ||
36 | While all configuration is stored on the cluster file system, the | |
37 | iptables based firewall runs on each cluster node, and thus provides | |
38 | full isolation between virtual machines. The distributed nature of | |
39 | this system also provides much higher bandwidth than a central | |
40 | firewall solution. | |
41 | ||
42 | NOTE: If you enable the firewall, all traffic is blocked by default, | |
43 | except WebGUI(8006) and ssh(22) from your local network. | |
44 | ||
45 | ||
46 | Zones | |
47 | ----- | |
48 | ||
49 | The Proxmox VE firewall groups the network into the following logical zones: | |
50 | ||
51 | Host:: | |
52 | ||
53 | Traffic from/to a cluster node | |
54 | ||
55 | VM:: | |
56 | ||
57 | Traffic from/to a specific VM | |
58 | ||
59 | For each zone, you can define firewall rules for incoming and/or | |
60 | outgoing traffic. | |
61 | ||
62 | ||
63 | Ports used by Proxmox VE | |
64 | ------------------------ | |
65 | ||
66 | * Web interface: 8006 | |
67 | * VNC Web console: 5900-5999 | |
68 | * SPICE proxy: 3128 | |
69 | * sshd (used for cluster actions): 22 | |
70 | * rpcbind: 111 | |
71 | * corosync multicast (if you run a cluster): 5404, 5405 UDP | |
72 | ||
73 | ||
74 | Configuration | |
75 | ------------- | |
76 | ||
77 | All firewall related configuration is stored on the proxmox cluster | |
78 | file system. So those files are automatically distributed to all | |
79 | cluster nodes, and the 'pve-firewall' service updates the underlying | |
80 | iptables rules automatically on any change. Any configuration can be | |
81 | done using the GUI (i.e. Datacenter -> Firewall -> Options tab (tabs | |
82 | at the bottom of the page), or on a Node -> Firewall), so the | |
83 | following configuration file snippets are just for completeness. | |
84 | ||
85 | Cluster wide configuration is stored at: | |
86 | ||
87 | /etc/pve/firewall/cluster.fw | |
88 | ||
89 | The firewall is completely disabled by default, so you need to set the | |
90 | enable option here: | |
91 | ||
92 | ---- | |
93 | [OPTIONS] | |
94 | # enable firewall (cluster wide setting, default is disabled) | |
95 | enable: 1 | |
96 | ---- | |
97 | ||
98 | The cluster wide configuration can contain the following data: | |
99 | ||
100 | * IP set definitions | |
101 | * Alias definitions | |
102 | * Security group definitions | |
103 | * Cluster wide firewall rules for all nodes | |
104 | ||
105 | VM firewall configuration is read from: | |
106 | ||
107 | /etc/pve/firewall/<VMID>.fw | |
108 | ||
109 | and contains the following data: | |
110 | ||
111 | * IP set definitions | |
112 | * Alias definitions | |
113 | * Firewall rules for this VM | |
114 | * VM specific options | |
115 | ||
116 | And finally, any host related configuration is read from: | |
117 | ||
118 | /etc/pve/nodes/<nodename>/host.fw | |
119 | ||
120 | This is useful if you want to overwrite rules from 'cluster.fw' | |
121 | config. You can also increase log verbosity, and set netfilter related | |
122 | options. | |
123 | ||
124 | Enabling the Firewall for VMs and Containers | |
125 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
126 | ||
127 | You need to enable the firewall on the virtual network interface configuration | |
128 | in addition to the general 'Enable Firewall' option in the 'Options' tab. | |
129 | ||
130 | Firewall Rules | |
131 | ~~~~~~~~~~~~~~ | |
132 | ||
133 | Any firewall rule consists of a direction (`IN` or `OUT`) and an | |
134 | action (`ACCEPT`, `DENY`, `REJECT`). Additional options can be used to | |
135 | refine rule matches. Here are some examples: | |
136 | ||
137 | ---- | |
138 | [RULES] | |
139 | ||
140 | #TYPE ACTION [OPTIONS] | |
141 | #TYPE MACRO(ACTION) [OPTIONS] | |
142 | ||
143 | # -i <INTERFACE> | |
144 | # -source <SOURCE> | |
145 | # -dest <DEST> | |
146 | # -p <PROTOCOL> | |
147 | # -dport <DESTINATION_PORT> | |
148 | # -sport <SOURCE_PORT> | |
149 | ||
150 | IN SSH(ACCEPT) -i net0 | |
151 | IN SSH(ACCEPT) -i net0 # a comment | |
152 | IN SSH(ACCEPT) -i net0 -source 192.168.2.192 # only allow SSH from 192.168.2.192 | |
153 | IN SSH(ACCEPT) -i net0 -source 10.0.0.1-10.0.0.10 # accept SSH for ip range | |
154 | IN SSH(ACCEPT) -i net0 -source 10.0.0.1,10.0.0.2,10.0.0.3 #accept ssh for ip list | |
155 | IN SSH(ACCEPT) -i net0 -source +mynetgroup # accept ssh for ipset mynetgroup | |
156 | IN SSH(ACCEPT) -i net0 -source myserveralias #accept ssh for alias myserveralias | |
157 | ||
158 | |IN SSH(ACCEPT) -i net0 # disabled rule | |
159 | ---- | |
160 | ||
161 | Security Groups | |
162 | ~~~~~~~~~~~~~~~ | |
163 | ||
164 | A security group is a collection of rules, defined at cluster level, which | |
165 | can be used in all VMs' rules. For example you can define a group named | |
166 | `webserver` with rules to open the http and https ports. | |
167 | ||
168 | ---- | |
169 | # /etc/pve/firewall/cluster.fw | |
170 | ||
171 | [group webserver] | |
172 | IN ACCEPT -p tcp -dport 80 | |
173 | IN ACCEPT -p tcp -dport 443 | |
174 | ---- | |
175 | ||
176 | Then, you can add this group to a VM's firewall | |
177 | ||
178 | ---- | |
179 | # /etc/pve/firewall/<VMID>.fw | |
180 | ||
181 | [RULES] | |
182 | GROUP webserver | |
183 | ---- | |
184 | ||
185 | ||
186 | IP Aliases | |
187 | ~~~~~~~~~~ | |
188 | ||
189 | IP Aliases allow you to associate IP addresses of networks with a | |
190 | name. You can then refer to those names: | |
191 | ||
192 | * inside IP set definitions | |
193 | * in `source` and `dest` properties of firewall rules | |
194 | ||
195 | Standard IP alias `local_network` | |
196 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
197 | ||
198 | This alias is automatically defined. Please use the following command | |
199 | to see assigned values: | |
200 | ||
201 | ---- | |
202 | # pve-firewall localnet | |
203 | local hostname: example | |
204 | local IP address: 192.168.2.100 | |
205 | network auto detect: 192.168.0.0/20 | |
206 | using detected local_network: 192.168.0.0/20 | |
207 | ---- | |
208 | ||
209 | The firewall automatically sets up rules to allow everything needed | |
210 | for cluster communication (corosync, API, SSH) using this alias. | |
211 | ||
212 | The user can overwrite these values in the cluster.fw alias | |
213 | section. If you use a single host on a public network, it is better to | |
214 | explicitly assign the local IP address | |
215 | ||
216 | ---- | |
217 | # /etc/pve/firewall/cluster.fw | |
218 | [ALIASES] | |
219 | local_network 1.2.3.4 # use the single ip address | |
220 | ---- | |
221 | ||
222 | IP Sets | |
223 | ~~~~~~~ | |
224 | ||
225 | IP sets can be used to define groups of networks and hosts. You can | |
226 | refer to them with `+name` in the firewall rules' `source` and `dest` | |
227 | properties. | |
228 | ||
229 | The following example allows HTTP traffic from the `management` IP | |
230 | set. | |
231 | ||
232 | IN HTTP(ACCEPT) -source +management | |
233 | ||
234 | Standard IP set `management` | |
235 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
236 | ||
237 | This IP set applies only to host firewalls (not VM firewalls). Those | |
238 | ips are allowed to do normal management tasks (PVE GUI, VNC, SPICE, | |
239 | SSH). | |
240 | ||
241 | The local cluster network is automatically added to this IP set (alias | |
242 | `cluster_network`), to enable inter-host cluster | |
243 | communication. (multicast,ssh,...) | |
244 | ||
245 | ---- | |
246 | # /etc/pve/firewall/cluster.fw | |
247 | ||
248 | [IPSET management] | |
249 | 192.168.2.10 | |
250 | 192.168.2.10/24 | |
251 | ---- | |
252 | ||
253 | Standard IP set 'blacklist' | |
254 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
255 | ||
256 | Traffic from these ips is dropped by every host's and VM's firewall. | |
257 | ||
258 | ---- | |
259 | # /etc/pve/firewall/cluster.fw | |
260 | ||
261 | [IPSET blacklist] | |
262 | 77.240.159.182 | |
263 | 213.87.123.0/24 | |
264 | ---- | |
265 | ||
266 | Standard IP set 'ipfilter-net*' | |
267 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
268 | ||
269 | These filters belong to a VM's network interface and are mainly used to prevent | |
270 | IP spoofing. If such a set exists for an interface then any outgoing traffic | |
271 | with a source IP not matching its interface's corresponding ipfilter set will | |
272 | be dropped. | |
273 | ||
274 | For containers with configured IP addresses these sets, if they exist (or are | |
275 | activated via the general `IP Filter` option in the VM's firewall's 'options' | |
276 | tab), implicitly contain the associated IP addresses. | |
277 | ||
278 | For both virtual machines and containers they also implicitly contain the | |
279 | standard MAC-derived IPv6 link-local address in order to allow the neighbor | |
280 | discovery protocol to work. | |
281 | ||
282 | ---- | |
283 | /etc/pve/firewall/<VMID>.fw | |
284 | ||
285 | [IPSET ipfilter-net0] # only allow specified IPs on net0 | |
286 | 192.168.2.10 | |
287 | ---- | |
288 | ||
289 | Services and Commands | |
290 | ~~~~~~~~~~~~~~~~~~~~~ | |
291 | ||
292 | The firewall runs two service daemons on each node: | |
293 | ||
294 | * pvefw-logger: NFLOG daemon (ulogd replacement). | |
295 | * pve-firewall: updates iptables rules | |
296 | ||
297 | There is also a CLI command named 'pve-firewall', which can be used to | |
298 | start and stop the firewall service: | |
299 | ||
300 | # pve-firewall start | |
301 | # pve-firewall stop | |
302 | ||
303 | To get the status use: | |
304 | ||
305 | # pve-firewall status | |
306 | ||
307 | The above command reads and compiles all firewall rules, so you will | |
308 | see warnings if your firewall configuration contains any errors. | |
309 | ||
310 | If you want to see the generated iptables rules you can use: | |
311 | ||
312 | # iptables-save | |
313 | ||
314 | Tips and Tricks | |
315 | ~~~~~~~~~~~~~~~ | |
316 | ||
317 | How to allow FTP | |
318 | ^^^^^^^^^^^^^^^^ | |
319 | ||
320 | FTP is an old style protocol which uses port 21 and several other dynamic ports. So you | |
321 | need a rule to accept port 21. In addition, you need to load the 'ip_conntrack_ftp' module. | |
322 | So please run: | |
323 | ||
324 | modprobe ip_conntrack_ftp | |
325 | ||
326 | and add `ip_conntrack_ftp` to '/etc/modules' (so that it works after a reboot) . | |
327 | ||
328 | Suricata IPS integration | |
329 | ^^^^^^^^^^^^^^^^^^^^^^^^ | |
330 | ||
331 | If you want to use the http://suricata-ids.org/[Suricata IPS] | |
332 | (Intrusion Prevention System), it's possible. | |
333 | ||
334 | Packets will be forwarded to the IPS only after the firewall ACCEPTed | |
335 | them. | |
336 | ||
337 | Rejected/Dropped firewall packets don't go to the IPS. | |
338 | ||
339 | Install suricata on proxmox host: | |
340 | ||
341 | ---- | |
342 | # apt-get install suricata | |
343 | # modprobe nfnetlink_queue | |
344 | ---- | |
345 | ||
346 | Don't forget to add `nfnetlink_queue` to '/etc/modules' for next reboot. | |
347 | ||
348 | Then, enable IPS for a specific VM with: | |
349 | ||
350 | ---- | |
351 | # /etc/pve/firewall/<VMID>.fw | |
352 | ||
353 | [OPTIONS] | |
354 | ips: 1 | |
355 | ips_queues: 0 | |
356 | ---- | |
357 | ||
358 | `ips_queues` will bind a specific cpu queue for this VM. | |
359 | ||
360 | Available queues are defined in | |
361 | ||
362 | ---- | |
363 | # /etc/default/suricata | |
364 | NFQUEUE=0 | |
365 | ---- | |
366 | ||
367 | ||
368 | ifdef::manvolnum[] | |
369 | include::copyright.adoc[] | |
370 | endif::manvolnum[] | |
371 |