I have a RaspberryPi 2 with an IP camera (SND-7084) connected to it with static IP When browsing in the RPi to I can see the video streaming from the camera.

I want to be able to add a WiFi dongle to the RPi and connect to the streaming video from any computer in my home network by clicking the RPi wlan0 IP. for example: browsing to (the RPi wlan0 IP and a new port) will be routed to the eth0 IP

can this be done?

I found this LINK which forward all wlan0 ports to eth0 but I want to be able to use the RPi for other services in different ports (80,443,22,etc.)


  • Please netstat -nap | grep -w 4567
    – fcm
    Jan 6, 2016 at 21:49

1 Answer 1


Assuming you're running trusty ol' iptables on your Pi (i.e. you haven't replaced it with something else), run this command (either as root or with sudo) on your Pi:

iptables -t nat -A PREROUTING -p tcp --dport 5555 -i wlan0 \
         -j DNAT --to

You might have to do echo 1 > /proc/sys/net/ipv4/ip_forward before this will work, but I think that's only necessary for "regular" NAT (i.e. if you were running your Pi as your network's edge router/gateway).

This command does the following:

  1. -t nat -A PREROUTING Without too much detail, this is where we put rules like this one
  2. -p tcp Selects the TCP protocol
  3. --dport 5555 Matches incoming traffic to the Pi's port 5555
  4. -i wlan0 Matches traffic coming in on the Pi's wlan0 interface
  5. -j DNAT Tells iptables we're doing "Destination Network Address Translation", aka "port forwarding"
  6. --to This is the host we're forward traffic that has matched the rest of this rule to

If you want to use a different port on the Pi, just change the --dport 5555 to whatever port you want to use; if you ever change the IP or port of your camera, change the --to part to match.

The above rule assumes you're using a TCP protocol (e.g. HTTP(S)) to connect to the camera, an assumption I came to because you used the word "browsing", which suggests a web browser. If you're using a UDP client instead (the specs mention it supports both TCP and UDP), change the -p tcp to -p udp. You could even do two versions of this rule, one for TCP and one for UDP, to support both!

  • @Fcm If this were a USB webcam, you'd be correct. Since this is an IP camera running across the network that the Pi's eth0 is connected to (or possibly directly connected to), then you have to NAT to the camera if you want it to be the "bridge" from the wlan network.
    – Kromey
    Jan 7, 2016 at 1:21
  • you are right, a bridge will do it. My comment deleted.
    – fcm
    Jan 7, 2016 at 1:30
  • Did what you said but I am facing another problem now.. When the Wlan0 network is connected then eth0 not working.. Any ideas?? Thanks..
    – user28282
    Jan 7, 2016 at 20:16
  • 1
    @user28282 Make sure wlan0 and eth0 are both using different subnets; beyond that, there's too little to go on, but in any case it's really an entirely different question altogether.
    – Kromey
    Jan 7, 2016 at 20:21
  • Sorry about that, changed the subnets and now everything is working..
    – user28282
    Jan 10, 2016 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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