作者: fatman 時間: 2019-12-14 16:30 標題: openwrt firewall 問題
各位Ching,我試用openwrt firewall "Traffic Rules"去加可以由wan用ssh 去router,但我發覺好似firewall無開到個port 22.
- config rule
- option target 'ACCEPT'
- option src 'wan'
- option proto 'tcp'
- option dest_port '22'
- option name 'accept-ssh-wan-service'
- option dest_ip '192.168.1.1'
- option enabled '1'
- config redirect
- option target 'DNAT'
- option src 'wan'
- option dest 'lan'
- option proto 'tcp'
- option src_dport '22'
- option dest_ip '192.168.1.1'
- option dest_port '22'
- option name 'wan-ssh'
作者: lancer 時間: 2019-12-14 17:46
iptables -L
之後貼上來
via HKEPC IR Pro 3.6.1 - iOS(3.0.0)
作者: fatman 時間: 2019-12-14 22:09
Ching, 唔該睇下有無建議
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- ACCEPT all -- anywhere anywhere /* !fw3 */
- input_rule all -- anywhere anywhere /* !fw3: Custom input rule chain */
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- syn_flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
- zone_lan_input all -- anywhere anywhere /* !fw3 */
- zone_wan_input all -- anywhere anywhere /* !fw3 */
- zone_dmz_input all -- anywhere anywhere /* !fw3 */
- Chain FORWARD (policy DROP)
- target prot opt source destination
- forwarding_rule all -- anywhere anywhere /* !fw3: Custom forwarding rule chain */
- FLOWOFFLOAD all -- anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- @
- "iptables.txt" 180L, 10529C
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- ACCEPT all -- anywhere anywhere /* !fw3 */
- input_rule all -- anywhere anywhere /* !fw3: Custom input rule chain */
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- syn_flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
- zone_lan_input all -- anywhere anywhere /* !fw3 */
- zone_wan_input all -- anywhere anywhere /* !fw3 */
- zone_dmz_input all -- anywhere anywhere /* !fw3 */
- Chain FORWARD (policy DROP)
- target prot opt source destination
- forwarding_rule all -- anywhere anywhere /* !fw3: Custom forwarding rule chain */
- FLOWOFFLOAD all -- anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- zone_lan_forward all -- anywhere anywhere /* !fw3 */
- zone_wan_forward all -- anywhere anywhere /* !fw3 */
- zone_dmz_forward all -- anywhere anywhere /* !fw3 */
- reject all -- anywhere anywhere /* !fw3 */
- Chain OUTPUT (policy ACCEPT)
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- ACCEPT all -- anywhere anywhere /* !fw3 */
- input_rule all -- anywhere anywhere /* !fw3: Custom input rule chain */
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- syn_flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
- zone_lan_input all -- anywhere anywhere /* !fw3 */
- zone_wan_input all -- anywhere anywhere /* !fw3 */
- zone_dmz_input all -- anywhere anywhere /* !fw3 */
- Chain FORWARD (policy DROP)
- target prot opt source destination
- forwarding_rule all -- anywhere anywhere /* !fw3: Custom forwarding rule chain */
- FLOWOFFLOAD all -- anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- zone_lan_forward all -- anywhere anywhere /* !fw3 */
- zone_wan_forward all -- anywhere anywhere /* !fw3 */
- zone_dmz_forward all -- anywhere anywhere /* !fw3 */
- reject all -- anywhere anywhere /* !fw3 */
- Chain OUTPUT (policy ACCEPT)
- target prot opt source destination
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- ACCEPT all -- anywhere anywhere /* !fw3 */
- input_rule all -- anywhere anywhere /* !fw3: Custom input rule chain */
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- syn_flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
- zone_lan_input all -- anywhere anywhere /* !fw3 */
- zone_wan_input all -- anywhere anywhere /* !fw3 */
- zone_dmz_input all -- anywhere anywhere /* !fw3 */
- Chain FORWARD (policy DROP)
- target prot opt source destination
- forwarding_rule all -- anywhere anywhere /* !fw3: Custom forwarding rule chain */
- FLOWOFFLOAD all -- anywhere anywhere /* !fw3: Traffic offloading */ ctstate RELATED,ESTABLISHED FLOWOFFLOAD hw
- ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
- DROP all -- anywhere anywhere ctstate INVALID /* !fw3 */
- zone_lan_forward all -- anywhere anywhere /* !fw3 */
- zone_wan_forward all -- anywhere anywhere /* !fw3 */
- zone_dmz_forward all -- anywhere anywhere /* !fw3 */
- reject all -- anywhere anywhere /* !fw3 */
- Chain OUTPUT (policy ACCEPT)
- target prot opt source destination
- ACCEPT all -- anywhere anywhere /* !fw3 */
- Chain zone_wan_dest_REJECT (1 references)
- target prot opt source destination
- reject all -- anywhere anywhere /* !fw3 */
- Chain zone_wan_forward (1 references)
- target prot opt source destination
- forwarding_wan_rule all -- anywhere anywhere /* !fw3: Custom wan forwarding rule chain */
- zone_lan_dest_ACCEPT esp -- anywhere anywhere /* !fw3: Allow-IPSec-ESP */
- zone_lan_dest_ACCEPT udp -- anywhere anywhere udp dpt:isakmp /* !fw3: Allow-ISAKMP */
- ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
- MINIUPNPD all -- anywhere anywhere
- zone_wan_dest_REJECT all -- anywhere anywhere /* !fw3 */
- Chain zone_wan_input (1 references)
- target prot opt source destination
- input_wan_rule all -- anywhere anywhere /* !fw3: Custom wan input rule chain */
- ACCEPT udp -- anywhere anywhere udp dpt:bootpc /* !fw3: Allow-DHCP-Renew */
- ACCEPT icmp -- anywhere anywhere icmp echo-request /* !fw3: Allow-Ping */
- ACCEPT igmp -- anywhere anywhere /* !fw3: Allow-IGMP */
- ACCEPT udp -- anywhere newifi.lan udp dpt:domain /* !fw3: dmz-dns */
- ACCEPT udp -- anywhere newifi.lan udp dpt:bootps /* !fw3: dmz-dhcp */
- ACCEPT tcp -- anywhere newifi.lan tcp dpt:ssh /* !fw3: accept-ssh-wan-service */
- ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
- zone_wan_src_REJECT all -- anywhere anywhere /* !fw3 */
- Chain zone_wan_output (1 references)
- target prot opt source destination
- output_wan_rule all -- anywhere anywhere /* !fw3: Custom wan output rule chain */
- zone_wan_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
- Chain zone_wan_src_REJECT (1 references)
- target prot opt source destination
- reject all -- anywhere anywhere /* !fw3 */
作者: 321 時間: 2019-12-14 23:36
在/etc/config/firewall加入以下幾行就可以
config rule
option target 'ACCEPT'
option src 'wan'
option proto 'tcp'
option dest_port '22'
option name 'ssh'
唔需要"option dest_ip '192.168.1.1"呢行
作者: fatman 時間: 2019-12-14 23:43
本帖最後由 fatman 於 2019-12-14 23:44 編輯
在/etc/config/firewall加入以下幾行就可以
config rule
option target 'ACCEPT'
option s ...
321 發表於 2019-12-14 23:36
Ching, 試過都係一樣,都係connection refused

