日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

78 FreeBSD連載:設(shè)置和使用ipfw/natd( 三 )


rc.firewall
當(dāng)啟動了系統(tǒng)的包過濾能力之后,就需要在系統(tǒng)啟動時(shí)將這些過濾規(guī)則自動載入內(nèi)核,可以將這些添加過濾規(guī)則的指令寫入啟動文件rc.local或者其他啟動文件中 。但系統(tǒng)的啟動文件中本來就具備載入這些過濾規(guī)則的相關(guān)啟動文件rc.firewall,這個(gè)文件中根據(jù)防火墻的基本要求,設(shè)置了常用的過濾規(guī)則,可以減輕防火墻管理員的設(shè)置工作 。
為了讓系統(tǒng)執(zhí)行rc.firewall中的設(shè)置,需要在rc.conf中設(shè)置參數(shù)firewall為YES,以及設(shè)置firewall_type的值,這個(gè)參數(shù)值將傳遞給rc.firewall,使rc.firewall執(zhí)行不同的設(shè)置 。一般情況下可以將firewall_type設(shè)置為open,對網(wǎng)絡(luò)訪問不進(jìn)行限制,而clIEnt主要用于計(jì)算機(jī)不對外提供網(wǎng)絡(luò)服務(wù),保護(hù)本計(jì)算機(jī)只用于訪問外部系統(tǒng)而拒絕所有的訪問請求,設(shè)置為simple則定義了簡單的防火墻規(guī)則,可以使用這臺計(jì)算機(jī)保護(hù)防火墻內(nèi)部的計(jì)算機(jī),這三個(gè)選項(xiàng)比較常用 。下面為缺省rc.firewall中的有關(guān)過濾規(guī)則的設(shè)置 。
############# Define the firewall type in /etc/rc.conf.Valid values are:#open- will allow anyone in#client- will try to protect just this Machine#simple- will try to protect a whole network#closed- totally disables IP services except via lo0 interface#UNKNOWN- disables the loading of firewall rules.#filename - will load the rules in the given filename (full path required)## For ``client"" and ``simple"" the entries below should be customized# appropriately.這里解釋了rc.conf中對firewall參數(shù)的可能設(shè)置值,可以設(shè)置為不同的設(shè)置值,或者可以使用一個(gè)文件名作為firewall_type的值,指定一個(gè)包括了ipfw規(guī)則的文件,而設(shè)置使用者自己定制的過濾規(guī)則 。
############# Only in rare cases do you want to change these rules$fwcmd add 100 pass all from any to any via lo0$fwcmd add 200 deny all from any to 127.0.0.0/8這兩個(gè)規(guī)則用于設(shè)置本地網(wǎng)絡(luò)lo0的數(shù)據(jù)包能進(jìn)行傳輸,但屏蔽所有從其他網(wǎng)絡(luò)界面通向本地網(wǎng)絡(luò)lo0的通信 。這是最基本的設(shè)置,防止在路由或IP地址設(shè)置不正確的情況下,外部計(jì)算機(jī)訪問127.0本地網(wǎng)絡(luò) 。
# Prototype setups.if [ "${firewall_type}" = "open" -o "${firewall_type}" = "OPEN" ]; then $fwcmd add 65000 pass all from any to any設(shè)置open為防火墻的類型時(shí),即使沒有設(shè)置IPFIREWALL_DEFAULT_TO_ACCEPT內(nèi)核選項(xiàng),也允許對數(shù)據(jù)包進(jìn)行轉(zhuǎn)發(fā),因?yàn)檫@里設(shè)置的規(guī)則序號為65000,小于缺省的65535規(guī)則 。
elif [ "${firewall_type}" = "client" ]; then############# This is a prototype setup that will protect your system somewhat against# people from outside your own network.############# set these to your network and netmask and ipnet="192.168.4.0"mask="255.255.255.0"ip="192.168.4.17"當(dāng)設(shè)置了client為防火墻的類型,那么就需要更改這里的IP地址和子網(wǎng)掩碼的設(shè)置,使其符合自己計(jì)算機(jī)的實(shí)際情況 。client類型主要用于單機(jī)系統(tǒng),保護(hù)本機(jī)不受外部計(jì)算機(jī)侵襲的設(shè)置 。它的保護(hù)與tcpwrapper類似,但比tcpwrapper更為基本和高效,但是它不能提供詳細(xì)的連接記錄日志 。
# Allow any traffic to or from my own net.$fwcmd add pass all from ${ip} to ${net}:${mask}$fwcmd add pass all from ${net}:${mask} to ${ip}這兩個(gè)規(guī)則用于許可計(jì)算機(jī)與本地網(wǎng)絡(luò)的通信 。
# Allow TCP through if setup succeeded$fwcmd add pass tcp from any to any established上面這兩個(gè)規(guī)則允許連接已經(jīng)設(shè)定成功的TCP連接的數(shù)據(jù)包能夠保持連接,數(shù)據(jù)傳輸能夠繼續(xù)進(jìn)行 。established參數(shù)就用于說明數(shù)據(jù)包為已經(jīng)設(shè)置成功的TCP連接數(shù)據(jù)包 。
# Allow setup of incoming email$fwcmd add pass tcp from any to ${ip} 25 setup允許外部計(jì)算機(jī)能向內(nèi)地smtp端口發(fā)起連接請求,setup用于說明定義的數(shù)據(jù)包為請求連接的數(shù)據(jù)包 。
# Allow setup of outgoing TCP connections only$fwcmd add pass tcp from ${ip} to any setup允許本地計(jì)算機(jī)能向外部網(wǎng)絡(luò)發(fā)起連接請求 。

推薦閱讀