Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit ssh attempts to WAN zone #120

Merged
merged 9 commits into from
Jan 22, 2015
15 changes: 14 additions & 1 deletion default-files/etc/config/firewall
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

config defaults
option syn_flood '1'
option input 'DROP'
Expand Down Expand Up @@ -61,6 +60,17 @@ config forwarding
config rule
option src 'wan'
option dest_port '22'
option proto 'tcp'
option state 'NEW'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no 'state' option in the OpenWRT wiki's page about the UCI firewall, as far as I can see. Is this an undocumented option?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I could have sworn I read it on one of the openwrt wiki pages or forum posts but now I can't find it. State is supported by iptables. The closest I can find in the UCI documentation is "The iptables rules generated for this section rely on the state match." I must have guessed at it.

option limit '3/min'
option limit_burst '2'
option target 'LOG'

config rule
option src 'wan'
option dest_port '22'
option state 'RELATED'
option state 'ESTABLISHED'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be two state options here. Is this intentional (it's sorta valid), or is it supposed to be a list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentional. I wasn't totally sure whether I could put two state options in a single config rule, but it seems to work. I could break it out if you want.

option target 'ACCEPT'
option proto 'tcp'

Expand Down Expand Up @@ -167,3 +177,6 @@ config rule
option src 'vpn'
option proto 'icmp'
option target 'ACCEPT'

config include
option path '/etc/firewall.user'