1

I have a home server running Kubuntu 14.04. It serves a web page to the outside world and provides internet access to all devices on my home LAN. I have an Arduino device with a web server application for reporting temperature. I wish to use my Android phone to connect to the Arduino web page.

I use UFW for configuring my firewall and wish to forward requests to my home server using port 225 to the Arduino web page, configured to listen to port 225.

I can reach the Arduino from anywhere on my home LAN, but not from the outside. I've researched and tried many things but am unsuccessful. Sites like "check your ports" report back that port 225 is closed.

Any help is greatly appreciated!

1

Try this

Check first with cat /proc/sys/net/ipv4/ip_forward is response 0 or 1. If is 0 run command

 sudo echo 1 >/proc/sys/net/ipv4/ip_forward

This will enable ip forwarding

Then edit and add before filter section in /etc/ufw/before.rules(top of file):

 sudo nano etc/ufw/before.rules


*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp --dport 225 -j DNAT --to-destination ip_address_of_Arduino
COMMIT

Then restart ufw.

Problem is place of the rule.

Your *nat table is on begining and can not show again at the end of file . Move your rule from line 82 belowe PREROUTING

Should look like this

*nat
:PREROUTING ACCEPT [0:0]
# Port fw
-A PREROUTING -i eth0 -p tcp --dport 225 -j DNAT --to-destination      ip_address_of_Arduino

:POSTROUTING ACCEPT [0:0] 
# Forward traffic from eth1 through eth0. 
-A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE 

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

After this start table *filter and the rest of ufw configuration.

|improve this answer|||||
  • Thank you! I had tried something like your statement, however, it was in the wrong place in the before.rules file. I got hung up trying to accomplish this thru the GUI, rather than using a console shell. – John Zbesko Aug 21 '15 at 0:53
  • Spoke too soon. Following the above procedure works, but is not persistent, that is, if I reboot the server, I have to manually stop and restart ufw. – John Zbesko Aug 21 '15 at 1:10
  • When I manually do so, I get the error message: ERROR: problem running ufw-init Bad argument *nat' Error occurred at line: 82 Try iptables-restore -h' or 'iptables-restore --help' for more information. Problem running '/etc/ufw/before.rules' – John Zbesko Aug 21 '15 at 1:16
  • (At end of file) Line 82: # nat Table rules *nat :POSTROUTING ACCEPT [0:0] # Forward traffic from eth1 through eth0. -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE # don't delete the 'COMMIT' line or these rules won't be processed COMMIT – John Zbesko Aug 21 '15 at 1:19
  • I edited answer – 2707974 Aug 21 '15 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.