I've got my Ubuntu box acting as a router / firewall for my network and everything is working fine. I need to forward some ports into my network, but I'm unsure how to do this. I have the proper iptables command to enable it, and if I run it from the command line, it works. I imagine the rule has to go into /etc/ufw/before.rules, but I don't know where.
iptables code that works:
ufw status:Code:sudo iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 50002 -j DNAT --to 192.168.100.20
/etc/ufw/before.rules:Code:To Action From -- ------ ---- Anywhere ALLOW 192.168.100.0/24 22:tcp ALLOW Anywhere 22:udp ALLOW Anywhere 192.168.100.20 50002:tcp ALLOW Anywhere 192.168.100.20 50002:udp ALLOW Anywhere
Code:# rules.before # # Rules that should be run before the ufw command line added rules. Custom # rules should be added to one of these chains: # ufw-before-input # ufw-before-output # ufw-before-forward # # nat Table rules *nat :POSTROUTING ACCEPT [0:0] # Forward traffic from eth1 through eth0. -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE # don't delete the 'COMMIT' line or these nat table rules won't be processed COMMIT # Don't delete these required lines, otherwise there will be errors *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 -i lo -j ACCEPT # connection tracking rules -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT # drop INVALID packets # uncomment to log INVALID packets #-A ufw-before-input -m conntrack --ctstate INVALID -j LOG --log-prefix "[UFW BLOCK INVALID]: " -A ufw-before-input -m conntrack --ctstate INVALID -j DROP # connection tracking for outbound -A ufw-before-output -p tcp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT -A ufw-before-output -p udp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT # ok icmp codes -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 # 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 -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j LOG --log-prefix "[UFW BLOCK NOT-TO-ME]: " # all other non-local packets are dropped -A ufw-not-local -j DROP # allow MULTICAST, be sure the MULTICAST line above is uncommented -A ufw-before-input -s 224.0.0.0/4 -j ACCEPT -A ufw-before-input -d 224.0.0.0/4 -j ACCEPT # don't delete the 'COMMIT' line or these rules won't be processed COMMIT



Adv Reply




Bookmarks