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.
49 The Proxmox VE firewall groups the network into the following logical zones:
53 Traffic from/to a cluster node
57 Traffic from/to a specific VM
59 For each zone, you can define firewall rules for incoming and/or
63 Ports used by Proxmox VE
64 ------------------------
67 * VNC Web console: 5900-5999
69 * sshd (used for cluster actions): 22
71 * corosync multicast (if you run a cluster): 5404, 5405 UDP
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.
85 Cluster wide configuration is stored at:
87 /etc/pve/firewall/cluster.fw
89 The firewall is completely disabled by default, so you need to set the
94 # enable firewall (cluster wide setting, default is disabled)
98 The cluster wide configuration can contain the following data:
102 * Security group definitions
103 * Cluster wide firewall rules for all nodes
105 VM firewall configuration is read from:
107 /etc/pve/firewall/<VMID>.fw
109 and contains the following data:
113 * Firewall rules for this VM
114 * VM specific options
116 And finally, any host related configuration is read from:
118 /etc/pve/nodes/<nodename>/host.fw
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
124 Enabling Firewall for VMs and Containers
125 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127 You need to enable the firewall on the virtual network interface configuration.
132 Any firewall rule consists of a direction (`IN` or `OUT`) and an
133 action (`ACCEPT`, `DENY`, `REJECT`). Additional options can be used to
134 refine rule matches. Here are some examples:
139 #TYPE ACTION [OPTIONS]
140 #TYPE MACRO(ACTION) [OPTIONS]
146 # -dport <DESTINATION_PORT>
147 # -sport <SOURCE_PORT>
149 IN SSH(ACCEPT) -i net0
150 IN SSH(ACCEPT) -i net0 # a comment
151 IN SSH(ACCEPT) -i net0 -source 192.168.2.192 # only allow SSH from 192.168.2.192
152 IN SSH(ACCEPT) -i net0 -source 10.0.0.1-10.0.0.10 # accept SSH for ip range
153 IN SSH(ACCEPT) -i net0 -source 10.0.0.1,10.0.0.2,10.0.0.3 #accept ssh for ip list
154 IN SSH(ACCEPT) -i net0 -source +mynetgroup # accept ssh for ipset mynetgroup
155 IN SSH(ACCEPT) -i net0 -source myserveralias #accept ssh for alias myserveralias
157 |IN SSH(ACCEPT) -i net0 # disabled rule
163 A security group is a group a rules, defined at cluster level, which
164 can be used in all VMs rules. For example you can define a group named
165 `webserver` with rules to open http and https ports.
168 # /etc/pve/firewall/cluster.fw
171 IN ACCEPT -p tcp -dport 80
172 IN ACCEPT -p tcp -dport 443
175 Then, you can add this group in a vm firewall
178 # /etc/pve/firewall/<VMID>.fw
188 IP Aliases allows you to associate IP addresses of Networks with a
189 name. You can then refer to those names:
191 * inside IP set definitions
192 * in `source` and `dest` properties of firewall rules
194 Standard IP alias `local_network`
195 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197 This alias is automatically defined. Please use the following command
198 to see assigned values:
201 # pve-firewall localnet
202 local hostname: example
203 local IP address: 192.168.2.100
204 network auto detect: 192.168.0.0/20
205 using detected local_network: 192.168.0.0/20
208 The firewall automatically sets up rules to allow everything needed
209 for cluster communication (corosync, API, SSH).
211 The user can overwrite these values in the cluster.fw alias
212 section. If you use a single host on a public network, it is better to
213 explicitly assign the local IP address
216 # /etc/pve/firewall/cluster.fw
218 local_network 1.2.3.4 # use the single ip address
224 IP sets can be used to define groups of networks and hosts. You can
225 refer to them with `+name` in firewall rules `source` and `dest`
228 The following example allows HTTP traffic from the `management` IP
231 IN HTTP(ACCEPT) -source +management
233 Standard IP set `management`
234 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
236 This IP set applies only to host firewalls (not VM firewalls). Those
237 ips are allowed to do normal management tasks (PVE GUI, VNC, SPICE,
240 The local cluster network is automatically added to this IP set (alias
241 `cluster_network`), to enable inter-host cluster
242 communication. (multicast,ssh,...)
245 # /etc/pve/firewall/cluster.fw
252 Standard IP set 'blacklist'
253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
255 Traffic from those ips is dropped in all hosts and VMs firewalls.
258 # /etc/pve/firewall/cluster.fw
265 Standard IP set 'ipfilter'
266 ^^^^^^^^^^^^^^^^^^^^^^^^^^
268 This ipset is used to prevent ip spoofing
271 /etc/pve/firewall/<VMID>.fw
273 [IPSET ipfilter-net0] # only allow specified IPs on net0
277 Services and Commands
278 ~~~~~~~~~~~~~~~~~~~~~
280 The firewall runs two service daemons on each node:
282 * pvefw-logger: NFLOG daemon (ulogd replacement).
283 * pve-firewall: updates iptables rules
285 There is also a CLI command named 'pve-firewall', which can be used to
286 start and stop the firewall service:
291 To get the status use:
293 # pve-firewall status
295 The above command reads and compiles all firewall rules, so you will
296 see warnings if your firewall configuration contains any errors.
298 If you want to see the generated iptables rules you can use:
308 FTP is an old style protocol which uses port 21 and several other dynamic ports. So you
309 need a rule to accept port 21. In addition, you need to load the 'ip_conntrack_ftp' module.
312 modprobe ip_conntrack_ftp
314 and add `ip_conntrack_ftp` to '/etc/modules' (so that it works after a reboot) .
316 Suricata IPS integration
317 ^^^^^^^^^^^^^^^^^^^^^^^^
319 If you want to use the http://suricata-ids.org/[Suricata IPS]
320 (Intrusion Prevention System), it's possible.
322 Packets will be forwarded to the IPS only after the firewall ACCEPTed
325 Rejected/Dropped firewall packets don't go to the IPS.
327 Install suricata on proxmox host:
330 # apt-get install suricata
331 # modprobe nfnetlink_queue
334 Don't forget to add `nfnetlink_queue` to '/etc/modules' for next reboot.
336 Then, enable IPS for a specific VM with:
339 # /etc/pve/firewall/<VMID>.fw
346 `ips_queues` will bind a specific cpu queue for this VM.
348 Available queues are defined in
351 # /etc/default/suricata
357 include::copyright.adoc[]