Open nat masquerading and port forwarding on ufw

Possible until now,You have been very skilled how to open nat and port forwarding on Linux - after all, this operation may also require a server at the time of deployment。But its operation is too cumbersome,Especially when we use edit iptables ufw after that,But you can not directly edit the iptables,This time in the end what to do it?

wantUse ufw to open nat masquerading and port forwarding,You can refer to this articleUnder Ubuntu more simple firewall Uncomplicated FirewallLook at the front end of the firewall ufw,In fact, it gives us a more advanced operations,使用 ufw,Avoid to edit iptables、Backup iptables and set boot automatically restore iptables,Thus,Configuration is much simpler。

First of all,We need

Change ufw default forwarding policy

Locate the file "/etc/default/ufw

Modify the content:

Open forwarding

edit"/etc/ufw/sysctl.conf"file,The inside of the forwarding options uncomment(If you want to open ipv6 forwarding,Then put ipv6 Notes also removed)

Add Forwarding Entry

At last,We edit "/etc/ufw/before.rules'File to add an entry to forward - and grammar iptables Identical Syntax,After the end of the file contents inside "COMMIT" new line:

 

Open Port Forwarding

Written above * nat inside the block is inserted below the command to:

Restart ufw configuration to take effect

Original article written by Gerber drop-off:R0uter's Blog » Open nat masquerading and port forwarding on ufw

Reproduced Please keep the source and description link:https://www.logcg.com/archives/993.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Comments

Leave a Reply

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