I have a LAN as well as a VLAN ("exposed"), and am trying to setup a Firewall rule wherein I can connect to a specific LAN device on port 22 from my VLAN. It works partly, but first let me provide the configuration before explaining what's wrong.
This works as you would expect, I cannot access any lan devices from exposed without a Traffic Rule.
Below is my entire /etc/config/firewall file:
/etc/config/firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
list network 'lan'
option forward 'REJECT'
option log '1'
option log_limit '30/second'
config zone
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
list network 'wan'
list network 'wan6'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'
config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
config zone
option name 'exposed'
list network 'exposed'
option output 'ACCEPT'
option forward 'REJECT'
option input 'REJECT'
config forwarding
option src 'exposed'
option dest 'wan'
config redirect
option dest 'exposed'
option target 'DNAT'
list reflection_zone 'lan'
list reflection_zone 'exposed'
option src 'wan'
option src_dport '443'
option dest_ip '192.168.3.50'
option dest_port '443'
option name 'nginx-https'
config redirect
option dest 'exposed'
option target 'DNAT'
list reflection_zone 'lan'
list reflection_zone 'exposed'
option src 'wan'
option src_dport '80'
option dest_ip '192.168.3.50'
option dest_port '80'
option name 'nginx-http'
config redirect
option dest 'exposed'
option target 'DNAT'
list reflection_zone 'lan'
list reflection_zone 'exposed'
option src 'wan'
option src_dport '81'
option dest_ip '192.168.3.50'
option dest_port '81'
option name 'nginx-admin'
option enabled '0'
config rule
option src 'exposed'
option target 'REJECT'
option name 'Block VLAN Router Input'
config rule
option name 'Allow-VLAN-DHCP'
option src 'exposed'
option dest_port '67-68'
option target 'ACCEPT'
list proto 'udp'
option src_port '67-68'
list dest_ip '192.168.3.1'
config rule
option name 'Allow-VLAN-DNS'
option src_port '53'
option dest_port '53'
option target 'ACCEPT'
option src 'exposed'
list dest_ip '192.168.3.1'
config rule
option name 'VLAN To Server SSH'
option target 'ACCEPT'
option dest 'lan'
option family 'ipv4'
list proto 'tcp'
list src_ip '192.168.3.15'
option src 'exposed'
list dest_ip '192.168.1.21'
option dest_port '22'
The most notable rule is the following:
config rule
option name 'VLAN To Server SSH'
option target 'ACCEPT'
option dest 'lan'
option family 'ipv4'
list proto 'tcp'
list src_ip '192.168.3.15'
option src 'exposed'
list dest_ip '192.168.1.21'
option dest_port '22'
I would expect this to fully allow traffic from 192.168.3.15 (on "exposed") to access 192.168.1.21 on port 22. However, upon using a command like telnet 192.168.1.21 22
, half the time I get a connection refused, and the other half it works. Bizarre
Using SFTP also only works half the time, and notably it seems to work the second try in quick succession. Once I get SFTP to connect, there is no issue with that connection either.
After enabling logging for "lan", I do see that it is getting rejected when I get the connection refused message:
Reject Log
kern.warn kernel: [13398.131800] reject lan out: IN=br-lan OUT=br-lan MAC=b0:b9:8a:5b:ec:9c:00:a0:98:1d:e7:e5:08:00 SRC=192.168.3.15 DST=192.168.1.21 LEN=60 TOS=0x10 PREC=0x00 TTL=63 ID=27327 DF PROTO=TCP SPT=40342 DPT=22 WINDOW=64240 RES=0x00 SYN URGP=0
I have tried the following:
-
In Firewall > General Settings, setting Forward to accept for the top lan Zone. This DOES work, with no more connection refused messages, however obviously now any device from the VLAN can access anything on lan, which is a problem.
-
Changing the ports and destination IP on the traffic rule, same issue with whatever target lan device or port.
-
Changing the protocol to "Any" on the traffic rule.
I find this very odd, hopefully one of you knows better than I do.