Sunday, June 14, 2015

Port Forwarding on OpenWRT

Port forwarding for home users is needed if they have some server or service running on their PC that others on the internet need to access (gaming server for example).
File you need to edit is /etc/config/firewall and for reference also check out /etc/config/firewall#forwarding.ports.destination.natdnat
What most of people want is just to forward some specific port from router to some other machine, and that is done simply adding new redirect rules to your /etc/config/firewall or /etc/firewall.user files.
config 'redirect'
        option 'name' 'some awesome game'
        option 'src' 'wan'
        option 'proto' 'tcpudp'
        option 'src_dport' '2222'
        option 'dest_ip' '192.168.1.100'
        option 'target' 'DNAT'
        option 'dest' 'lan'
Or if you wan't to hide on which port is your service running for security reasons you can redirect port 5555 to port 22 on your linux server running ssh
config 'redirect'
        option 'name' 'ssh'
        option 'src' 'wan'
        option 'proto' 'tcpudp'
        option 'src_dport' '5555'
        option 'dest_ip' '192.168.1.100'
        option 'dest_port' '22'
        option 'target' 'DNAT'
        option 'dest' 'lan'
To make the changes active, run /etc/init.d/firewall restart.

On your home router: web GUI -> network -> firewall -> Redirections
Set up the following rule will do port forwarding to your server (in my case, it is host 192.168.1.189 on my LAN). This worked for me.

No comments:

Post a Comment