Skip to content

Instantly share code, notes, and snippets.

@lynus
Created August 24, 2012 06:39
Show Gist options
  • Save lynus/3446706 to your computer and use it in GitHub Desktop.
Save lynus/3446706 to your computer and use it in GitHub Desktop.
openwrt:allow wan ssh into your wrt
by default,openwrt do not allow ssh access from wan, here are two method to change that:
1.login into your wrt from a lan host.issue the following command:
iptables -F
the command "flush away" all the firewall rules,including the one that rejects ssh request from wan.
now you can try ssh from anywhere.
aware that the firewall deactivation leads to highly security risk.and after the wrt restarts ,all default firewall configuration comes back.you hava to "flush" the rules once again.
2.add the following lines in /etc/config/firewall :
config rule
option src wan
option dest_port 22
option target ACCEPT
option proto tcp
after restart ('reboot' commmand),wrt accept port 22 request (in this case ,ssh request)from wan.
@pjobson
Copy link

pjobson commented Dec 11, 2022

10 years later thanks @lynus !

@lynus
Copy link
Author

lynus commented Jan 2, 2023

10 years later thanks @lynus !

You are welcome! I cannot believe it's 10 years. How time flies.

@kada-chu
Copy link

11 years later thanks @lynus 👍

@xros
Copy link

xros commented Nov 7, 2023

It works. For recent OpenWRT destros, you would need to add ' mark

config rule
        option src              'wan'
        option dest_port        '22'
        option target           'ACCEPT'
        option proto            'tcp' 

@abdulbasetbasher
Copy link

12 years later thank you @lynus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment