UFW IP Masquerade

Навигация

Оригинал статьи здесь.

Enable Forward policy first.

root@dlp:~# vi /etc/default/ufw
# line 19 : change
DEFAULT_FORWARD_POLICY="ACCEPT"
root@dlp:~# vi /etc/sysctl.conf
# line 28 : uncomment
net.ipv4.ip_forward=1
# reload settings
root@dlp:~# sysctl -p
root@dlp:~# ufw reload

In addition to the UFW default setting, add rules that computers in Internal network can connect to external network or internet via [10.0.0.30] as a gateway

root@dlp:~# ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), allow (routed)
New profiles: skip

root@dlp:~# vi /etc/ufw/before.rules
.....
.....
# don't delete the 'COMMIT' line or these rules won't be processed
COMMIT

# add to the end
# NAT
*nat
-F
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 10.0.0.0/24 -o enp1s0 -j MASQUERADE

COMMIT

root@dlp:~# ufw reload