By capey0
Hi all
I am relatively new to UFW and iptables.
I need the following port forwarding to be permanent: iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT iptables -A INPUT -i eth0 -p tcp --dport 8443 -j ACCEPT iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
I have enabled UFW and made settings in there as well.
When rebooting the UFW settings remain but the iptables settings disappear.
How do I make them permanent? Preferably via UFW - if possible.
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
UFW is a simple frontend for IPtables, and does not allow you to configure everything that IPtables does. Though it does make many common task easier. If you have more complex firewall rules you need to setup, you can use the files:
/etc/ufw/before.rules
/etc/ufw/after.rules
Placing IPtables rules in before.rules will apply those rules before starting UFW. Likewise, rules placed in after.rules will be applied after UFW has started in case the order matters.
There are also the files:
/etc/ufw/after.init
/etc/ufw/before.init
They behave similarly, except that you can execute any arbitrary script rather than just IPtables rules.
You can find more information on UFW in this tutorial:
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.