Port forward to wireless client

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Goto page 1, 2  Next
Author Message
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Sun Jun 29, 2014 14:30    Post subject: Port forward to wireless client Reply with quote
This is an offshoot of my questions on another thread. That thread may be overcomplicating the situation, so I wanted to just ask about the simplest issue at hand.

I have two wireless security cameras that run a webserver on port 80. I want to access those cameras from outside the router. I've setup port forwards, however I can never establish a connection to either camera. The browser will just time out. Port forwards to wired clients work just fine, it's only to wireless clients that I have this problem. If I ssh into the router setting up a SOCKS proxy port, then I can access the cameras using that proxy.

It appears it has something to do with the bridging of the wired/wireless networks when dealing with port forwards.

Here is a dump of the iptables. The cameras are on IP addresses, 192.168.1.201/203. Any other forwards you see there are wired client ports that work.

Code:

root@BUFFALO-IPCAM:~# iptables -vnL && iptables -t nat -vnL
Chain INPUT (policy ACCEPT 2727 packets, 1920K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 logdrop    tcp  --  vlan2  *       0.0.0.0/0            0.0.0.0/0           tcp dpt:23

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 logaccept  0    --  br0    br0     0.0.0.0/0            0.0.0.0/0           
  104  5408 TCPMSS     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp flags:0x06/0x02 TCPMSS clamp to PMTU
  594 45941 lan2wan    0    --  *      *       0.0.0.0/0            0.0.0.0/0           
  541 43161 logaccept  0    --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
    0     0 logaccept  udp  --  vlan2  *       0.0.0.0/0            224.0.0.0/4         
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.221       tcp dpt:80
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.221       tcp dpt:6001
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.221       tcp dpt:6002
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.221       tcp dpt:6003
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.201       tcp dpt:80
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.203       tcp dpt:80
    0     0 logaccept  tcp  --  *      *       0.0.0.0/0            192.168.1.201       tcp dpt:21
    0     0 TRIGGER    0    --  vlan2  br0     0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
   53  2780 trigger_out  0    --  br0    *       0.0.0.0/0            0.0.0.0/0           
   53  2780 logaccept  0    --  br0    *       0.0.0.0/0            0.0.0.0/0           state NEW

Chain OUTPUT (policy ACCEPT 1140 packets, 535K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain advgrp_1 (0 references)
 pkts bytes target     prot opt in     out     source               destination         

---- snip same info for advgrp_2 to advgrp_10 ----

Chain grp_1 (0 references)
 pkts bytes target     prot opt in     out     source               destination         

---- snip same info for Chain grp_2 to Chain grp_10 ----

Chain lan2wan (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain logaccept (11 references)
 pkts bytes target     prot opt in     out     source               destination         
  594 45941 ACCEPT     0    --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain logdrop (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DROP       0    --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain logreject (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 REJECT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           reject-with tcp-reset

Chain trigger_out (1 references)
 pkts bytes target     prot opt in     out     source               destination         
Chain PREROUTING (policy ACCEPT 4195 packets, 2115K bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:8080 to:192.168.1.1:80
    2   112 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:22 to:192.168.1.1:22
    0     0 DNAT       icmp --  *      *       0.0.0.0/0            192.168.123.220     to:192.168.1.1
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:80 to:192.168.1.221:80
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:6001 to:192.168.1.221:6001
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:6002 to:192.168.1.221:6002
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:6003 to:192.168.1.221:6003
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:20081 to:192.168.1.201:80
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:20083 to:192.168.1.203:80
    0     0 DNAT       tcp  --  *      *       0.0.0.0/0            192.168.123.220     tcp dpt:20021 to:192.168.1.201:21
    0     0 TRIGGER    0    --  *      *       0.0.0.0/0            192.168.123.220     TRIGGER type:dnat match:0 relate:0

Chain INPUT (policy ACCEPT 1384 packets, 1322K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 64 packets, 6499 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 64 packets, 6499 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   53  2780 SNAT       0    --  *      vlan2   192.168.1.0/24       0.0.0.0/0           to:192.168.123.220
    0     0 RETURN     0    --  *      br0     0.0.0.0/0            0.0.0.0/0           PKTTYPE = broadcast


Last edited by brucehvn on Sat Jul 26, 2014 23:20; edited 2 times in total
Sponsor
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Tue Jul 01, 2014 5:06    Post subject: Reply with quote
By the way, I should mention I've tried this with 4 different routers, 3 were dd-wrt based, and one wasn't and still couldn't get this working. Is there some inherent inability for routers in general to port forward a service on a wireless client? If so, is there something I can do via IPTABLES, etc. to make this work?
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Sat Jul 26, 2014 1:17    Post subject: Reply with quote
Does anyone have any ideas on this? I would really like to get port forwards to work. I'm doing this so my home automation gateway can grab images from the cameras. I've currently hacked it up so the home automation gateway creates an ssh connection into the camera router setting up ssh tunnel connections to each camera. This works, but it requires me to monitor the connection in the gateway and restore it if it goes bad or if the cameras cannot be accessed.

It would be much simpler if the port forwards just worked.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Sat Jul 26, 2014 15:04    Post subject: Reply with quote
Port forwarding is to an ip address. It does not matter ip the destination is on a wlan or on cable.

You can only forward port 80 to a single unit. For the other camera, use port 81. In the browser the url must end with :81.

Use VPN to access your local network. That will give access to all resources.
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Sat Jul 26, 2014 23:09    Post subject: Reply with quote
Per Yngve Berg wrote:
Port forwarding is to an ip address. It does not matter ip the destination is on a wlan or on cable.

You can only forward port 80 to a single unit. For the other camera, use port 81. In the browser the url must end with :81.

Use VPN to access your local network. That will give access to all resources.


Thanks for your reply. I do know how to setup port forwards and am doing that correctly. I've turned off UPNP. I'm also forwarding other wired clients on that router and have no problem, it's only with the wireless clients. I cannot access them through the port forwards. That's the frustrating part. As I said, I've tried 4 different routers. With all of them, I can access wired clients through port forwards, but not the wireless devices.

Obviously, internally there's a bridge setup between the wired and wireless networks so they can all act as one network. What it appears to me is that something is not allowing packets through port forwards to make it across that bridge.

VPN is not an option in this case. That's essentially what I'm doing with the SSH tunnels through the router. I really want to use the port forwards instead, and I don't understand why they aren't working.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Sun Jul 27, 2014 8:27    Post subject: Reply with quote
Can you access the cameras from a lan port?
Is the camera connected over wifi?

Do the cameras have a static ip address or a static dhcp lease?
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Sun Jul 27, 2014 13:13    Post subject: Reply with quote
Per Yngve Berg wrote:
Can you access the cameras from a lan port?
Is the camera connected over wifi?

Do the cameras have a static ip address or a static dhcp lease?


Yes, I can access the cameras fine from within the camera router's network. And the SSH tunnels I create from outside also work.

The cameras are wi-fi and have static IP addresses. If you look at the IPTABLE dump in my first post, the cameras are 192.168.1.201 and 192.168.1.203. 192.168.1.221 is the NVR which is a wired network device. I'm forwarding ports 80, 6001, 6002, and 6003 on it and that all works fine. No problem accessing it through the port forwards. When trying to access the cameras through the port forwards, it doesn't come back with an error such as connection refused or anything like that. It just times out.

Oh, and I've disabled the firewall completely on the camera router.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Sun Jul 27, 2014 20:17    Post subject: Reply with quote
For any tunneling you need a device at both ends.

There is a EoIP client for Linux.

http://www.serveradminblog.com/2014/01/eoip-tunnel-on-linux/
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Mon Jul 28, 2014 5:46    Post subject: Reply with quote
Per Yngve Berg wrote:
For any tunneling you need a device at both ends.

There is a EoIP client for Linux.

http://www.serveradminblog.com/2014/01/eoip-tunnel-on-linux/


I'm not sure I understand what you are saying. I'm able to SSH to the camera router and by using the -L param, I can setup SSH tunnels to the two cameras. That works, but it's very troublesome to maintain that connection and reconnect as necessary. It's just an ugly hack to work around the fact the port forwards won't work like they should.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Mon Jul 28, 2014 13:44    Post subject: Reply with quote
There must be some protocol or port you have missed.

What make and model is the cameras?
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Mon Jul 28, 2014 19:45    Post subject: Reply with quote
Per Yngve Berg wrote:
There must be some protocol or port you have missed.

What make and model is the cameras?


The cameras are Sinocam IPC-3016R. What the home automation gateway needs to do is pull a single frame from the camera which it would do by using the URL http://<cameraip>/cgi-bin/anv/images_cgi?channel=0&user=*****&pwd=*****

What I've done is have the home automation gateway SSH to the router and open tunnels to port 80 on the cameras. The SSH command being issued is:

Code:
ssh -N -f -i /root/.ssh/id_vera_rsa -L 20201:192.168.1.201:80 -L 20203:192.168.1.203:80 -I 0 root@192.168.123.220


192.168.123.220 is the camera router.

Once that is done, then it can grab an image from camera 1 by using the URL:

http://localhost:20201/cgi-bin/anv/images_cgi?channel=0&user=*****&pwd=*****

and that works. I can grab the images with no problem.

Attached is an image of my port forward screen on the camera router. The cameras are forwarded to ports 20081 and 20083. Based on the above, I should be able to go into a browser and type:

http://192.168.123.220:20081/cgi-bin/anv/images_cgi?channel=0&user=*****&pwd=*****

but that just times out. The cameras also support telnet access. I have camera 1's telnet port forwarded to port 20021. Trying to connect to that also fails with a timeout after about 60 seconds or whatever the default timeout is.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Tue Jul 29, 2014 6:27    Post subject: Reply with quote
What network is 192.168.123.0? Is it one you have control over?
It's a private address. Why running NAT?

Have you tried to put the camer in the DMZ?

Check the firewall logs for blocked packets.

Security->Firewall->Log Management
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Wed Jul 30, 2014 17:16    Post subject: Reply with quote
Have you tried to enter 0.0.0.0 as Source Net in the Forwards?
There are other threads that indicate that Forwards does not work with the Source Net blank on some builds.
brucehvn
DD-WRT User


Joined: 06 Jul 2008
Posts: 54

PostPosted: Wed Jul 30, 2014 18:19    Post subject: Reply with quote
Per Yngve Berg wrote:
What network is 192.168.123.0? Is it one you have control over?
It's a private address. Why running NAT?

Have you tried to put the camer in the DMZ?

Check the firewall logs for blocked packets.

Security->Firewall->Log Management


192.168.123.0 is my main router for my home. Since the cameras use a lot of bandwidth constantly streaming to the NVR, I put the whole system on it's own wireless router behind the main router. The camera router is at 192.168.123.220 on the main network.

I don't remember if I tried putting a camera in the DMZ. I will disable the current forward for port 80 (that goes to the NVR) and put one camera in the DMZ and see what happens.

The firewall is disabled on the camera router. I can turn on and check the logs on the main router. I think I've done that before and they just show nothing related to my requests to the cameras, but I'll check it out.
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6870
Location: Romerike, Norway

PostPosted: Wed Jul 30, 2014 18:37    Post subject: Reply with quote
Turn off NAT by changing the router from "Gateway" to "Router"

Then you can route from 192.168.123.0 to 192.168.1.0 without any port forwards.

Note: Traffic from one lan port to the other will be handled by the switch and does not stress the router.
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum