UFW Prerouting

Francisco PeƱaranda francisco.penaranda at gmail.com
Wed Jan 16 00:29:19 UTC 2019


Dear Community, I have a problem with ufw before.rules, I would like to get
input from my outside network card (enp3s1:1) 190.XXXX.XXXX.XXXX to my
internal network (eno1) 172.19.170.5 specifically to one lan computer
172.19.170.163.

This is my before.rules *nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
# Port forwarding
-A PREROUTING -i enp3s1:1 -p tcp --dport 80 -j DNAT --to-destination
172.19.170.163:80
-A PREROUTING -i enp3s1:1 -p tcp --dport 20248 -j DNAT --to-destination
172.19.170.163:20248

#postrouting outside
-A POSTROUTING -s 172.19.170.0/24 -o enp3s1 -j MASQUERADE
COMMIT*filter
:ufw-before-input - [0:0]
:ufw-before-output - [0:0]
:ufw-before-forward - [0:0]
:ufw-not-local - [0:0]

# End required lines


# allow all on loopback
-A ufw-before-input -i lo -j ACCEPT
-A ufw-before-output -o lo -j ACCEPT

# quickly process packets for which we already have a connection
-A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A ufw-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

# drop INVALID packets (logs these in loglevel medium and higher)
-A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny
-A ufw-before-input -m conntrack --ctstate INVALID -j DROP

# ok icmp codes for INPUT
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT

# ok icmp code for FORWARD
-A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT

# allow dhcp client to work
-A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT

#
# ufw-not-local
#
-A ufw-before-input -j ufw-not-local

# if LOCAL, RETURN
-A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN

# if MULTICAST, RETURN
-A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN

# if BROADCAST, RETURN
-A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN

# all other non-local packets are dropped
-A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny
-A ufw-not-local -j DROP

# allow MULTICAST mDNS for service discovery (be sure the MULTICAST line
above
# is uncommented)
-A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT

# allow MULTICAST UPnP for service discovery (be sure the MULTICAST line
above
# is uncommented)
-A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT

#port forwarding
-A FORWARD -p tcp -d 172.19.170.163 --dport 80 -j ACCEPT
-A FORWARD -p tcp -d 172.19.170.163 --dport 20248 -j ACCEPT
-A FORWARD -p udp -d 172.19.170.163 --dport 20248 -j ACCEPT

# don't delete the 'COMMIT' line or these rules won't be processed
COMMIT

----------------------------------------------------------------
Some Ideas?

Thanks

Francisco PeƱaranda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20190115/b3ed7b6e/attachment.html>


More information about the ubuntu-users mailing list