痞酷網_PIGOO

 找回密碼
 立即註冊
!!! [系統偵測到廣告阻擋軟體] !!!

如果您覺得痞酷網對您有些許幫助,或者您認同痞酷網的理想,

那麼希望您將痞酷網設定為白名單.

並請在上論壇的時候,動動您的手指,用行動支持我們.

謝謝!
查看: 8256|回復: 7

橋接式防火牆簡單實作

[複製鏈接]
發表於 2011-2-5 09:49:50 | 顯示全部樓層 |閱讀模式
本帖最後由 wst2080 於 2011-2-5 10:18 AM 編輯

167316_1452511687477_1673833097_862421_4648969_n.jpg
呵呵~~~ 終於從百忙當中抽空來幫忙某位鄉民的需求!!!
PS: 又剛好正逢感冒頭暈暈的時候~~~ 回答得亂七八糟的就是了~~~

聲明: 以下文章均需要有相當程度的觀念! 並且熟悉以下列表才看得懂我在寫的部分
一、熟悉與融會貫通TCP/IP
二、需具有CCNA的相關能力(paper除外!)
三、需具有CCNA Security的相關能力(paper除外!)
四、需具有CCNP SWITCH 或 BCMSN 的相關能力與觀念(paper除外)
五、需具有良好的邏輯觀念以及相關經驗與技術等~

這次委託的需求如下:
硬體架構:Cisco PIX 515 + Cisco Catalyst 4510
需求:僅使用PIX 515 管控 Server Farm的流量
PS: 至於需求為何這麼特殊~~~ 原因為何~ 呵呵 看官就自己去猜測吧!!!


這次我個人的LAB實體硬體:
http://farm6.static.flickr.com/5094/5417412044_988b991765_z.jpg
PS: Cisco Catalyst 3560 + Cisco Catalyst 3500XL + Cisco ASA5505-10


緣由:原有的外部連線進來的是透過Fiber的方式連線到該鄉民的網路機房中~
而該鄉民的主管想要藉由閒置的PIX 515來管控ServerFarm端~~ 但原先的PIX 515又沒有Fiber介面~
所以想要藉由 C4510的設備來結合! (PS:哈~詭異的想法~其實會用的,就使用VLAN ACL搭配RACL即可!)
以前我實作的方式則直接透過真實的設備來進行橋接~ 而當初他來信問我的時候,我還以為他使用的只是單純的L2 Switch~ 後來我就覺得很莫名其妙~ 因為他根據我之前稍微指點的作法照做就發生了問題~ 爾後我才問他所使用的SWITCH的型號後,我才知道他使用的是L3 Switch~~~

一般的做法若是外部進來是Fiber的介面~ 若要實作橋接防火牆的時候~ 則就是透過一台擁有GBIC的L2 SWITCH 然後串一台防火牆 之後再連到 Core Switch 當中~ 或者比較克難的做法~ 就是弄台光電轉換器來跑也OK~ 因為當初該鄉民所說的環境,當初我還以為是蠻克難的環境就是了~~~ 呵呵!!! 這就是溝通上的誤解吧~~~ 無所謂~~~ 這段只是題外話而已~~~ 現在我也稍微模擬一下那位鄉民的環境!!! 也是用Fiber從外部連線進來~~~ 之後Firewall橋接一個L3 Switch....

OK 開始回歸正題~~~
透通式(橋接)就對外部來說好像是隱形的一樣!!! 對於L3來說是看不到的~ 因為透通則是透過L2的方式運作!簡單來說 透通(橋接) 可以想像成一台SWITCH 所以防火牆在設定在透通(橋接)模式的時候,並且同時兩個連接埠連到同一個VLAN當中時候 就會產生網路迴圈(Loop) 的現象~ 這時候~ 若是擁有網管型的SWITCH就會自動地透過STP機制來進行端口阻塞來杜絕網路迴圈所帶來的廣播風暴等等~~~
http://farm6.static.flickr.com/5257/5416801063_25d27aae5d_z.jpg


http://farm6.static.flickr.com/5297/5416805209_51846e451c.jpg

http://farm6.static.flickr.com/5057/5417416316_31a6ab5be4_z.jpg
http://farm6.static.flickr.com/5257/5416801063_25d27aae5d_z.jpg
可以注意到STP的資訊 以及SWITCH上頭 Fa0/3 上頭的燈號以證明防火牆在透通(transparent)模式
透通模式的運作對於網路傳輸就好像是SWITCH般~ 所以接上相同的VLAN或者同個L2的環境就會發生環路的狀況~ 除非是接上不同的VLAN 或者 不同的L2環境,就可以不會發生網路迴圈的問題!!!


