Linux防火牆配置—訪問外網WEB

來源:互聯網
上載者:User

標籤:關閉   gre   linu   搭建web服務   本地yum源   網關   href   related   測試   

一、實驗目標

1、本次實驗在“Linux基礎網路搭建實驗”的基礎上,在外網虛擬機器上搭建WEB服務,並分別配置外網和網關的防火牆規則,使內網能夠訪問WEB服務

2、Linux基礎網路搭建實驗:http://www.cnblogs.com/liaoyuanyang/p/6749416.html

3、實驗拓撲:  

二、實驗步驟

1、建立的網路拓撲結構,內外網聯通,網關防火牆也暫時關閉

2、外網測試主機配置

(1)配置本地Yum源(參考:http://www.cnblogs.com/liaoyuanyang/p/6746542.html)

(2)檢查系統是否安裝WEB伺服器,如有,則啟動該服務,如沒有,則安裝該服務

[[email protected] 案頭]# rpm -qa |grep httpd  //檢查系統是否安裝WEB[[email protected] 案頭]# yum install httpd -y  //安裝WEB

(3)檢查WEB伺服器是否運行正常

在瀏覽器中訪問202.3.4.10,如出現APACHE的測試頁面,則表示WEB伺服器正常運行並可以訪問

(4)在內網測試機上訪問WEB伺服器,顯示為無法訪問

(5)在外網測試機上對外開放WEB服務

  1)清空防火牆規則,設定預設規則

[[email protected] yum.repos.d]# iptables -F[[email protected] yum.repos.d]# iptables -X[[email protected] yum.repos.d]# iptables -Z[[email protected] yum.repos.d]# iptables -P INPUT DROP[[email protected] yum.repos.d]# iptables -P OUTPUT DROP[[email protected] yum.repos.d]# iptables -P FORWARD DROP

  

  2)設定對外開放WEB伺服器

[[email protected] yum.repos.d]# iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT[[email protected] yum.repos.d]# iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT[[email protected] yum.repos.d]# iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT[[email protected] yum.repos.d]# iptables-save

  

(6)在內網主機上測試訪問

3、在網關上搭建內外網之間的防火牆

(1)啟動防火牆

(2)在內網測試主機上訪問WEB伺服器(應為無法訪問)

(3)清空防火牆規則,設定預設規則

[[email protected] 案頭]# iptables -F[[email protected] 案頭]# iptables -X[[email protected] 案頭]# iptables -Z[[email protected] 案頭]# iptables -P INPUT DROP[[email protected] 案頭]# iptables -P OUTPUT DROP[[email protected] 案頭]# iptables -P FORWARD DROP[[email protected] 案頭]# iptables -A FORWARD -d 202.3.4.10/32 -i eth0 -o eth1 -p tcp -m tcp --dport 80 -j ACCEPT[[email protected] 案頭]# iptables -A FORWARD -s 202.3.4.10/32 -m state --state RELATED,ESTABLISHED -j ACCEPT[[email protected] 案頭]# iptables-save

(4)內網主機上測試(能夠正常訪問)

Linux防火牆配置—訪問外網WEB

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.