I'm having an issue with my OpenWrt router where my SSH service is still accessible from the WAN on port 66 despite having configured my firewall rules to block it. I'm hoping someone can help me troubleshoot this issue.
Here are the firewall rules I have set up:
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone
option name 'DMZ'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'DMZ'
config zone
option input 'ACCEPT'
option output 'ACCEPT'
option name 'WAN'
option masq '1'
option forward 'ACCEPT'
list network 'wan'
config forwarding
option src 'DMZ'
option dest 'WAN'
config rule
option name 'REJECT'
option src 'WAN'
option src_port '66'
option dest '*'
option dest_port '66'
option target 'REJECT'
config rule
option name 'ALL'
option dest 'WAN'
option target 'ACCEPT'
option src '*'
list proto 'all'
config forwarding
option src 'HOME'
option dest 'WAN'
config forwarding
option src 'WAN'
option dest 'HOME'
config rule
option src 'WAN'
option target 'ACCEPT'
option name '80 EXT'
list proto 'tcp'
option src_port '80'
option dest 'DMZ'
list dest_ip '10.0.0.5'
option dest_port '80'
config forwarding
option src 'DMZ'
option dest 'HOME'
config zone
option name 'HOME'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'HOME'
config redirect
option dest 'DMZ'
option target 'DNAT'
option name 'REVERSE PROXY'
option src 'WAN'
option src_dport '443'
option dest_port '443'
option dest_ip '10.0.0.5'
config redirect
option dest 'DMZ'
option target 'DNAT'
option name 'REVERSE PROXY 80'
option src 'WAN'
option src_dport '80'
option dest_port '80'
list proto 'tcp'
option dest_ip '10.0.0.5'
option enabled '0'
config zone
option name 'GUEST'
option output 'ACCEPT'
option forward 'REJECT'
option input 'REJECT'
list network 'Guest'
config forwarding
option src 'GUEST'
option dest 'WAN'
config rule
option name 'GUEST DNS'
option src 'GUEST'
option dest_port '53'
option target 'ACCEPT'
config rule
option name 'GUEST DHCP'
list proto 'udp'
option src 'GUEST'
option dest_port '67-68'
option target 'ACCEPT'
config redirect
option dest 'DMZ'
option target 'DNAT'
option name 'PLEX'
option src 'WAN'
option src_dport '32400'
option dest_ip '10.0.0.2'
option dest_port '32400'
list proto 'tcp'
list proto 'udp'
config rule
option name 'ALL_DMZ'
option target 'ACCEPT'
option src 'IoT'
option dest 'DMZ'
config redirect
option target 'DNAT'
option name 'OPENWRT'
list proto 'tcp'
option src 'WAN'
option src_dport '666'
option dest_ip '10.0.0.254'
option dest_port '80'
option enabled '0'
config zone
option name 'IoT'
option output 'ACCEPT'
list network 'IoT'
option input 'ACCEPT'
option forward 'ACCEPT'
config forwarding
option src 'DMZ'
option dest 'IoT'
config forwarding
option src 'HOME'
option dest 'DMZ'
config forwarding
option src 'IoT'
option dest 'DMZ'
config forwarding
option src 'WAN'
option dest 'DMZ'
config forwarding
option src 'WAN'
option dest 'GUEST'
config forwarding
option src 'WAN'
option dest 'IoT'
config forwarding
option src 'IoT'
option dest 'HOME'
config forwarding
option src 'HOME'
option dest 'IoT'
config rule
option name 'ALL_DMZ'
option src 'DMZ'
option dest 'IoT'
option target 'ACCEPT'
config rule
option name 'ALL_IOT'
option src 'WAN'
option dest 'IoT'
option target 'ACCEPT'
config rule
option name 'ALL_IOT'
option src 'IoT'
option dest 'WAN'
option target 'ACCEPT'
config redirect
option dest 'DMZ'
option target 'DNAT'
option name 'SSH'
list proto 'tcp'
option src 'WAN'
option src_dport '80'
option dest_ip '10.0.0.9'
option dest_port '66'
option src_ip '193.49.190.200'
option enabled '0'
config forwarding
option src 'IoT'
option dest 'WAN'
config rule
option src 'DMZ'
option dest 'HOME'
option target 'ACCEPT'
config rule
option name 'TEST'
option src 'HOME'
option dest 'DMZ'
option target 'ACCEPT'
config rule
option name 'Allow-mDNS'
list proto 'udp'
option src 'HOME'
option src_port '5353'
option dest 'DMZ'
list dest_ip '224.0.0.251'
option dest_port '5353'
option target 'ACCEPT'
config include
option path '/etc/firewall.user'
option fw4_compatible '1'
config rule
list proto 'udp'
option src 'IoT'
option src_port '5353'
list dest_ip '224.0.0.0/4'
option dest_port '5353'
option target 'ACCEPT'
config rule
list proto 'udp'
option src 'DMZ'
list dest_ip '224.0.0.0/4'
option target 'ACCEPT'
config rule
list proto 'udp'
option src 'HOME'
list dest_ip '224.0.0.0/4'
option target 'ACCEPT'
config rule
option name '443 EXT'
list proto 'tcp'
option src 'WAN'
option src_port '443'
option dest 'DMZ'
list dest_ip '10.0.0.5'
option dest_port '443'
option target 'ACCEPT'
I'm not sure what I'm missing here, so any suggestions or guidance would be greatly appreciated. Thank you in advance!
Yes, I had to leave many bad rules to make services work while I configured everything. How can I set WAN as the default for reject? 'Your port 66 rule has a src port set - this can't work.' What should I do here?
This rule is applied to forwarded packets. To apply it to ingress packets to OpenWrt, you need to remove the option dest '*'
Start with the default firewall configuration. It is adequately secure. Then you can open the ports you need to do your work.
I told you to start fresh, @trendy told you to start fresh. Obviously, you ignored that and ended up with an equally confusing (bad?) configuration.
Let's start step by step and with the basics:
What is your goal?
Why are there so many zones? Are they really needed?
Which zone should have access to what?
Which ports do you want to open/forward and to which target?
Then, start with a fresh configuration involving only lan and wan. Add your first zone, e.g. DMZ, and get it working. Then add the next zone and so on.
I started from scratch, all my rules have been redone and each required service is identified in the traffic rules. I am trying to understand the difference between "zones" and "traffic rules". For example, between DMZ and HOME, I only allowed 2 ports in the rules, should I put "accept" or "reject" in the zone section? This is the part that I don't understand.
Do a web search for "Zone-based Firewall" and read some basics about firewall concepts.
Since you are - again - ignoring important questions (i.e. What is DMZ? What is HOME? What do you want to do?), I'm out.
You have created bidirectional forwardings from HOME to DMZ, so all traffic is allowed between these two.
The mDNS rule you have will not work, as the multicast scope is not to go outside of the broadcast domain.