Advertisement
Guest User

firewall

a guest
Feb 1st, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 32.73 KB | None | 0 0
  1. /etc/config/firewall (default)
  2.  
  3. table inet fw4 {                                                                                                                                                                                                                                            
  4.         chain input {                                                                                            
  5.                 type filter hook input priority filter; policy accept;                                          
  6.                 iifname "lo" accept comment "!fw4: Accept traffic from loopback"                                                                                                                                                                            
  7.                 ct state established,related accept comment "!fw4: Allow inbound established and related flows"                                                                                                                                            
  8.                 tcp flags syn / fin,syn,rst,ack jump syn_flood comment "!fw4: Rate limit TCP syn packets"                                                                                                                                                    
  9.                 iifname "br-lan" jump input_lan comment "!fw4: Handle lan IPv4/IPv6 input traffic"                                                                                                                                                          
  10.                 iifname "eth0.2" jump input_wan comment "!fw4: Handle wan IPv4/IPv6 input traffic"                                                                                                                                      
  11.         }                                                                                                                                                                                                                              
  12.                                                                                                                                                                                                                                                            
  13.         chain forward {                                                                                                                                                                                                                
  14.                 type filter hook forward priority filter; policy drop;                                                                                                                                                                                      
  15.                 ct state established,related accept comment "!fw4: Allow forwarded established and related flows"                                                                                                                    
  16.                 iifname "br-lan" jump forward_lan comment "!fw4: Handle lan IPv4/IPv6 forward traffic"                                                                                                                                                      
  17.                 iifname "eth0.2" jump forward_wan comment "!fw4: Handle wan IPv4/IPv6 forward traffic"                                                                                      
  18.                 jump handle_reject                                                                                                                                                                                                                          
  19.         }                                                                                                                                                                                                                              
  20.                                                                                                                                                                                                                                                              
  21.         chain output {                                                                                                                                                                                                                
  22.                 type filter hook output priority filter; policy accept;                                                                                                                                                                                      
  23.                 oifname "lo" accept comment "!fw4: Accept traffic towards loopback"                                                                                                          
  24.                 ct state established,related accept comment "!fw4: Allow outbound established and related flows"                                                                                                                                            
  25.                 oifname "br-lan" jump output_lan comment "!fw4: Handle lan IPv4/IPv6 output traffic"                                                                                                                                  
  26.                 oifname "eth0.2" jump output_wan comment "!fw4: Handle wan IPv4/IPv6 output traffic"                                                                                                                                                        
  27.         }                                                                                                                                                                                                                            
  28.                                                                                                                                                                                                                                                              
  29.         chain prerouting {                                                                                                                                                                  
  30.                 type filter hook prerouting priority filter; policy accept;                                                                                                                                                            
  31.                 iifname "br-lan" jump helper_lan comment "!fw4: Handle lan IPv4/IPv6 helper assignment"                                                                                                                                                    
  32.         }                                                                                                                                                                                                                                                  
  33.                                                                                                                                                                                                                                                              
  34.         chain handle_reject {                                                                                                                                                                                                                                
  35.                 meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic"                                                                                                    
  36.                 reject comment "!fw4: Reject any other traffic"                                                                                                                                                                        
  37.         }                                                                                                                                                                                                                                                  
  38.                                                                                                                                                                                                                                        
  39.         chain syn_flood {                                                                                                                                                                                                                                    
  40.                 limit rate 25/second burst 50 packets return comment "!fw4: Accept SYN packets below rate-limit"                                                                                                                      
  41.                 drop comment "!fw4: Drop excess packets"                                                                                                                                                                                                    
  42.         }                                                                                                                                                                                    
  43.                                                                                                                                                                                                                                                            
  44.         chain input_lan {                                                                                                                                                                                                              
  45.                 jump accept_from_lan                                                                                                                                                                                                                        
  46.         }                                                                                                                                                                                                                            
  47.                                                                                                                                                                                                                                                              
  48.         chain output_lan {                                                                                                                                                                  
  49.                 jump accept_to_lan                                                                                                                                                                                                      
  50.         }                                                                                                                                                                                                                                                  
  51.                                                                                                                                                                                                                                                            
  52.         chain forward_lan {                                                                                                                                                                                                                                  
  53.                 jump accept_to_wan comment "!fw4: Accept lan to wan forwarding"                                                                                                                                                                              
  54.                 jump accept_to_lan                                                                                                                                                          
  55.         }                                                                                                                                                                                                                              
  56.                                                                                                                                                                                              
  57.         chain helper_lan {                                                                                                                                                                                                              
  58.         }                                                                                                                                                                                                                                                  
  59.                                                                                                                                                                                                                                      
  60.         chain accept_from_lan {                                                                                                                                                                                                                              
  61.                 iifname "br-lan" counter packets 124 bytes 10234 accept comment "!fw4: accept lan IPv4/IPv6 traffic"                                                                        
  62.         }                                                                                                                                                                                                                                                  
  63.                                                                                                                                                                                                                                        
  64.         chain accept_to_lan {                                                                                                                                                                                                                                
  65.                 oifname "br-lan" counter packets 13 bytes 1706 accept comment "!fw4: accept lan IPv4/IPv6 traffic"                                                                                                                    
  66.         }                                                                                                                                                                                                                                                    
  67. chain input_wan {                                                                                                                                                                                                              
  68.                 meta nfproto ipv4 udp dport 68 counter packets 0 bytes 0 accept comment "!fw4: Allow-DHCP-Renew"                                                                                                                                            
  69.                 icmp type echo-request counter packets 0 bytes 0 accept comment "!fw4: Allow-Ping"                                                                                                                                      
  70.                 meta nfproto ipv4 meta l4proto igmp counter packets 9 bytes 324 accept comment "!fw4: Allow-IGMP"                                                                                                                                            
  71.                 meta nfproto ipv6 udp dport 546 counter packets 0 bytes 0 accept comment "!fw4: Allow-DHCPv6"                                                                                                                        
  72.                 ip6 saddr fe80::/10 icmpv6 type . icmpv6 code { mld-listener-query . no-route, mld-listener-report . no-route, mld-listener-done . no-route, mld2-listener-report . no-route } counter packets 10 bytes 760 accept comment "!fw4: Allow-MLD"
  73.                 icmpv6 type { destination-unreachable, time-exceeded, echo-request, echo-reply, nd-router-solicit, nd-router-advert } limit rate 1000/second counter packets 353 bytes 50832 accept comment "!fw4: Allow-ICMPv6-Input"
  74.                 icmpv6 type . icmpv6 code { packet-too-big . no-route, parameter-problem . no-route, parameter-problem . admin-prohibited, nd-neighbor-solicit . no-route, nd-neighbor-advert . no-route } limit rate 1000/second counter packets 11 bytes 79
  75.                 jump reject_from_wan                                                                                                                                                                                                    
  76.         }                                                                                                                                                                                                                                                    
  77.                                                                                                                                                                                                                                                            
  78.         chain output_wan {                                                                                                                                                                                                                                  
  79.                 jump accept_to_wan                                                                                                                                                                                                                          
  80.         }                                                                                                                                                                                                                                                  
  81.                                                                                                                                                                                                                                      
  82.         chain forward_wan {                                                                                                                                                                                                                                  
  83.                 icmpv6 type { destination-unreachable, time-exceeded, echo-request, echo-reply } limit rate 1000/second counter packets 0 bytes 0 accept comment "!fw4: Allow-ICMPv6-Forward"                                                              
  84.                 icmpv6 type . icmpv6 code { packet-too-big . no-route, parameter-problem . no-route, parameter-problem . admin-prohibited } limit rate 1000/second counter packets 0 bytes 0 accept comment "!fw4: Allow-ICMPv6-Forward"                    
  85.                 meta l4proto esp counter packets 0 bytes 0 jump accept_to_lan comment "!fw4: Allow-IPSec-ESP"                                                                                                                                                
  86.                 udp dport 500 counter packets 0 bytes 0 jump accept_to_lan comment "!fw4: Allow-ISAKMP"                                                                                                                                
  87.                 jump reject_to_wan                                                                                                                                                                                                                          
  88.         }                                                                                                                                                                                                                                                  
  89.                                                                                                                                                                                                                                                              
  90.         chain accept_to_wan {                                                                                                                                                                                                                                
  91.                 oifname "eth0.2" counter packets 2325 bytes 293019 accept comment "!fw4: accept wan IPv4/IPv6 traffic"                                                                                                                                      
  92.         }                                                                                                                                                                                                                              
  93.                                                                                                                                                                                                                                                            
  94.         chain reject_from_wan {                                                                                                                                                                                                        
  95.                 iifname "eth0.2" counter packets 7 bytes 659 jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"                                                                                                                                
  96.         }                                                                                                                                                                                                                                                  
  97.                                                                                                                                                                                                                                                              
  98.         chain reject_to_wan {                                                                                                                                                                                                                                
  99.                 oifname "eth0.2" counter packets 0 bytes 0 jump handle_reject comment "!fw4: reject wan IPv4/IPv6 traffic"                                                                                                                                  
  100.         }                                                                                                                                                                                                                              
  101.                                                                                                                                                                                                                                                              
  102.         chain dstnat {                                                                                                                                                                                                                                      
  103.                 type nat hook prerouting priority dstnat; policy accept;                                                                                                                                                                                    
  104.         }                                                                                                                                                                                                                                                    
  105.                                                                                                                                                                                                                                        
  106.         chain srcnat {                                                                                                                                                                                                                                      
  107.                 type nat hook postrouting priority srcnat; policy accept;                                                                                                                                                                                  
  108.                 oifname "eth0.2" jump srcnat_wan comment "!fw4: Handle wan IPv4/IPv6 srcnat traffic"                                                                                                                                                        
  109.         }                                                                                                                                                                                                                                                    
  110.                                                                                                                                                                                                                                                              
  111.         chain srcnat_wan {                                                                                                                                                                                                              
  112.                 meta nfproto ipv4 masquerade comment "!fw4: Masquerade IPv4 wan traffic"                                                                                                    
  113.         }                                                                                                                                                                                                                              
  114.                                                                                                                                                                                                                                                            
  115.         chain raw_prerouting {                                                                                                                                                                                                                              
  116.                 type filter hook prerouting priority raw; policy accept;                                                                                                                                                                                    
  117.         }                                                                                                                                                                                                                                                    
  118.                                                                                                                                                                                                                                                            
  119.         chain raw_output {                                                                                                                                                                                                              
  120.                 type filter hook output priority raw; policy accept;                                                                                                                                                                                        
  121.         }                                                                                                                                                                                                                                                  
  122.                                                                                                                                                                                                                                                              
  123.         chain mangle_prerouting {                                                                                                                                                                                                                            
  124.                 type filter hook prerouting priority mangle; policy accept;                                                          
  125.         }                                                                      
  126. chain mangle_postrouting {                                                                                                                                                                                                                          
  127.                 type filter hook postrouting priority mangle; policy accept;                                                                                                                                                                                
  128.         }                                                                                                                                                                                                                              
  129.                                                                                                                                                                                              
  130.         chain mangle_input {                                                                                                                                                                                                            
  131.                 type filter hook input priority mangle; policy accept;                                                                                                                                                                                      
  132.         }                                                                                                                                                                                                                                                  
  133.                                                                                                                                                                                                                                                              
  134.         chain mangle_output {                                                                                                                                                                                                                                
  135.                 type route hook output priority mangle; policy accept;                                                                                                                                                                                      
  136.         }                                                                                                                                                                                                                              
  137.                                                                                                                                                                                                                                                              
  138.         chain mangle_forward {                                                                                                                                                                                                                              
  139.                 type filter hook forward priority mangle; policy accept;                                                                                                                                                                                    
  140.                 iifname "eth0.2" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 ingress MTU fixing"                                                                                                                      
  141.                 oifname "eth0.2" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 egress MTU fixing"
  142.         }                                                                                                                                                                                                                                                  
  143. }                    
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement