#StackBounty: #raspberry-pi #vnc #port-forwarding #jessie VNC over Raspberry Pi router using port forwarding

Bounty: 100

I have configured Raspberry Pi as a router and access point for client devices, and it works without problem.

It works with usage of hostapd and isc-dhcp-sever programs, but there is a challenge: enabling VNC connections through the Raspberry Pi router. Below you can find schematics of what has been done.

intranet <--> [x.x.x.x|eth0] Raspberry Pi 2 [192.168.1.1/24|wlan0] <--> clients

My idea was to enable for port forwarding in rc.local file, but it is not executing code for some unknown reason.

Below you can find content of the rc.local file:

# enable VCN port forwarding
vncport=5900
for (( counter=0; counter<91; counter++ ))
do
    port=$[10010+counter]
    address=$[10+counter]
    iptables -A PREROUTING -t nat -i eth0 -p tcp --dport "$port" -j DNAT --to 192.168.1."$address":"$vncport"
    iptables -A FORWARD -p tcp -d 192.168.1."$address" --dport "$port" -j ACCEPT
done

# access point code
iptables -A FORWARD -o eth0 -i wlan0 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
exit 0


Get this bounty!!!

Leave a Reply