Skip to content

software/mail-server-relay: add bin/port-forward-setup with down mode

utils/ports.sh was nice but had issues:

  • it deleted all iptables rules of the host
  • operator had to manually fill in IP and infos about the relay
  • rules did not stay after a reboot

MR replaces it by bin/port-forward-setup which is prefilled with the IPv4 & 6 addresses and the SMTP & submission ports of the partition.

sudo /srv/slapgrid/slappartN/bin/port-forward-setup up    # default
sudo /srv/slapgrid/slappartN/bin/port-forward-setup down
  • up mode forwards ports 25 and 587 of the host to the inbound postfix, for IPv4 and IPv6. Outgoing IPv4 mail of the relay uses the address of the host, because the partition IPv4 address is private.
  • down mode does the same as up, but also refuses new connections from other hosts to the inbound postfix and to the submission postfix, with a TCP reset. Remote mail servers then try the next MX record immediately. Mail backends try the next relay address immediately. Connections from the relay host (promises, manual tests), open connections and outgoing mail continue to work.

The script now uses nft instead of iptables to set rules, in a dedicated table (so it doesn't clobber global rules). Rules are applied are startup using a systemd service (mail-relay-ports.service).

Merge request reports