4 include::attributes.txt[]
9 pve-firewall - The PVE Firewall Daemon
15 include::pve-firewall.8-synopsis.adoc[]
25 include::attributes.txt[]
28 // Copied from pve wiki: Revision as of 08:45, 9 November 2015
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.
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
42 NOTE: If you enable the firewall, all traffic is blocked by default,
43 except WebGUI(8006) and ssh(22) from your local network.
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. Any configuration can be
74 done using the GUI (i.e. Datacenter -> Firewall -> Options tab (tabs
75 at the bottom of the page), or on a Node -> Firewall), so the
76 following configuration file snippets are just for completeness.
78 All firewall configuration files contains sections of key-value
79 pairs. Lines beginning with a '#' and blank lines are considered
80 comments. Sections starts with a header line containing the section
81 name enclosed in '[' and ']'.
86 The cluster wide firewall configuration is stored at:
88 /etc/pve/firewall/cluster.fw
90 The configuration can contain the following sections:
94 This is used to set cluster wide firewall options.
96 NOTE: The firewall is completely disabled by default, so you need to
97 set the enable option here:
101 # enable firewall (cluster wide setting, default is disabled)
107 This sections contains cluster wide firewall rules for all nodes.
111 Cluster wide IP set definitions.
115 Cluster wide security group definitions.
119 Cluster wide Alias definitions.
121 Host specific Configuration
122 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
124 Host related configuration is read from:
126 /etc/pve/nodes/<nodename>/host.fw
128 This is useful if you want to overwrite rules from 'cluster.fw'
129 config. You can also increase log verbosity, and set netfilter related
133 VM/Container configuration
134 ~~~~~~~~~~~~~~~~~~~~~~~~~~
136 VM firewall configuration is read from:
138 /etc/pve/firewall/<VMID>.fw
140 and contains the following data:
144 * Firewall rules for this VM
145 * VM specific options
148 Enabling the Firewall for VMs and Containers
149 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
151 You need to enable the firewall on the virtual network interface configuration
152 in addition to the general 'Enable Firewall' option in the 'Options' tab.
158 Firewall rules consists of a direction (`IN` or `OUT`) and an
159 action (`ACCEPT`, `DENY`, `REJECT`). You can also specify a macro
160 name. Macros contain predifined sets of rules and options. Rules can be disabled by prefixing them with '|'.
162 .Firewall rules syntax
166 DIRECTION ACTION [OPTIONS]
167 |DIRECTION ACTION [OPTIONS] # disabled rule
169 DIRECTION MACRO(ACTION) [OPTIONS] # use predefined macro
172 The following options can be used to refine rule matches.
174 include::pve-firewall-rules-opts.adoc[]
176 Here are some examples:
180 IN SSH(ACCEPT) -i net0
181 IN SSH(ACCEPT) -i net0 # a comment
182 IN SSH(ACCEPT) -i net0 -source 192.168.2.192 # only allow SSH from 192.168.2.192
183 IN SSH(ACCEPT) -i net0 -source 10.0.0.1-10.0.0.10 # accept SSH for ip range
184 IN SSH(ACCEPT) -i net0 -source 10.0.0.1,10.0.0.2,10.0.0.3 #accept ssh for ip list
185 IN SSH(ACCEPT) -i net0 -source +mynetgroup # accept ssh for ipset mynetgroup
186 IN SSH(ACCEPT) -i net0 -source myserveralias #accept ssh for alias myserveralias
188 |IN SSH(ACCEPT) -i net0 # disabled rule
190 IN DROP # drop all incoming packages
191 OUT ACCEPT # accept all outgoing packages
197 A security group is a collection of rules, defined at cluster level, which
198 can be used in all VMs' rules. For example you can define a group named
199 `webserver` with rules to open the http and https ports.
202 # /etc/pve/firewall/cluster.fw
205 IN ACCEPT -p tcp -dport 80
206 IN ACCEPT -p tcp -dport 443
209 Then, you can add this group to a VM's firewall
212 # /etc/pve/firewall/<VMID>.fw
222 IP Aliases allow you to associate IP addresses of networks with a
223 name. You can then refer to those names:
225 * inside IP set definitions
226 * in `source` and `dest` properties of firewall rules
228 Standard IP alias `local_network`
229 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
231 This alias is automatically defined. Please use the following command
232 to see assigned values:
235 # pve-firewall localnet
236 local hostname: example
237 local IP address: 192.168.2.100
238 network auto detect: 192.168.0.0/20
239 using detected local_network: 192.168.0.0/20
242 The firewall automatically sets up rules to allow everything needed
243 for cluster communication (corosync, API, SSH) using this alias.
245 The user can overwrite these values in the cluster.fw alias
246 section. If you use a single host on a public network, it is better to
247 explicitly assign the local IP address
250 # /etc/pve/firewall/cluster.fw
252 local_network 1.2.3.4 # use the single ip address
258 IP sets can be used to define groups of networks and hosts. You can
259 refer to them with `+name` in the firewall rules' `source` and `dest`
262 The following example allows HTTP traffic from the `management` IP
265 IN HTTP(ACCEPT) -source +management
267 Standard IP set `management`
268 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270 This IP set applies only to host firewalls (not VM firewalls). Those
271 ips are allowed to do normal management tasks (PVE GUI, VNC, SPICE,
274 The local cluster network is automatically added to this IP set (alias
275 `cluster_network`), to enable inter-host cluster
276 communication. (multicast,ssh,...)
279 # /etc/pve/firewall/cluster.fw
286 Standard IP set 'blacklist'
287 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
289 Traffic from these ips is dropped by every host's and VM's firewall.
292 # /etc/pve/firewall/cluster.fw
300 Standard IP set 'ipfilter-net*'
301 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 These filters belong to a VM's network interface and are mainly used to prevent
304 IP spoofing. If such a set exists for an interface then any outgoing traffic
305 with a source IP not matching its interface's corresponding ipfilter set will
308 For containers with configured IP addresses these sets, if they exist (or are
309 activated via the general `IP Filter` option in the VM's firewall's 'options'
310 tab), implicitly contain the associated IP addresses.
312 For both virtual machines and containers they also implicitly contain the
313 standard MAC-derived IPv6 link-local address in order to allow the neighbor
314 discovery protocol to work.
317 /etc/pve/firewall/<VMID>.fw
319 [IPSET ipfilter-net0] # only allow specified IPs on net0
324 Services and Commands
325 ---------------------
327 The firewall runs two service daemons on each node:
329 * pvefw-logger: NFLOG daemon (ulogd replacement).
330 * pve-firewall: updates iptables rules
332 There is also a CLI command named 'pve-firewall', which can be used to
333 start and stop the firewall service:
338 To get the status use:
340 # pve-firewall status
342 The above command reads and compiles all firewall rules, so you will
343 see warnings if your firewall configuration contains any errors.
345 If you want to see the generated iptables rules you can use:
356 FTP is an old style protocol which uses port 21 and several other dynamic ports. So you
357 need a rule to accept port 21. In addition, you need to load the 'ip_conntrack_ftp' module.
360 modprobe ip_conntrack_ftp
362 and add `ip_conntrack_ftp` to '/etc/modules' (so that it works after a reboot) .
365 Suricata IPS integration
366 ~~~~~~~~~~~~~~~~~~~~~~~~
368 If you want to use the http://suricata-ids.org/[Suricata IPS]
369 (Intrusion Prevention System), it's possible.
371 Packets will be forwarded to the IPS only after the firewall ACCEPTed
374 Rejected/Dropped firewall packets don't go to the IPS.
376 Install suricata on proxmox host:
379 # apt-get install suricata
380 # modprobe nfnetlink_queue
383 Don't forget to add `nfnetlink_queue` to '/etc/modules' for next reboot.
385 Then, enable IPS for a specific VM with:
388 # /etc/pve/firewall/<VMID>.fw
395 `ips_queues` will bind a specific cpu queue for this VM.
397 Available queues are defined in
400 # /etc/default/suricata
404 Avoiding link-local addresses on tap and veth devices
405 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407 With IPv6 enabled by default every interface gets a MAC-derived link local
408 address. However, most devices on a typical {pve} setup are connected to a
409 bridge and so the bridge is the only interface which really needs one.
411 To disable a link local address on an interface you can set the interface's
412 `disable_ipv6` sysconf variable. Despite the name, this does not prevent IPv6
413 traffic from passing through the interface when routing or bridging, so the
414 only noticeable effect will be the removal of the link local address.
416 The easiest method of achieving this setting for all newly started VMs is to
417 set it for the `default` interface configuration and enabling it explicitly on
418 the interfaces which need it. This is also the case for other settings such as
419 `forwarding`, `accept_ra` or `autoconf`.
421 Here's a possible setup:
423 # /etc/sysconf.d/90-ipv6.conf
425 net.ipv6.conf.default.forwarding = 0
426 net.ipv6.conf.default.proxy_ndp = 0
427 net.ipv6.conf.default.autoconf = 0
428 net.ipv6.conf.default.disable_ipv6 = 1
429 net.ipv6.conf.default.accept_ra = 0
431 net.ipv6.conf.lo.disable_ipv6 = 0
435 # /etc/network/interfaces
437 iface vmbr0 inet6 static
442 pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/disable_ipv6
450 The firewall contains a few IPv6 specific options. One thing to note is that
451 IPv6 does not use the ARP protocol anymore, and instead uses NDP (Neighbor
452 Discovery Protocol) which works on IP level and thus needs IP addresses to
453 succeed. For this purpose link-local addresses derived from the interface's MAC
454 address are used. By default the 'NDP' option is enabled on both host and VM
455 level to allow neighbor discovery (NDP) packets to be sent and received.
457 Beside neighbor discovery NDP is also used for a couple of other things, like
458 autoconfiguration and advertising routers.
460 By default VMs are allowed to send out router solicitation messages (to query
461 for a router), and to receive router advetisement packets. This allows them to
462 use stateless auto configuration. On the other hand VMs cannot advertise
463 themselves as routers unless the 'Allow Router Advertisement' (`radv: 1`) option
466 As for the link local addresses required for NDP, there's also an 'IP Filter'
467 (`ipfilter: 1`) option which can be enabled which has the same effect as adding
468 an `ipfilter-net*` ipset for each of the VM's network interfaces containing the
469 corresponding link local addresses. (See the
470 <<ipfilter-section,Standard IP set 'ipfilter-net*'>> section for details.)
473 Ports used by Proxmox VE
474 ------------------------
476 * Web interface: 8006
477 * VNC Web console: 5900-5999
479 * sshd (used for cluster actions): 22
481 * corosync multicast (if you run a cluster): 5404, 5405 UDP
489 include::pve-firewall-macros.adoc[]
492 include::pve-copyright.adoc[]