1、安裝
連接服務(wù)器后,打開/etc/sysconfig/目錄,然后運(yùn)行以下命令安裝
service iptables status // 檢查是否安裝了iptables
yum install -y iptables // 安裝iptables
yum update iptables // 升級(jí)iptables
yum install iptables-services //安裝iptables-service
提示Complete!即沒問題
2、如果有安裝防火墻服務(wù),先停止:
rpm -qa | grep firewalld //檢查有沒有
有的話就停止:
systemctl stop firewalld // 停止firewalld服務(wù)
3、iptables的使用:
systemctl enable iptables.service // 設(shè)置防火墻開機(jī)啟動(dòng)
systemctl start iptables // 啟動(dòng)防火墻
systemctl stop iptables // 關(guān)閉防火墻,關(guān)閉時(shí)才運(yùn)行此命令
systemctl restart iptables // 重啟防火墻,重啟時(shí)才運(yùn)行此命令
vim /etc/sysconfig/iptables // 查看防火墻編輯,最好是通過下面的語句來運(yùn)行:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8080 -j ACCEPT //這兩句命令都需要執(zhí)行,8080即為想要打開的端口號(hào)
service iptables save // 保存編輯
iptables -L -n // 查看已有防火墻配置,看前面兩個(gè)accept是否執(zhí)行成功
如果還是不行的話,執(zhí)行iptables -F,清除所有的命令,重新再試一遍(我就是試了兩遍才可以的),一定要注意保存!文章來源:http://www.zghlxwxcb.cn/news/detail-566584.html
=============有問題隨時(shí)留言==========文章來源地址http://www.zghlxwxcb.cn/news/detail-566584.html
到了這里,關(guān)于iptables的安裝和使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!