用forward port 就可以!
作者: ckshum 時間: 2019-12-15 01:28
openwrt default應該唔俾從wan interface入ssh,要自行修改dropbear嘅config:
https://openwrt.org/docs/guide-user/base-system/dropbear
作者: platinum 時間: 2019-12-15 21:07
有d危, 基本上唔會開俾wan access
你想achieve 到d乜?
Secure your router's access
https://openwrt.org/docs/guide-user/security/secure.access
Also, as long as an attacker has network access to the console, he can always run a brute-force attack to find out username and password. He does not have to do that himself: he can let his computer(s) do the guessing. To render this option improbable or even impossible you can:
not offer access from the Internet at all, or restrict it to certain IP addresses or IP address ranges
by letting the SSH server dropbear and the web-Server uhttpd not listen on the external/WAN port
by blocking incoming connections to those ports (TCP 22, 80 and 443 by default) in your firewall
作者: fatman 時間: 2019-12-15 22:57
ssh 係個測試,因為想開一個wan port 1234然後forward 去 LAN 其中一部機嘅ssh server.
如果用port forward rules, 係無問題。但如果用Traffic Rules 做,就做唔到。
所以想問下Traffic Rules 係唔係有特別用途?!
via HKEPC IR Pro 3.6.1 - iOS(3.0.0)
作者: erickobiz 時間: 2019-12-16 00:20
回覆 1# fatman
我無用開openwrt... 但
發現呢句可能有問題:
config redirect
option target 'DNAT'
option src 'wan'
option dest 'lan'
option proto 'tcp'
option src_dport '22' <-------- 你開個 ssh client , connect 去 ssh 既 source port 唔會有指定port number , 所以試下刪左呢句先
option dest_ip '192.168.1.1'
option dest_port '22'
option name 'wan-ssh'

