首页 > 其他分享 >OpenWrt-防火墙

OpenWrt-防火墙

时间:2023-10-20 14:59:54浏览次数:23  
标签:src option config list 防火墙 icmp type OpenWrt

https://blog.csdn.net/agave7/article/details/119926353

 

 


防火墙是OPenWrt非常重要的一部分,基础篇只说防火墙的配置和一些常用的命令.

9.1 防火墙配置文件

root@Togetek:/# cat /etc/config/firewall
config defaults
option syn_flood 1
option input REJECT
option output ACCEPT
option forward REJECT
# Uncomment this line to disable ipv6 rules
# option disable_ipv6 1

config zone
option name lan
list network 'lan'
option input ACCEPT
option output ACCEPT
option forward ACCEPT

config zone
option name wan
list network 'wan'
list network 'wan6'
option input ACCEPT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1

config forwarding
option src lan
option dest wan

# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
option name Allow-DHCP-Renew
option src wan
option proto udp
option dest_port 68
option target ACCEPT
option family ipv4

# Allow IPv4 ping
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

# Allow DHCPv6 replies
# see https://github.com/openwrt/openwrt/issues/5066
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

# Allow essential incoming IPv6 ICMP traffic
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

# Allow essential forwarded IPv6 ICMP traffic
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

# allow interoperability with traceroute classic
# note that traceroute uses a fixed port range, and depends on getting
# back ICMP Unreachables. if we're operating in DROP mode, it won't
# work so we explicitly REJECT packets on these ports.
config rule
option name Support-UDP-Traceroute
option src wan
option dest_port 33434:33689
option proto udp
option family ipv4
option target REJECT
option enabled false

# include a file with users custom iptables rules
config include
option path /etc/firewall.user


### EXAMPLE CONFIG SECTIONS
# do not allow a specific ip to access wan
#config rule
# option src lan
# option src_ip 192.168.45.2
# option dest wan
# option proto tcp
# option target REJECT

# block a specific mac on wan
#config rule
# option dest wan
# option src_mac 00:11:22:33:44:66
# option target REJECT

# block incoming ICMP traffic on a zone
#config rule
# option src lan
# option proto ICMP
# option target DROP

# port redirect port coming in on wan to lan
#config redirect
# option src wan
# option src_dport 80
# option dest lan
# option dest_ip 192.168.16.235
# option dest_port 80
# option proto tcp

# port redirect of remapped ssh port (22001) on wan
#config redirect
# option src wan
# option src_dport 22001
# option dest lan
# option dest_port 22
# option proto tcp

### FULL CONFIG SECTIONS
#config rule
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 80
# option dest wan
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp
# option target REJECT

#config redirect
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 1024
# option src_dport 80
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp


9.2 防火墙常用操作
#阻止防火墙服务开机自动启动
/etc/init.d/firewall disable
#关闭防火墙
/etc/init.d/firewall stop
#开启防火墙
/etc/init.d/firewall start
#重启防火墙
/etc/init.d/firewall restart
————————————————
版权声明:本文为CSDN博主「图解编程」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/shuige2215/article/details/128038055

标签:src,option,config,list,防火墙,icmp,type,OpenWrt
From: https://www.cnblogs.com/cheyunhua/p/17777084.html

相关文章

  • 安全HCIE_防火墙入侵防御
    防火墙入侵防御0.入侵概述·入侵是指指未经授权而尝试访问信息系统资源、篡改信息系统中的数据,使信息系统不可靠或不能使用的行为。· 入侵企图破坏信息系统的完整性、机密性、可用性以及可控性。·常见入侵手段如下:1>利用系统及软件的漏洞2>DDoS攻击3>病毒及恶意软件......
  • 通过openwrt查看连接设备的IP,MAC地址,设备名
    前言openwrt开发中,我们经常要查看连接设备的情况,今天分享一下如何查看:作者:良知犹存转载授权以及围观:欢迎关注微信公众号:羽林君或者添加作者个人微信:become_me通过arp缓存列表/proc/net/arpcat /proc/net/arp在该文件中保存有IP地址,网络类型,ARP标志,MAC地址,网络掩码,和网......
  • 山石防火墙HA配置--主备模式--命令行
    配置山石防火墙HA主备模式分为4部分 配置TRACK配置HA组配置HA链路检查状态1.配置track检测对象(非必须)主备设备配置相同configtrackha0interfacee0/1interfacee0/2 2.配置HA组属性主confighagroup0priority100    //优先级,值越小越优先preempt1   ......
  • 山石防火墙不同HA组需要配置不同的IP,不然接口地址MAC会冲突
    配置山石防火墙HA和管理地址,调试之后,发现管理地址不通。在网关设备上查看ARP信息,发现mac地址获取的位置不对,根据路径查询到另一组山石防火墙。接口MAC地址竟然一样!!!!!!!!!询问客服得知是因为HA配置问题,两组防火墙HAIP地址不能相同。接口MAC地址是根据这个进行计算的。这两组墙都配置......
  • 防火墙
                  ......
  • kylin-verver firewalld 防火墙配置
    1.查看firewalld状态systemctlstatusfirewalldsystemctlstatusfirewalld.servicesystemctlis-activefirewalld2.firewalld服务开启:systemctlstartfirewalld关闭:systemctlstopfirewalld重启:systemctlrestartfirewalld3.开机自启systemctl......
  • 防火墙网络放行
    通常做设置时需要对指定的程序或端口进行防火墙放行@echooffrem设置需要启动的端口setOTHERPORT=1433,3389rem启用防火墙常规端口可以删除netshadvfirewallfirewalladdrulename="_Ping"dir=inprotocol=icmpv4action=allownetshadvfirewallfirewalladdr......
  • Ubuntu防火墙操作
    #查看防火墙状态ufwstatus#安装ufwapt-getinstallufw#开启ufwenable#关闭ufwdisable#开放指定端口ufwallow端口号#重启ufwreload关闭指定端口ufwdeleteallow端口号#设置默认访问权限,拒绝所有外部访问ufwdefaultdeny#开放指定ip所有......
  • 当防火墙开通策略后如何验证端口服务已经连通了?
    当防火墙开通策略后如何验证端口服务已经连通了?假设策略开通的没有问题。在源主机上进行测试:1.Windows下测试TCP端口格式:telnet【目的IP/域名】端口telnetwww.baidu.com443成功则会显示以下界面 telnetwww.baidu.com135失败则会显示以下界面 2.在Linux(cent......
  • 安全HCIE_防火墙高可靠性技术
    防火墙高可靠性技术0.高可靠解决方案(1)高可靠性技术背景·网络架构中硬件的不可靠主要源自于设备不可靠与链路不可靠两方面。·防火墙高可靠性技术分为两类:设备高可靠性和链路高可靠性。 (2)设备高可靠性·双机热备:两台防火墙组成双机热备,当一台防火墙发生故障时,另一台防......