Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for port forwarding #25

Open
egeexyz opened this issue Nov 21, 2018 · 5 comments
Open

Add example for port forwarding #25

egeexyz opened this issue Nov 21, 2018 · 5 comments

Comments

@egeexyz
Copy link

egeexyz commented Nov 21, 2018

The examples in the readme are quite good, however there is not an example that features Port Forwarding.

It would be great for folks looking for a comprehensive ufw role that supports port forwarding to see one in the examples because it is not clear from the readme if this role supports it.

@tersmitten
Copy link
Member

I have no idea too, do you have a terminal (or generic ansible) example?

@oneslash
Copy link

oneslash commented Jan 4, 2019

I have managed to do it with

- name: insert port forwarding for ufw
  lineinfile:
    dest: /etc/ufw/before.rules
    line: "{{ item }}"
  with_items:
    - '*nat'
    - ':POSTROUTING ACCEPT [0:0]'
    - "-A POSTROUTING -s {{  }} -o ens5 -j MASQUERADE \nCOMMIT"

@tersmitten
Copy link
Member

I think it would be better to template /etc/ufw/before.rules. See https://github.com/Oefenweb/ansible-dnsmasq/blob/master/templates/etc/default/dnsmasq.j2 for instance

@tersmitten
Copy link
Member

But there're probably more files that (might) need templating:

-rw-r-----   1 root root  915 jul 19  2017 after6.rules
-rw-r-----   1 root root 1,1K jul 19  2016 after.init
-rw-r-----   1 root root 1004 jul 19  2017 after.rules
drwxr-xr-x   2 root root 4,0K dec 11 06:14 applications.d
-rw-r-----   1 root root 6,3K jul 19  2017 before6.rules
-rw-r-----   1 root root 1,2K jul 19  2016 before.init
-rw-r-----   1 root root 2,7K jul 19  2017 before.rules
-rw-r--r--   1 root root 1,9K apr 15  2016 sysctl.conf
-rw-r--r--   1 root root  313 mrt 26  2018 ufw.conf
-rw-r-----   1 root root 1,6K jul  6  2018 user6.rules
-rw-r-----   1 root root 1,6K jul  6  2018 user.rules

@tersmitten
Copy link
Member

See #21

@tersmitten tersmitten added this to the 4.1.0 milestone Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants