CentOS7 配置最基本的web環境 —— 詭異的iptables

來源:互聯網
上載者:User

標籤:centos   iptables   防火牆   

因為想試試Sphinx,所以裝了個CentOS7的虛擬機器。


前面很簡單,官方下載一個新的鏡像就可以,我用的64位的。


安裝好後,ifconfig可以看到ip地址,VMware選擇橋接才可以讓主機串連虛擬機器。


root進入系統後,嘗試用主機串連ftp,成功!


嘗試http,失敗。於是開始檢查httpd配置,沒發現可疑,最後找到了防火牆,也就是iptables。

iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT

執行後,web正常。


串連Mysql(其實是MariaDB,CentOS使用MariaDB替換了Mysql,不過還好,一切都一模一樣),失敗。

本地登入 mysql -u root -p成功,於是

iptables -A OUTPUT -p tcp --sport 3306 -j ACCEPT

再次遠端連線Mysql,成功。(這裡省略了在mysql裡執行GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘111111‘ WITH GRANT OPTION;)


於是開始搗鼓iptables。


iptable stop

重啟後問題依舊


iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT

iptables -A OUTPUT -p tcp --sport 3306 -j ACCEPT

service iptables save

重啟後問題依舊


chkconfig –level 35 iptables off

重啟後,問題依舊。


systemctl disable iptables.service

重啟後問題依舊


啟動後

service iptables status可以看到iptables服務確實關閉了,但規則還是生效,鬱悶了。


在/etc/sysconfig/下可以找到iptables的設定檔,在檔案裡添加了

-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT

重啟後,問題依舊。


最後妥協了,暫時先每次重啟打兩行命令吧!

CentOS7 配置最基本的web環境 —— 詭異的iptables

聯繫我們

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