1 / 15

資訊安全與系統管理

資訊安全與系統管理. 2013/4/10 Chien wei lin. 練習. 防火牆是否可以防範病毒 ? 若有 10 台電腦相要共用一條 8M/2M 的 ADSL 連線網際網路,只有一個公共 IP ,該如何規畫才能夠使 10 台電腦同時都能上網,並且在瀏覽網頁時不會感到緩慢 ?. 防火 牆架構. Gateway. 通訊閘 Gateway 主要的用途在於轉送 (Forward) 網路封包,使得在內部網路的其他電腦能夠透過 Gateway 連上網路

Download Presentation

資訊安全與系統管理

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 資訊安全與系統管理 2013/4/10 Chienweilin

  2. 練習 防火牆是否可以防範病毒? 若有 10 台電腦相要共用一條 8M/2M 的 ADSL連線網際網路,只有一個公共 IP,該如何規畫才能夠使10台電腦同時都能上網,並且在瀏覽網頁時不會感到緩慢?

  3. 防火牆架構

  4. Gateway • 通訊閘 Gateway主要的用途在於轉送(Forward)網路封包,使得在內部網路的其他電腦能夠透過 Gateway 連上網路 • 因此,要做為 Gateway 的伺服器至少需要有兩張網路卡,一張網路卡是對內網段使用,另外一張網路卡則是對外網段使用,分別擁有不同的 IP • 在練習實作時,我們必須先規畫好可以對外連線的網卡所需使用的 IP,及對內連線所使用的 IP • 對外連線所使用的 IP 通常會依據實際所配發的公共 IP 網段做設定 • 對內連線則可以自行規畫想使用的 IP

  5. 硬體設置 • 由於沒有實體的設備,使用 VirtualBox練習時,需在要實作的主機上設定安裝兩個網路卡 • 外部網路: 設定其中一張可以透過 VirtualBox連線到網際網路 • 內部網路: 設定另一張網路卡只能與 VirtualBox中其他虛擬主機連線 • 完成硬體的配置過後,接著進入 Ubuntu 分別依據規劃設定兩張網路卡的 IP 位置 • sudovi /etc/network/interfaces

  6. 設定IP 位置 外部網路:eth0為對外的連線,因此必須設定實際對外連線所需使用的 Gateway 及 DNS 內部網路:eth1則依據規畫的 IP 網段做設定即可 auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.20.30.77 netmask 255.255.255.0 gateway 10.20.30.1 dns-nameservers 10.20.30.15 10.20.30.16 auto eth1 iface eth1 inet static address 172.22.22.1 netmask 255.255.255.0 network 172.22.22.0

  7. 開啟 Ubuntu 封包轉送的功能 • Linux 要做為 Gateway 或 Router 會使用到封包轉送(Forward)的功能,Linux 有提供此功能,但在預設情況下是沒有開啟的 • 編輯 Linux 核心參數 • sudovim /etc/sysctl.conf • 找到 IPv4 封包轉送的設定 • # net.ipv4.ip_forward=1 • 將註解的符號 # 移除以開啟設定 • net.ipv4.ip_forward=1 • 重新啟動 Linux 以載入新的設定 • sudo reboot

  8. NAT Linux 的 IP 轉送功能以開啟,內部網路的封包已經可以透過 Gateway 轉送到網際網路 但其他內部網路的電腦仍然沒有辦法透過 Gateway 上網,主要是由於內部網路的電腦使用的是私有 IP 使用私有 IP 使得其他伺服器要回應時無法找到回應的位置,使得連線無法雙向溝通 因此要設定 NAT 的功能

  9. NAT 設定 • 網路地址轉換NAT 的功能可以透過 Linux 中 iptables的指令做設定 • iptables是 Ubuntu 中內建可以用來過濾封包的套件,可以用來做為防火牆或 NAT 時使用 • 透過加以下兩行開啟 NAT 的功能 • 第一行為開啟允許封包轉送的規則 • 第二行為設定使用 NAT 名稱轉換並偽裝成 eth0 (對外 IP) 的封包送出請求 • iptables的設定可以放在 /etc/rc.local的最下方 exit 0; 之前每次開機時會自動執行 /sbin/iptables -P FORWARD ACCEPT /sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE

  10. 其他電腦連線的設定 • 完成了 Linux 封包轉送的設定,理論上其他內部網路的電腦已經可以使用此 Linux 伺服器做為 Gateway 上網 • 其他電腦在 IP 的設定上則使用,內部網路規畫的 IP 網段以連線到做為 Gateway 的伺服器,並設定 Gateway 的 IP(172.22.22.1) 做為參數 • DNS 則使用與 Gateway 相同的 DNS 即可 • 使用ping 測試是否與外部網路能夠聯繫 • ping www.hinet.net auto lo iface lo inet loopback auto eth0 ifaceeth0 inet static address 172.22.22.2 netmask 255.255.255.0 network 172.22.22.0 gateway 172.22.22.1 dns-nameservers 10.20.30.15 10.20.30.16

  11. DHCPServer • 一般用戶的電腦對於 IP 位置若無特別定規劃,我們通常會架設 DHCP 伺服器動態分配 IP,以便一般的電腦無需做 IP 的設定即可上網 • DHCP 主要的優點 • 節省設定的時間 • 分配較具彈性 • 解決 IP 位置不足的問題 (可共用 IP) • 在 Ubuntu 中要架設 DHCP 伺服器需要安裝 isc-dhcp-server 的套件 • sudo apt-get install isc-dhcp-server • 並設定 DHCP 的設定檔 • sudo vi /etc/dhcp/dhcpd.conf

  12. 設定 DHCP Server • DHCP 伺服器的設定檔最主要設定的項目有兩個 • IP 租賃的時間 • IP 分配出去保留的時間及可使用的時間,多久會重新分配? • PI 租賃的 IP 相關資訊 • 所要分配出去的 IP 網段、遮罩、範圍、DNS 伺服器與 Gateway ddns-update-style none; # option definitions common to all supported networks... option domain-name "codeghar.com"; option domain-name-servers 10.20.30.15, 10.20.30.16; default-lease-time 3600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # This is a very basic subnet declaration. subnet 172.22.22.0netmask255.255.255.0 { range 172.22.22.21 172.22.22.250; option subnet-mask 255.255.255.0; option routers 172.22.22.1; }

  13. 設定 Proxy 代理伺服器可以暫存使用者於網頁上瀏覽的內容,當下一次再瀏覽時則使用暫存的內容做為回應,以減少對外網路的頻寬使用量

  14. Ubuntu 安裝代理伺服器 • 安裝代理伺服器 • sudo apt-get install squid • 設定代理伺服器 • sudovi /etc/squid/squid.conf • 設定可以使用代理伺服器的網段 • acllanhomesrc172.22.22.0/255.255.255.0 • 加入允許使用代理伺服器的網端 • http_accessallow lanhome • 重新啟動代理伺服器 • service squid3 restart

  15. 用戶端的設定 每一台使用的電腦必須在瀏覽器的設定中額外做設定 Squid Proxy 預設使用的埠號為 3128

More Related