FreeBSD ipfw 防火牆基礎指南(轉)
FreeBSD ipfw 防火牆基礎指南(轉)[@more@]FreeBSD ipfw 防火牆基礎指南 (zt)FreeBSD ipfw 防火牆基礎指南轉自: http://w.yi.org/weblog/42_0_1_0.htmlFreeBSD ipfw 防火牆基礎指南本文告訴你如何快速上手FreeBSD的IPFW防火牆一、核心配置/usr/src/sys/i386/conf/HQ_SuperServer程式碼:options IPFIREWALLoptions IPFIREWALL_DEFAULT_TO_ACCEPToptions IPDIVERT # IPDIVERT enables the divert IP sockets, used by 'ipfw divert'options IPFIREWALL_VERBOSEoptions IPFIREWALL_VERBOSE_LIMIT=30#options IPFILTER #ipfilter support#options IPFILTER_LOG #ipfilter logging# traffic shaper, bandwidth manager and delay emulatoroptions DUMMYNET # enables the "dummynet" bandwidth limiter. You need IPFIREWALL as well.# Statically Link in accept filters for a web server on this boxoptions ACCEPT_FILTER_DATAoptions ACCEPT_FILTER_HTTPoptions ICMP_BANDLIM # D.O.S. protectionoptions IPSTEALTH #To hide firewall from tracerouteoptions TCP_DROP_SYNFIN #To hide from nmap OS fingerprint, remove if create web server二、rc.conf配置/etc/rc.conf程式碼:firewall_enable="YES"firewall_logging="YES"firewall_script="/etc/rc.firewall"firewall_quiet="NO" #change to YES once happy with rulesfirewall_logging_enable="YES"#extra firewalling optionslog_in_vain="YES"#This option prevents something known as OS fingerprinting, must have TCP_DROP_SYNFIN compiled into kernel to usetcp_drop_synfin="NO" #change to NO if create webservertcp_restrict_rst="YES"icmp_drop_redirect="YES"三、ipfw使用程式碼:ipfw add allow tcp from to in recv新增和除去規則例子:程式碼:$ sudo ipfw add deny tcp from 61.49.203.115 to 61.49.203.114 22 in recv fxp0$ sudo ipfw -t list$ sudo ipfw delete 00100禁止icmp程式碼:$ sudo ipfw add deny icmp from any to any in recv fxp0顯示rules程式碼:$ sudo ipfw show按照序號顯示規則程式碼:$ sudo ipfw -t list列出資訊包的數目,和與它們相對應的規則匹配程式碼:$ sudo ipfw -a list四、/etc/ipfw.rules規則檔案程式碼:allow 00010 udp from any to me 67 in via $iifallow 00020 udp from me 68 to any out via $iif五、/etc/rc.firewall指令碼程式碼:# mv /etc/rc.firewall /etc/rc.firewall.orig# touch /etc/rc.firewall# chmod u=+rx,og=-rwx /etc/ipfw.rules/etc/rc.firewall程式碼:#!/bin/sh# This will flush the existing rules - sudo ipfw -f flush# You can execute this script without dropping existing connections/statesfwcmd="/sbin/ipfw -q"extif="fxp0"myip="10.1.8.114"mybcast="10.1.8.119"mynetwork="10.1.8.112/29"dns_server="10.1.8.1"# Reset all rules in case script run multiple times${fwcmd} -f flush${fwcmd} add 200 check-state# Block RFC 1918 networks - the , syntax only works in ipfw2${fwcmd} add 210 deny all from 0.0.0.0/7,1.0.0.0/8,2.0.0.0/8,5.0.0.0/8,10.0.0.0/8,23.0.0.0/8,27.0.0.0/8,31.0.0.0/8,67.0.0.0/8,68.0.0.0/6,72.0.0.0/5,80.0.0.0/4,96.0.0.0/3,127.0.0.0/8,128.0.0.0/16,128.66.0.0/16,169.254.0.0/16,172.16.0.0/12,191.255.0.0/16,192.0.0.0/16,192.168.0.0/16,197.0.0.0/8,201.0.0.0/8,204.152.64.0/23,224.0.0.0/3,240.0.0.0/8 to any# Allow all via loopback to loopback${fwcmd} add 220 allow all from any to any via lo0# Allow from me to anywhere${fwcmd} add 240 allow tcp from ${myip} to any setup keep-state${fwcmd} add 260 allow udp from ${myip} to any keep-state${fwcmd} add 280 allow icmp from ${myip} to any# Allow local LAN to connect to us${fwcmd} add 300 allow ip from ${mynetwork} to ${mynetwork}# Allow INCOMING SSH,SMTP,HTTP from anywhere on the internet${fwcmd} add 320 allow log tcp from any to ${myip} 22,25,80 in keep-state setup# Disable icmp${fwcmd} add 340 allow icmp from any to any icmptype 0,3,11# Block all other traffic and log in${fwcmd} add 360 deny log all from any to any# End of /etc/rc.firewall六、 ipfw日誌紀錄配置/etc/syslog.conf程式碼:!ipfw*.* /var/log/ipfw.log程式碼:$ sudo touch /var/log/ipfw.log$ sudo killall -HUP syslog
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-940813/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 用IPFW實現BSD防火牆(轉)防火牆
- FreeBSD防火牆技術(轉)防火牆
- Firewalld防火牆基礎防火牆
- FreeBSD設定和使用ipfw/natd(轉)
- Linux防火牆基礎Linux防火牆
- 防火牆基礎Firewalld命令配置防火牆
- Linux基礎命令---iptables防火牆Linux防火牆
- 硬體防火牆選購指南(轉載)防火牆
- CiscoPIX防火牆配置指南防火牆
- 配置基於ADSL的防火牆(轉)防火牆
- 全面分析防火牆及防火牆的滲透(轉)防火牆
- 1、iptables-基礎-包過濾防火牆-四層防火牆(只支援4層協議)防火牆協議
- WindowsXP作業系統防火牆經典使用指南(轉)Windows作業系統防火牆
- 基於iptables防火牆堵漏防火牆
- 選用單防火牆DMZ還是雙防火牆DMZ(轉)防火牆
- Juniper防火牆簡介(轉)防火牆
- 防火牆介紹(1)(轉)防火牆
- 防火牆介紹(2)(轉)防火牆
- 動態 iptables 防火牆(轉)防火牆
- NAT iptables防火牆(script)(轉)防火牆
- 防火牆埠(下)(轉載)防火牆
- 防火牆埠(中)(轉載)防火牆
- 防火牆埠(上)(轉載)防火牆
- 八種防火牆產品評測(企業級防火牆)(轉)防火牆
- WAb防火牆與傳統防火牆防火牆
- 深入淺出談防火牆(轉)防火牆
- 動態iptables防火牆dynfw(轉)防火牆
- 輕輕鬆鬆穿透防火牆(轉)穿透防火牆
- 防火牆防火牆
- 開源的firewall(防火牆) SINUS (轉)防火牆
- 淺析Windows防火牆的缺陷(轉)Windows防火牆
- Linux防火牆程式設計(轉)Linux防火牆程式設計
- 用FWTK配置Linux防火牆(轉)Linux防火牆
- 蘋果釋出防火牆後方使用FaceTime指南蘋果防火牆
- 基於Linux系統的包過濾防火牆(3)(轉)Linux防火牆
- 基於Linux系統的包過濾防火牆(1)(轉)Linux防火牆
- 基於Linux系統的包過濾防火牆(2)(轉)Linux防火牆
- 防火牆(firewall)防火牆