Linux基础优化之SElinux和iptables项
生活随笔
收集整理的這篇文章主要介紹了
Linux基础优化之SElinux和iptables项
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
版權聲明:
###########################################################################
本文的所有內容均來自作者劉春凱的學習總結,未經本人許可,禁止私自轉發及使用。
QQ:1151887353
E-mail:dakai517@163.com??????1151887353@qq.com
##########################################################################
第1章?關閉SElinux的方法
1.1?操作前備份
法一:
[root@oldboyedu-36-02?~]#?cp/etc/selinux/config?/etc/selinux/config.bak
[root@oldboyedu-36-02?~]#?ls?/etc/selinux
config??config.bak??restorecond.conf??restorecond_user.conf??semanage.conf?targeted
法二:
[root@oldboyedu-36-02?~]#?sed?-i.ori's#SELINUX=enforcing#SELINUX=disabled#g'?/etc/selinux/config===-i.ori替換前備份文件;
[root@oldboyedu-36-02?~]#?ls?/etc/selinux
config?config.bak??config.ori??restorecond.conf??restorecond_user.conf??semanage.conf?targeted
1.2?永久關閉SElinux(修改配置文件)
[root@oldboyedu-36-02?~]#?cat?/etc/selinux/config?#?This?file?controls?the?state?of?SELinux?on?thesystem.
#?SELINUX=?can?take?one?of?these?three?values:
#????enforcing?-?SELinux?security?policy?is?enforced.
#????permissive?-?SELinux?prints?warnings?instead?of?enforcing.
#????disabled?-?No?SELinux?policy?is?loaded.
SELINUX=enforcing
#?SELINUXTYPE=?can?take?one?of?these?two?values:
#????targeted?-?Targeted?processes?are?protected,
#?????mls?-Multi?Level?Security?protection.
SELINUXTYPE=targeted
[root@oldboyedu-36-02?~]#?sed?-i?'s#SELINUX=enforcing#SELINUX=disabled#g'/etc/selinux/config?
[root@oldboyedu-36-02?~]#?cat?/etc/selinux/config?#?This?file?controls?the?state?of?SELinux?on?the?system.
#?SELINUX=?can?take?one?of?these?three?values:
#????enforcing?-?SELinux?security?policy?is?enforced.
#????permissive?-?SELinux?prints?warnings?instead?of?enforcing.
#????disabled?-?No?SELinux?policy?is?loaded.
SELINUX=disabled
#?SELINUXTYPE=?can?take?one?of?these?two?values:
#????targeted?-?Targeted?processes?are?protected,
#?????mls?-Multi?Level?Security?protection.
SELINUXTYPE=targeted===需要重啟服務器才能生效(工作場景中不要以任何理由重啟服務器);1.3?臨時關閉
[root@oldboyedu-36-02?~]#?getenforce?===查看selinux狀態
Enforcing
[root@oldboyedu-36-02?~]#?setenforce?===查看selinux設置選項
usage:?setenforce?[?Enforcing?|?Permissive?|?1?|?0?]===1:開啟;0:提醒但不阻止;
[root@oldboyedu-36-02?~]#?setenforce?0===設置為0
[root@oldboyedu-36-02?~]#?getenforce
Permissive1.4?恢復SElinux的方法
法一:命令行恢復
setenforce?1;
法二:文件回復
1、通過vi、sed直接修改配置文件
2、mv/etc/selinux/config.bak?/etc/selinux/config==直接覆蓋配置文件
第2章?關閉防火墻iptables
2.1?臨時關閉iptables
查看防火墻狀態
法一:
/etc/init.d/iptables?status
法二:
service?iptables?status
臨時關閉防火墻
法一:
/etc/init.d/iptables?stop
/etc/init.d/iptables?stop???===執行關閉兩次,確保關閉;
法二:
service?iptables?stop
service?iptables?stop
/etc/init.d/iptables?status或者service?iptables?status?===修改完成后,再次查看iptables狀態;2.2?永久關閉iptables(開機自啟動項關閉iptables)
查看iptables是否開機自啟動
chkconfig?|?grep?ipt?或者chkconfig?--list?iptables關閉iptables的開機自啟動項
chkconfig?iptables?off再次查看iptables開機自啟動是否關閉
chkconfig?|?grep?ipt?或者chkconfig?--list?iptables
轉載于:https://blog.51cto.com/dakaige517/1922398
總結
以上是生活随笔為你收集整理的Linux基础优化之SElinux和iptables项的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Scrapy爬虫入门系列2 示例教程
- 下一篇: IntelliJ IDEA 中,英官网