brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: allow IPsec in ufw with proto esp and proto ah

Ufw
~/tips/tip-ufw-proto-esp-ah-ipsec

sudo ufw allow to 10.0.0.1 proto esp

IPsec uses protocols 50 and 51, so a normal port rule does not cover it.

A port rule can’t help with IPsec traffic, because ESP and AH are protocols of their own and have no ports. ufw does have a way to write these rules, but the man page says it only works in one syntax.

sudo ufw allow to 10.0.0.1 proto esp
sudo ufw allow to 10.0.0.1 proto ah

According to the man page, IPsec is supported through the esp (protocol 50) and ah (protocol 51) protocols. You can restrict a rule to a source network as well:

sudo ufw allow to 10.0.0.1 from 10.4.0.0/16 proto esp

That lets ESP traffic from that network reach the host at 10.0.0.1. Your VPN software may need more rules on top of this, so check its documentation for the rest.

The caveat is in the man page: these protocols can only be used with the full syntax. Something like ufw allow esp does not fit that rule, so spell it out with to and proto. The same goes for ah, gre, vrrp, ipv6 and igmp. They are not enabled when you leave out the protocol, and ESP, AH, GRE and VRRP rules take no port number.

Further reading: ufw man page

Going deeper: Why a Tailscale device vanishes after 180 days, and how to stop it

More Ufw tips sudo ufw app update all sudo ufw show raw sudo ufw allow to 224.0.0.0/24 from 10.0.0.1 proto vrrp sudo ufw show listening grep IPV6 /etc/default/ufw All Ufw tips (32) All topics

Link