Categories
Development Linux Ubuntu

iptable change that survives a reboot

I am using the following command to make my UniFi Controller instance available at https://unifi.mydomain.org instead of https://unifi.mydomain.org:8443.

sudo iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443

I want this setting to survive a restart. I’ve tried to add this line (prepended with @reboot) to my crontab file but it doesn’t seem to take. Can anyone tell me what I’m doing wrong? Here’s my crontab entry:

@reboot /sbin/iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443

Edit: I am running Ubuntu 18.04.3 (in response to comment below)

Solved: I needed a blank line at the bottom of my crontab file.

Leave a Reply

Your email address will not be published. Required fields are marked *