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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Firewalld防火牆基礎防火牆
- Linux防火牆基礎Linux防火牆
- Linux基礎命令---iptables防火牆Linux防火牆
- 防火牆基礎Firewalld命令配置防火牆
- 1、iptables-基礎-包過濾防火牆-四層防火牆(只支援4層協議)防火牆協議
- 基於iptables防火牆堵漏防火牆
- WAb防火牆與傳統防火牆防火牆
- 防火牆防火牆
- 雲防火牆如何玩轉公有云引流防火牆
- 防火牆入侵於檢測——————3、思科 PIX 防火牆和 ASA 防火牆產品線防火牆
- iptables防火牆防火牆
- 防火牆配置防火牆
- 防火牆iptables防火牆
- 防火牆(firewall)防火牆
- linux之openEuler /centos7防火牆基本使用指南LinuxCentOS防火牆
- CentOS 7.0防火牆CentOS防火牆
- Linux防火牆命令Linux防火牆
- CentOS 防火牆操作CentOS防火牆
- Linux配置防火牆Linux防火牆
- 防火牆部署案例防火牆
- 防火牆介紹防火牆
- LINUX 防火牆 firewalldLinux防火牆
- ubuntu 關閉防火牆命令 ubuntu怎樣關閉防火牆Ubuntu防火牆
- 防火牆 搜尋 釋出 防火牆是什麼?怎麼理解?防火牆
- linux 7 防火牆操作Linux防火牆
- 資料庫防火牆資料庫防火牆
- Iptables防火牆應用防火牆
- CentOS防火牆設定CentOS防火牆
- 防火牆的分類防火牆
- CentOS 7 防火牆操作CentOS防火牆
- iptables防火牆規則防火牆
- Linux 防火牆配置使用Linux防火牆
- linux關閉防火牆命令 linux防火牆關閉和開啟命令Linux防火牆
- 雲伺服器需要防火牆嗎?防火牆如何啟用設定?伺服器防火牆
- 什麼是防火牆?防火牆能發揮什麼樣的作用?防火牆
- CentOS8檢視防火牆狀態,開啟/關閉防火牆CentOS防火牆
- 計算機網路之網路安全基礎-防火牆與入侵檢測系統計算機網路防火牆
- 怎麼重置win10防火牆_win10防火牆重置的方法Win10防火牆
- Mac有防火牆嗎?關於Mac防火牆常見的問題解答Mac防火牆