1 include::attributes.txt[]
9 pve-firewall - The PVE Firewall Daemon
15 include::pve-firewall.1-synopsis.adoc[]
27 // Copied from pve wiki: Revision as of 08:45, 9 November 2015
29 Proxmox VE Firewall provides an easy way to protect your IT
30 infrastructure. You can easily setup firewall rules for all hosts
31 inside a cluster, or define rules for virtual machines and
32 containers. Features like firewall macros, security groups, IP sets
33 and aliases help making that task easier.
35 While all configuration is stored on the cluster file system, the
36 iptables based firewall runs on each cluster node, and thus provides
37 full isolation between virtual machines. The distributed nature of
38 this system also provides much higher bandwidth than a central
41 NOTE: If you enable the firewall, all traffic is blocked by default,
42 except WebGUI(8006) and ssh(22) from your local network.
48 The Proxmox VE firewall groups the network into the following logical zones:
52 Traffic from/to a cluster node
56 Traffic from/to a specific VM
58 For each zone, you can define firewall rules for incoming and/or
62 Ports used by Proxmox VE
63 ------------------------
66 * VNC Web console: 5900-5999
68 * sshd (used for cluster actions): 22
70 * corosync multicast (if you run a cluster): 5404, 5405 UDP
76 All firewall related configuration is stored on the proxmox cluster
77 file system. So those files are automatically distributed to all
78 cluster nodes, and the 'pve-firewall' service updates the underlying
79 iptables rules automatically on any change. Any configuration can be
80 done using the GUI (i.e. Datacenter -> Firewall -> Options tab (tabs
81 at the bottom of the page), or on a Node -> Firewall), so the
82 following configuration file snippets are just for completeness.
84 Cluster wide configuration is stored at:
86 /etc/pve/firewall/cluster.fw
88 The firewall is completely disabled by default, so you need to set the
93 # enable firewall (cluster wide setting, default is disabled)
97 The cluster wide configuration can contain the following data:
101 * Security group definitions
102 * Cluster wide firewall rules for all nodes
104 VM firewall configuration is read from:
106 /etc/pve/firewall/<VMID>.fw
108 and contains the following data:
112 * Firewall rules for this VM
113 * VM specific options
115 And finally, any host related configuration is read from:
117 /etc/pve/nodes/<nodename>/host.fw
119 This is useful if you want to overwrite rules from 'cluster.fw'
120 config. You can also increase log verbosity, and set netfilter related
123 Enabling Firewall for VMs and Containers
124 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126 You need to enable the firewall on the virtual network interface configuration.
131 Any firewall rule consists of a direction (`IN` or `OUT`) and an
132 action (`ACCEPT`, `DENY`, `REJECT`). Additional options can be used to
133 refine rule matches. Here are some examples:
138 #TYPE ACTION [OPTIONS]
139 #TYPE MACRO(ACTION) [OPTIONS]
145 # -dport <DESTINATION_PORT>
146 # -sport <SOURCE_PORT>
148 IN SSH(ACCEPT) -i net0
149 IN SSH(ACCEPT) -i net0 # a comment
150 IN SSH(ACCEPT) -i net0 -source 192.168.2.192 # only allow SSH from 192.168.2.192
151 IN SSH(ACCEPT) -i net0 -source 10.0.0.1-10.0.0.10 # accept SSH for ip range
152 IN SSH(ACCEPT) -i net0 -source 10.0.0.1,10.0.0.2,10.0.0.3 #accept ssh for ip list
153 IN SSH(ACCEPT) -i net0 -source +mynetgroup # accept ssh for ipset mynetgroup
154 IN SSH(ACCEPT) -i net0 -source myserveralias #accept ssh for alias myserveralias
156 |IN SSH(ACCEPT) -i net0 # disabled rule
162 A security group is a group a rules, defined at cluster level, which
163 can be used in all VMs rules. For example you can define a group named
164 `webserver` with rules to open http and https ports.
167 # /etc/pve/firewall/cluster.fw
170 IN ACCEPT -p tcp -dport 80
171 IN ACCEPT -p tcp -dport 443
174 Then, you can add this group in a vm firewall
177 # /etc/pve/firewall/<VMID>.fw
187 IP Aliases allows you to associate IP addresses of Networks with a
188 name. You can then refer to those names:
190 * inside IP set definitions
191 * in `source` and `dest` properties of firewall rules
193 Standard IP alias `local_network`
194 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196 This alias is automatically defined. Please use the following command
197 to see assigned values:
200 # pve-firewall localnet
201 local hostname: example
202 local IP address: 192.168.2.100
203 network auto detect: 192.168.0.0/20
204 using detected local_network: 192.168.0.0/20
207 The firewall automatically sets up rules to allow everything needed
208 for cluster communication (corosync, API, SSH).
210 The user can overwrite these values in the cluster.fw alias
211 section. If you use a single host on a public network, it is better to
212 explicitly assign the local IP address
215 # /etc/pve/firewall/cluster.fw
217 local_network 1.2.3.4 # use the single ip address
223 IP sets can be used to define groups of networks and hosts. You can
224 refer to them with `+name` in firewall rules `source` and `dest`
227 The following example allows HTTP traffic from the `management` IP
230 IN HTTP(ACCEPT) -source +management
232 Standard IP set `management`
233 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235 This IP set applies only to host firewalls (not VM firewalls). Those
236 ips are allowed to do normal management tasks (PVE GUI, VNC, SPICE,
239 The local cluster network is automatically added to this IP set (alias
240 `cluster_network`), to enable inter-host cluster
241 communication. (multicast,ssh,...)
244 # /etc/pve/firewall/cluster.fw
251 Standard IP set 'blacklist'
252 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
254 Traffic from those ips is dropped in all hosts and VMs firewalls.
257 # /etc/pve/firewall/cluster.fw
264 Standard IP set 'ipfilter'
265 ^^^^^^^^^^^^^^^^^^^^^^^^^^
267 This ipset is used to prevent ip spoofing
270 /etc/pve/firewall/<VMID>.fw
272 [IPSET ipfilter-net0] # only allow specified IPs on net0
276 Services and Commands
277 ~~~~~~~~~~~~~~~~~~~~~
279 The firewall runs two service daemons on each node:
281 * pvefw-logger: NFLOG daemon (ulogd replacement).
282 * pve-firewall: updates iptables rules
284 There is also a CLI command named 'pve-firewall', which can be used to
285 start and stop the firewall service:
290 To get the status use:
292 # pve-firewall status
294 The above command reads and compiles all firewall rules, so you will
295 see warnings if your firewall configuration contains any errors.
297 If you want to see the generated iptables rules you can use:
307 FTP is an old style protocol which uses port 21 and several other dynamic ports. So you
308 need a rule to accept port 21. In addition, you need to load the 'ip_conntrack_ftp' module.
311 modprobe ip_conntrack_ftp
313 and add `ip_conntrack_ftp` to '/etc/modules' (so that it works after a reboot) .
315 Suricata IPS integration
316 ^^^^^^^^^^^^^^^^^^^^^^^^
318 If you want to use the http://suricata-ids.org/[Suricata IPS]
319 (Intrusion Prevention System), it's possible.
321 Packets will be forwarded to the IPS only after the firewall ACCEPTed
324 Rejected/Dropped firewall packets don't go to the IPS.
326 Install suricata on proxmox host:
329 # apt-get install suricata
330 # modprobe nfnetlink_queue
333 Don't forget to add `nfnetlink_queue` to '/etc/modules' for next reboot.
335 Then, enable IPS for a specific VM with:
338 # /etc/pve/firewall/<VMID>.fw
345 `ips_queues` will bind a specific cpu queue for this VM.
347 Available queues are defined in
350 # /etc/default/suricata
356 include::copyright.adoc[]