http://farm6.static.flickr.com/5051/5417412274_1275ccd11d_z.jpg
接下來會提供L3 SWITCH的組態設定 而由於在於SWITCH當中的 fa0/2跟 fa0/4均設定不同的VLAN環境當中,所以不會產生網路迴圈!


這次的實體架構圖
http://farm6.static.flickr.com/5257/5417412396_59fc6cdaac_z.jpg

http://farm6.static.flickr.com/5260/5416801209_dddbc56270_z.jpg




遠方路由端的設定 (把路由指向LAB端)
http://farm6.static.flickr.com/5251/5416801617_7d827bf618_z.jpg
這次在遠方端的路由是透過pfsense軟路由來指定~~~


http://farm6.static.flickr.com/5212/5416801271_7794868b01_z.jpg
研究發現~ 若設定靜態路由而靜態路由的流量不要受到pfsense的干擾~ 請在這個選項打勾後,重新啟動pfsense...



3560上頭的設定 (紅色為"需要注意的重點")

Switch#show run
Building configuration...

Current configuration : 2394 bytes
!
version 12.2
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Switch
!
!
no aaa new-model
system mtu routing 1500
ip subnet-zero
ip routing
!
ip dhcp pool vlan100
network 192.168.100.0 255.255.255.0
default-router 192.168.100.254
!
ip dhcp pool vlan150
network 192.168.150.0 255.255.255.0
default-router 192.168.150.254
!
ip dhcp pool vlan200
network 192.168.200.0 255.255.255.0
default-router 192.168.200.254
!
!
no file verify auto
!
spanning-tree mode rapid-pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
!
interface FastEthernet0/1
switchport mode access
!
interface FastEthernet0/2
switchport access vlan 100
switchport mode access

!
interface FastEthernet0/3
switchport mode access
!
interface FastEthernet0/4
switchport access vlan 20
switchport mode access

!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
switchport access vlan 150
switchport mode access
spanning-tree portfast
spanning-tree bpdufilter enable

!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
switchport access vlan 20
switchport mode access
spanning-tree portfast
spanning-tree bpdufilter enable

!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
switchport access vlan 150
switchport mode access
spanning-tree portfast
spanning-tree bpdufilter enable

!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
no switchport
ip address 10.0.100.200 255.255.255.0

!
interface GigabitEthernet0/2
!
interface Vlan1
no ip address
!
interface Vlan20
no ip address

!
interface Vlan100
ip address 192.168.100.254 255.255.255.0

!
interface Vlan150
ip address 192.168.150.254 255.255.255.0

!
interface Vlan200
ip address 192.168.200.254 255.255.255.0

!
ip default-gateway 10.0.100.254
ip classless
ip http server
ip http secure-server
!
!
no cdp run
!
control-plane
!
!
line con 0
exec-timeout 0 0
logging synchronous
line vty 0 4
login
line vty 5 15
login
!
end






Cisco ASA 設定 (紅色為重點部分)

ciscoasa# sh run
: Saved
:
ASA Version 7.2(4)
!
firewall transparent
hostname ciscoasa
domain-name default.domain.invalid
enable password XXXXXXXXXXXXXXXX encrypted
passwd XXXXXXXXXXXXX encrypted
names
!
interface Vlan1
nameif inside
security-level 100

!
interface Vlan2
nameif outside
security-level 0

!
interface Ethernet0/0
switchport access vlan 2

!
interface Ethernet0/1
shutdown
!
interface Ethernet0/2
shutdown
!
interface Ethernet0/3
shutdown
!
interface Ethernet0/4
shutdown
!
interface Ethernet0/5
!
interface Ethernet0/6
shutdown
!
interface Ethernet0/7
!
ftp mode passive
dns server-group DefaultDNS
domain-name default.domain.invalid
access-list inside_access_in extended permit ip any any
access-list outside_access_in extended permit ip any any
access-list outside-in extended permit icmp any any
access-list outside_access_in_1 extended permit ip host 192.168.100.254 any inactive
access-list outside_access_in_1 extended permit ip host 10.0.100.101 any
access-list outside_access_in_1 extended permit tcp host 10.0.100.100 eq ftp any
access-list outside_access_in_1 extended permit tcp host 10.0.100.100 eq ftp-data any
pager lines 24
mtu inside 1500
mtu outside 1500
ip address 192.168.150.100 255.255.255.0
icmp unreachable rate-limit 1 burst-size 1
no asdm history enable
arp timeout 14400
access-group inside_access_in in interface inside
access-group outside_access_in_1 in interface outside
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
http server enable
http 192.168.150.0 255.255.255.0 inside
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart
telnet timeout 5
ssh timeout 5
console timeout 0
!
class-map inspection_default
match default-inspection-traffic
!
!
policy-map type inspect dns preset_dns_map
parameters
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect rsh
inspect rtsp
inspect esmtp
inspect sqlnet
inspect skinny
inspect sunrpc
inspect xdmcp
inspect sip
inspect netbios
inspect tftp
!
service-policy global_policy global
prompt hostname context
Cryptochecksum:XXXXXXXXXXXXXXXXXXXXXXXXXXX
: end

