centos 防火牆配置

來源:互聯網
上載者:User

標籤:blog   http   io   os   使用   ar   for   2014   sp   

1. 使用setup命令

[1] 開啟一個終端視窗,輸入setup命令

[[email protected] ~]# setup

[2] 選擇Firewall configuration, 選擇Run Tool,進入防火牆配置介面

[3] 勾選Enabled開啟防火牆,不勾選則不開啟,此處開啟,並選擇Customize進行自訂配置

[4] 選擇要開放的服務連接埠,此例選擇FTP,WWW(HTTP)。預設SSH服務連接埠是開啟的,用於SSH遠程登陸,如果是遠程配置Linux伺服器,則一定要保持SSH服務連接埠開啟,不要自斷後路。

[5] 配置好後一路Forward到最後儲存即可,若還有其它的連接埠要開放,中間也有相應的自訂頁面。最後到這個頁面時選擇Yes,覆蓋原設定儲存。

 

 

2. 命令列方式

[1] 編輯防火牆配置,21連接埠和80連接埠是增加的FTP服務與80服務連接埠

[[email protected] ~]# vi /etc/sysconfig/iptables# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT

[2] 關閉防火牆服務(暫時關閉防火牆服務,重啟後服務會自動開啟)

[[email protected] ~]# service iptables stopiptables: Flushing firewall rules:                         [  OK  ]iptables: Setting chains to policy ACCEPT: filter          [  OK  ]iptables: Unloading modules:                               [  OK  ]

[3] 配置防火牆服務預設開機不啟動 (如果伺服器不需要防火牆)

[[email protected] ~]# chkconfig iptables off


centos 防火牆配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.