1 [[chapter_pve_firewall]]
5 include::attributes.txt[]
11 pve-firewall - PVE Firewall Daemon
17 include::pve-firewall.8-synopsis.adoc[]
26 include::attributes.txt[]
33 {pve} Firewall provides an easy way to protect your IT
34 infrastructure. You can setup firewall rules for all hosts
35 inside a cluster, or define rules for virtual machines and
36 containers. Features like firewall macros, security groups, IP sets
37 and aliases help to make that task easier.
39 While all configuration is stored on the cluster file system, the
40 `iptables`-based firewall runs on each cluster node, and thus provides
41 full isolation between virtual machines. The distributed nature of
42 this system also provides much higher bandwidth than a central
45 The firewall has full support for IPv4 and IPv6. IPv6 support is fully
46 transparent, and we filter traffic for both protocols by default. So
47 there is no need to maintain a different set of rules for IPv6.
53 The Proxmox VE firewall groups the network into the following logical zones:
57 Traffic from/to a cluster node
61 Traffic from/to a specific VM
63 For each zone, you can define firewall rules for incoming and/or
70 All firewall related configuration is stored on the proxmox cluster
71 file system. So those files are automatically distributed to all
72 cluster nodes, and the `pve-firewall` service updates the underlying
73 `iptables` rules automatically on changes.
75 You can configure anything using the GUI (i.e. *Datacenter* -> *Firewall*,
76 or on a *Node* -> *Firewall*), or you can edit the configuration files
77 directly using your preferred editor.
79 Firewall configuration files contains sections of key-value
80 pairs. Lines beginning with a `#` and blank lines are considered
81 comments. Sections starts with a header line containing the section
82 name enclosed in `[` and `]`.
85 [[pve_firewall_cluster_wide_setup]]
89 The cluster wide firewall configuration is stored at:
91 /etc/pve/firewall/cluster.fw
93 The configuration can contain the following sections:
97 This is used to set cluster wide firewall options.
99 include::pve-firewall-cluster-opts.adoc[]
103 This sections contains cluster wide firewall rules for all nodes.
107 Cluster wide IP set definitions.
111 Cluster wide security group definitions.
115 Cluster wide Alias definitions.
118 Enabling the Firewall
119 ^^^^^^^^^^^^^^^^^^^^^
121 The firewall is completely disabled by default, so you need to
122 set the enable option here:
126 # enable firewall (cluster wide setting, default is disabled)
130 IMPORTANT: If you enable the firewall, traffic to all hosts is blocked by
131 default. Only exceptions is WebGUI(8006) and ssh(22) from your local
134 If you want to administrate your {pve} hosts from remote, you
135 need to create rules to allow traffic from those remote IPs to the web
136 GUI (port 8006). You may also want to allow ssh (port 22), and maybe
139 TIP: Please open a SSH connection to one of your {PVE} hosts before
140 enabling the firewall. That way you still have access to the host if
141 something goes wrong .
143 To simplify that task, you can instead create an IPSet called
144 ``management'', and add all remote IPs there. This creates all required
145 firewall rules to access the GUI from remote.
148 [[pve_firewall_host_specific_configuration]]
149 Host Specific Configuration
150 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
152 Host related configuration is read from:
154 /etc/pve/nodes/<nodename>/host.fw
156 This is useful if you want to overwrite rules from `cluster.fw`
157 config. You can also increase log verbosity, and set netfilter related
158 options. The configuration can contain the following sections:
162 This is used to set host related firewall options.
164 include::pve-firewall-host-opts.adoc[]
168 This sections contains host specific firewall rules.
170 [[pve_firewall_vm_container_configuration]]
171 VM/Container Configuration
172 ~~~~~~~~~~~~~~~~~~~~~~~~~~
174 VM firewall configuration is read from:
176 /etc/pve/firewall/<VMID>.fw
178 and contains the following data:
182 This is used to set VM/Container related firewall options.
184 include::pve-firewall-vm-opts.adoc[]
188 This sections contains VM/Container firewall rules.
196 IP Alias definitions.
199 Enabling the Firewall for VMs and Containers
200 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
202 Each virtual network device has its own firewall enable flag. So you
203 can selectively enable the firewall for each interface. This is
204 required in addition to the general firewall `enable` option.
206 The firewall requires a special network device setup, so you need to
207 restart the VM/container after enabling the firewall on a network
214 Firewall rules consists of a direction (`IN` or `OUT`) and an
215 action (`ACCEPT`, `DENY`, `REJECT`). You can also specify a macro
216 name. Macros contain predefined sets of rules and options. Rules can be
217 disabled by prefixing them with `|`.
219 .Firewall rules syntax
223 DIRECTION ACTION [OPTIONS]
224 |DIRECTION ACTION [OPTIONS] # disabled rule
226 DIRECTION MACRO(ACTION) [OPTIONS] # use predefined macro
229 The following options can be used to refine rule matches.
231 include::pve-firewall-rules-opts.adoc[]
233 Here are some examples:
237 IN SSH(ACCEPT) -i net0
238 IN SSH(ACCEPT) -i net0 # a comment
239 IN SSH(ACCEPT) -i net0 -source 192.168.2.192 # only allow SSH from 192.168.2.192
240 IN SSH(ACCEPT) -i net0 -source 10.0.0.1-10.0.0.10 # accept SSH for ip range
241 IN SSH(ACCEPT) -i net0 -source 10.0.0.1,10.0.0.2,10.0.0.3 #accept ssh for ip list
242 IN SSH(ACCEPT) -i net0 -source +mynetgroup # accept ssh for ipset mynetgroup
243 IN SSH(ACCEPT) -i net0 -source myserveralias #accept ssh for alias myserveralias
245 |IN SSH(ACCEPT) -i net0 # disabled rule
247 IN DROP # drop all incoming packages
248 OUT ACCEPT # accept all outgoing packages
252 [[pve_firewall_security_groups]]
256 A security group is a collection of rules, defined at cluster level, which
257 can be used in all VMs' rules. For example you can define a group named
258 ``webserver'' with rules to open the 'http' and 'https' ports.
261 # /etc/pve/firewall/cluster.fw
264 IN ACCEPT -p tcp -dport 80
265 IN ACCEPT -p tcp -dport 443
268 Then, you can add this group to a VM's firewall
271 # /etc/pve/firewall/<VMID>.fw
277 [[pve_firewall_ip_aliases]]
281 IP Aliases allow you to associate IP addresses of networks with a
282 name. You can then refer to those names:
284 * inside IP set definitions
285 * in `source` and `dest` properties of firewall rules
288 Standard IP Alias `local_network`
289 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 This alias is automatically defined. Please use the following command
292 to see assigned values:
295 # pve-firewall localnet
296 local hostname: example
297 local IP address: 192.168.2.100
298 network auto detect: 192.168.0.0/20
299 using detected local_network: 192.168.0.0/20
302 The firewall automatically sets up rules to allow everything needed
303 for cluster communication (corosync, API, SSH) using this alias.
305 The user can overwrite these values in the `cluster.fw` alias
306 section. If you use a single host on a public network, it is better to
307 explicitly assign the local IP address
310 # /etc/pve/firewall/cluster.fw
312 local_network 1.2.3.4 # use the single ip address
315 [[pve_firewall_ip_sets]]
319 IP sets can be used to define groups of networks and hosts. You can
320 refer to them with `+name` in the firewall rules' `source` and `dest`
323 The following example allows HTTP traffic from the `management` IP
326 IN HTTP(ACCEPT) -source +management
329 Standard IP set `management`
330 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332 This IP set applies only to host firewalls (not VM firewalls). Those
333 IPs are allowed to do normal management tasks (PVE GUI, VNC, SPICE,
336 The local cluster network is automatically added to this IP set (alias
337 `cluster_network`), to enable inter-host cluster
338 communication. (multicast,ssh,...)
341 # /etc/pve/firewall/cluster.fw
349 Standard IP set `blacklist`
350 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
352 Traffic from these IPs is dropped by every host's and VM's firewall.
355 # /etc/pve/firewall/cluster.fw
363 [[pve_firewall_ipfilter_section]]
364 Standard IP set `ipfilter-net*`
365 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367 These filters belong to a VM's network interface and are mainly used to prevent
368 IP spoofing. If such a set exists for an interface then any outgoing traffic
369 with a source IP not matching its interface's corresponding ipfilter set will
372 For containers with configured IP addresses these sets, if they exist (or are
373 activated via the general `IP Filter` option in the VM's firewall's *options*
374 tab), implicitly contain the associated IP addresses.
376 For both virtual machines and containers they also implicitly contain the
377 standard MAC-derived IPv6 link-local address in order to allow the neighbor
378 discovery protocol to work.
381 /etc/pve/firewall/<VMID>.fw
383 [IPSET ipfilter-net0] # only allow specified IPs on net0
388 Services and Commands
389 ---------------------
391 The firewall runs two service daemons on each node:
393 * pvefw-logger: NFLOG daemon (ulogd replacement).
394 * pve-firewall: updates iptables rules
396 There is also a CLI command named `pve-firewall`, which can be used to
397 start and stop the firewall service:
402 To get the status use:
404 # pve-firewall status
406 The above command reads and compiles all firewall rules, so you will
407 see warnings if your firewall configuration contains any errors.
409 If you want to see the generated iptables rules you can use:
420 FTP is an old style protocol which uses port 21 and several other dynamic ports. So you
421 need a rule to accept port 21. In addition, you need to load the `ip_conntrack_ftp` module.
424 modprobe ip_conntrack_ftp
426 and add `ip_conntrack_ftp` to `/etc/modules` (so that it works after a reboot).
429 Suricata IPS integration
430 ~~~~~~~~~~~~~~~~~~~~~~~~
432 If you want to use the http://suricata-ids.org/[Suricata IPS]
433 (Intrusion Prevention System), it's possible.
435 Packets will be forwarded to the IPS only after the firewall ACCEPTed
438 Rejected/Dropped firewall packets don't go to the IPS.
440 Install suricata on proxmox host:
443 # apt-get install suricata
444 # modprobe nfnetlink_queue
447 Don't forget to add `nfnetlink_queue` to `/etc/modules` for next reboot.
449 Then, enable IPS for a specific VM with:
452 # /etc/pve/firewall/<VMID>.fw
459 `ips_queues` will bind a specific cpu queue for this VM.
461 Available queues are defined in
464 # /etc/default/suricata
472 The firewall contains a few IPv6 specific options. One thing to note is that
473 IPv6 does not use the ARP protocol anymore, and instead uses NDP (Neighbor
474 Discovery Protocol) which works on IP level and thus needs IP addresses to
475 succeed. For this purpose link-local addresses derived from the interface's MAC
476 address are used. By default the `NDP` option is enabled on both host and VM
477 level to allow neighbor discovery (NDP) packets to be sent and received.
479 Beside neighbor discovery NDP is also used for a couple of other things, like
480 autoconfiguration and advertising routers.
482 By default VMs are allowed to send out router solicitation messages (to query
483 for a router), and to receive router advertisement packets. This allows them to
484 use stateless auto configuration. On the other hand VMs cannot advertise
485 themselves as routers unless the ``Allow Router Advertisement'' (`radv: 1`) option
488 As for the link local addresses required for NDP, there's also an ``IP Filter''
489 (`ipfilter: 1`) option which can be enabled which has the same effect as adding
490 an `ipfilter-net*` ipset for each of the VM's network interfaces containing the
491 corresponding link local addresses. (See the
492 <<pve_firewall_ipfilter_section,Standard IP set `ipfilter-net*`>> section for details.)
498 * Web interface: 8006
499 * VNC Web console: 5900-5999
501 * sshd (used for cluster actions): 22
503 * corosync multicast (if you run a cluster): 5404, 5405 UDP
511 include::pve-firewall-macros.adoc[]
514 include::pve-copyright.adoc[]