**請注意!介面E0/0、E0/5與E0/7均下達sw mod acc、no shutdown 指令!
***請注意!介面E0/0下達sw acc vlan 2 指令;E0/5與E0/7下達sw acc vlan 1指令!



於控制端安裝ASDM
http://farm6.static.flickr.com/5174/5417412940_b071187111_z.jpg

http://farm6.static.flickr.com/5252/5417413000_6d670c397e_z.jpg

http://farm6.static.flickr.com/5098/5416801809_f9b8f71dae_z.jpg

http://farm6.static.flickr.com/5300/5416801855_1ef4956b90_z.jpg

http://farm6.static.flickr.com/5172/5417413134_18f0560d6c_z.jpg

http://farm6.static.flickr.com/5211/5416801979_0dbf4972bd_z.jpg


http://farm6.static.flickr.com/5092/5417413254_c7d3df8048_z.jpg

http://farm6.static.flickr.com/5294/5417413300_46b65190cc_z.jpg

http://farm6.static.flickr.com/5018/5417413378_f63df56f6b_z.jpg

http://farm6.static.flickr.com/5020/5416802169_66336a74d7_z.jpg

http://farm6.static.flickr.com/5016/5417413480_1ab383e5ec_z.jpg



安裝JRE
http://farm6.static.flickr.com/5097/5417413746_13a44bf010_z.jpg

http://farm6.static.flickr.com/5100/5416802761_d234d0db99_z.jpg

http://farm6.static.flickr.com/5252/5417414264_642806b52e_z.jpg

http://farm6.static.flickr.com/5019/5417414426_4db23f2d61_z.jpg

http://farm6.static.flickr.com/5260/5416803371_7d1c6994fd_z.jpg

http://farm6.static.flickr.com/5292/5417414806_f80bd8c748_z.jpg

http://farm6.static.flickr.com/5014/5416803761_f5484e8600_z.jpg


執行ASDM
http://farm6.static.flickr.com/5212/5416804033_500ea619e6_z.jpg

http://farm6.static.flickr.com/5098/5416804285_5e0f907e75_z.jpg

http://farm6.static.flickr.com/5133/5417415560_d3b0d034fb_z.jpg

http://farm6.static.flickr.com/5017/5416804343_f15df11ea2_z.jpg

http://farm6.static.flickr.com/5175/5416804377_e7068e5f4f_z.jpg

桃紅色: 為防火牆從內部(inside) → 外部(outside)
淺藍色: 為防火牆從外部(outside) → 內部(inside)
其實設定規則的時候 就可以看到底下有個算是蠻人性化的流通圖!!!

防火牆規則邏輯圖
http://farm6.static.flickr.com/5291/5416800077_a22ff043c6_z.jpg

舉例1: 開放 Firewall inside 與 SVI 之間的通信
※ 在這個案例當中~ 由於 inside 介面 (從inside連出outside) 已經設定成 any 到 any 允許~
    所以只要針對 outside 介面新增規則即可!!! (從outside連入inside)
http://farm6.static.flickr.com/5253/5416804431_6314d20c69_z.jpg

http://farm6.static.flickr.com/5051/5416804499_9784cf37b3_z.jpg

http://farm6.static.flickr.com/5053/5417415810_5d353fbae0_z.jpg

http://farm6.static.flickr.com/5253/5416804689_6f89de80a2_z.jpg

http://farm6.static.flickr.com/5255/5417415972_3d9e3dd769_z.jpg
設定好規則後! 一定要點選 Apply 來將設定好的規則套用才會生效

