国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務(wù)器 > Web服務(wù)器 > 正文

CentOS 7 下使用 iptables

2024-09-01 13:47:51
字體:
供稿:網(wǎng)友
禁用FireWallD,安裝&啟用iptables-services systemctl stop firewalld systemctl mask firewalld yum install iptables-services -y systemctl enable iptables
 

系統(tǒng)升級到CentOS 7后總感覺iptables怪怪的,比如不管怎么保存重啟后都被初始化一下,即便我最后發(fā)大絕招啟動時候加命令:
首先iptables-save > /etc/iptables.rules保存當(dāng)前狀態(tài)。
然后再在/etc/rc.local中強(qiáng)制加上

/etc/rc.local   

iptables-restore /etc/iptables .rules

重啟后雖然規(guī)則生效但仔細(xì)看規(guī)則還是一些被莫名添加的額外的內(nèi)容,讓人很是不爽。

仔細(xì)一google,發(fā)現(xiàn)問題之所在了。RedHat在7中更改了系統(tǒng)軟件,不再使用iptables作為系統(tǒng)的防火墻,而是使用了FirewallD,但是為了兼容過去的命令也可以使用iptables來設(shè)置防護(hù)規(guī)則,但啟動的時候自搞了一套。

解決方法也很簡單。

首先,可以考慮follow官方的想法轉(zhuǎn)用FirewallD。其實查看一些官方文檔也能用。
但是,個人覺得若沒有顯著的提升也可以繼續(xù)使用原來的iptables。若打算繼續(xù)使用iptables, 可以繼續(xù)做如下:

備份當(dāng)前規(guī)則

iptables-save > iptables.rules 
禁用FireWallD,安裝&啟用iptables-services systemctl stop firewalld systemctl mask firewalld yum install  iptables-services -y  systemctl enable  iptables    

這時候檢查iptables發(fā)現(xiàn)規(guī)則被清空了

iptables -L -x -n

將備份的規(guī)則還原

iptables-restore iptables.rules

保存當(dāng)前規(guī)則

/usr/libexec/iptables/iptables .init save

若使用minimize版本的安裝,可能會出現(xiàn)提示

iptables: Saving firewall rules to /etc/sysconfig/iptables: /etc/init.d/iptables: line 274: restorecon: command not found

這是因為selinux沒有安裝的緣故,缺少一個組件。安裝policycoreutils即可。

yum install policycoreutils -y



發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 宿松县| 绥棱县| 桃园市| 奈曼旗| 衡阳市| 石楼县| 仙居县| 阿坝县| 洛南县| 包头市| 五河县| 林西县| 龙南县| 丹巴县| 博野县| 象州县| 云和县| 建始县| 芮城县| 海丰县| 仁寿县| 长白| 克山县| 田阳县| 曲水县| 藁城市| 沐川县| 神木县| 岳普湖县| 农安县| 行唐县| 札达县| 红原县| 杂多县| 无棣县| 济阳县| 工布江达县| 盐源县| 常山县| 大同市| 西藏|