http://farm6.static.flickr.com/5054/5416804829_a3d3db33f5_z.jpg
PS: 只要記得一點很關鍵的!!! 就是大部分的傳輸都是有去有回的!!!
假設我從 inside端 下達PING到SVI ;則SVI也會回覆PING封包回來!!!
所以從上面的防火牆規則可以知道~~~ inside 允許所有連出的封包~~~
而outside的部分則是剛剛有新增一條允許SVI連入的封包!!!


http://farm6.static.flickr.com/5180/5416804963_2e519db2c1_z.jpg
ASA跟Cisco不少設備一樣 光是套用組態是不夠的~~~若下次重新啟動防火牆而使用目前設定完畢的組態,記得一定要按下 Save 存檔!!!

http://farm6.static.flickr.com/5216/5416804873_115c99bd7c_z.jpg



舉例2: 從inside端連出outside端的FTP伺服器!!!
http://farm6.static.flickr.com/5056/5417411254_539f17950a_z.jpg

http://farm6.static.flickr.com/5256/5416800035_db625d619c_z.jpg

http://farm6.static.flickr.com/5252/5416805043_54ac87ec3c_z.jpg

http://farm6.static.flickr.com/5293/5417416214_066b44e8fe_z.jpg

http://farm6.static.flickr.com/5211/5417416244_c561de0e10_z.jpg
這裡我就稍微說明~
由於inside對outisde的連線並沒有做限制,所以對方都可以收的到inside端發送的封包;但是由於outside對inside的連線有受到管制,因此外部回應的封包只接受對方服務所回應的連線! 此圖可以很清楚地了解,雖然對方有收到inside端的ICMP要求封包並把ICMP回應封包傳回來;但是被防火牆給丟棄了~ 然而由於有開放對方的FTP服務可連線回inside,所以inside可以存取遠端的FTP伺服器!


以上就是簡單的透通式防火牆建置與設定介紹!!!

評分

3

查看全部評分

發表於 2011-2-5 11:03:28 | 顯示全部樓層
本帖最後由 wooden 於 2011-2-5 11:06 AM 編輯


好像熟悉又覺得好漠生,好多年沒摸大多忘光了!哈!
大家新年快樂啦!
發表於 2011-2-5 11:41:12 | 顯示全部樓層
雖然很長, 但看完的感想是....強!!

只能說佩服佩服.........

另外請教一個問題: JRE有沒有限制要使用哪個版本?
 樓主| 發表於 2011-2-5 14:18:11 | 顯示全部樓層
雖然很長, 但看完的感想是....強!!

只能說佩服佩服.........

另外請教一個問題: JRE有沒有限制要使用哪個 ...
emc88888 發表於 2011-2-5 11:41 AM http://bbs.pigoo.com/images/common/back.gif


沒...
PS: 從 CiscoWorks 用到現在的經驗.....
發表於 2011-2-5 15:40:12 | 顯示全部樓層
哇!有看真的沒懂,只能說電腦的領域真的太大了。謝謝
發表於 2011-2-5 20:30:34 | 顯示全部樓層
本帖最後由 bglmlm 於 2011-2-5 08:44 PM 編輯

支持一下~   
這個【透通式防火牆】真是【博大精深】。。我也是有看沒有懂。。》《   
好像要【資訊系】的同學~ 來採買機器  +架站+ 下達指令!! 會比較快速^-^


ps:弱弱地問一下~
有沒有可以【利用網路線】來架設【網路電話】~
打電話【可以馬上通話】 或 通過電腦【講話免錢的 機器設備】??  這個咱就想 學習了^-^
發表於 2011-2-5 21:05:37 | 顯示全部樓層
回復 6# bglmlm

完全免費是不可能的..

可參考以下網址..
http://groups.google.com/group/asterisk-tw?hl=zh&pli=1
 樓主| 發表於 2011-2-5 22:07:00 | 顯示全部樓層
打電話【可以馬上通話】 或 通過電腦【講話免錢的 機器設備】??  這個咱就想 學習了^-^
bglmlm 發表於 2011-2-5 08:30 PM http://bbs.pigoo.com/images/common/back.gif



    SKYPE不就可以達成了嗎??? 呵呵... 擁有耳麥+電腦+音效裝置+網路+SKYPE....
免費的部分僅限於 網路  對 網路 (SKYPE帳號互相使用)

或者是 MSN 視訊功能 等等....

至於要使用網路電話撥打PSTN或者GSM等系統... 那當然要付費瞜~~~~
您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

關閉

站長小叮嚀上一條 /1 下一條

禁閉室|手機版|連繫我們|痞酷網電子技術論壇

GMT+8, 2024-4-19 08:53 PM , Processed in 0.070153 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.