iptables與firewalld兩種方式防火牆切換
用iptables開啟防火牆報錯: Failed to start IPv4 firewall with iptables.
錯誤原因:因為centos7.0預設不是使用iptables方式管理,而是firewalld方式。CentOS6.0防火牆用iptables管理。
解決辦法有兩個:使用firewalld方式。或者關閉firewalld,然後安裝iptables。
一、關閉firewalld,安裝iptables過程:
停止並遮蔽firewalld:
systemctl stop firewalld
systemctl mask firewalld
安裝iptables-services:
yum install iptables-services
設定開機啟動:
systemctl enable iptables
停止/啟動/重啟 防火牆:
systemctl [stop|start|restart] iptables
#or
service iptables [stop|start|restart]
儲存防火牆配置:
service iptables save
#or
/usr/libexec/iptables/iptables.init save
按照上述命令配置後的介面:
二、從iptables切換回firewalld
1、先看firewalld的狀態:inactive
2、安裝firewalld
3、切換到firewalld,切換過程與切換iptables一樣
/************下面是iptables的一些命令*******************************/
查詢防火牆狀態:
[[email protected] ~]# service iptables status
停止防火牆:
[[email protected] ~]# service iptables stop
啟動防火牆:
[[email protected] ~]# service iptables start
重啟防火牆:
[[email protected] ~]# service iptables restart
永久關閉防火牆:
[[email protected] ~]# chkconfig iptables off
永久關閉後啟用:
[[email protected] ~]# chkconfig iptables on
開啟埠:
[[email protected] ~]# vim/etc/sysconfig/iptables
/**********下面是firewalld的一些命令*****************************/
#systemctl statusfirewalld //檢視狀態,看電腦上是否已經安裝firewalld
#yum installfirewalld //安裝firewalld防火牆
#systemctl startfirewalld.service //開啟防火牆
#systemctl stop firewalld.service //關閉防火牆
#systemctl enable firewalld.service //設定開機自動啟動
#systemctl disable firewalld.service //設定關閉開機制動啟動
#firewall-cmd--reload //在不改變狀態的條件下重新載入防火牆
啟用某個服務
#firewall-cmd --zone=public --add-service=https //臨時
#firewall-cmd --permanent --zone=public --add-service=https //永久
開啟某個埠
#firewall-cmd--permanent --zone=public --add-port=8080-8081/tcp //永久
#firewall-cmd --zone=public --add-port=8080-8081/tcp //臨時
檢視開啟的埠和服務
#firewall-cmd--permanent --zone=public --list-services //服務空格隔開 例如 dhcpv6-client https ss
#firewall-cmd--permanent --zone=public --list-ports //埠空格隔開 例如 8080-8081/tcp 8388/tcp 80/tcp
#systemctl restartfirewalld.service //修改配置後需要重啟服務使其生效
#firewall-cmd--zone=public --query-port=8080/tcp //檢視服務是否生效(例:新增的埠為8080)
/**********下面是systemctl的一些命令*******************************/
觀察iptables和firewalld使用的兩組命令,發現三個常用的命令:service、chkconfig、systemctl。那麼它們分別是做什麼的呢?(去網上搜索了一下給出了答案)
systemctl命令是系統服務管理器指令,它實際上將 service 和 chkconfig 這兩個命令組合到一起。
任務 |
舊指令 |
新指令 |
使某服務自動啟動 |
chkconfig --level 3 httpd on |
systemctl enable httpd.service |
使某服務不自動啟動 |
chkconfig --level 3 httpd off |
systemctl disable httpd.service |
檢查服務狀態 |
service httpd status |
systemctl status httpd.service(服務詳細資訊) systemctl is-active httpd.service(僅顯示是否 Active) |
顯示所有已啟動的服務 |
chkconfig --list |
systemctl list-units --type=service |
啟動某服務 |
service httpd start |
systemctl start httpd.service |
停止某服務 |
service httpd stop |
systemctl stop httpd.service |
重啟某服務 |
service httpd restart |
systemctl restart httpd.service |
總結:
記是記不住的,實操才可以,熟能生巧。
抓住一個問題,深入去挖,往往能挖出一片,從而掃清一片盲點。深挖能出清泉。
參考文章:
相關推薦
iptables與firewalld兩種方式防火牆切換
用iptables開啟防火牆報錯: Failed to start IPv4 firewall with iptables. 錯誤原因:因為centos7.0預設不是使用iptables方式管理,而是firewalld方式。CentOS6.0防火牆用ipt
vue 路由傳參 params 與 query兩種方式的區別
fine 分享 文件 路由 註意 undefine 方法 router 由於 初學vue的時候,不知道如何在方法中跳轉界面並傳參,百度過後,了解到兩種方式,params 與 query。然後,錯誤就這麽來了: router文件下index.js裏面,是這麽定義路由
SparkSteaming中直連與receiver兩種方式的區別
SparkStreaming的Receiver方式和直連方式有什麼區別? Receiver接收固定時間間隔的資料(放在記憶體中的),使用高階API,自動維護偏移量,達到固定的時間才去進行處理,效率低並且容易丟失資料,靈活性特別差,不好,而且它處理資料的時候,如果某一刻的資料量過大,那麼就會造成磁碟溢寫的情況
python利用mongodb上傳圖片資料 : GridFS 與 bson兩種方式
利用mongodb儲存圖片通常有兩種方法,一種是將圖片資料轉化為二進位制作為字典的鍵值對進行儲存,另一種是利用mongodb提供的GridFS進行儲存,兩者各有利弊。效能方面的優劣未曾測試,無法進行評價,此處僅對兩種方式進行介紹,若有徹知者還望指教。 下面以如
mybatis關於SQL語句註解與XML兩種方式
細節記錄(此處未整合spring):1.SQL使用註解時,需手動新增Mapper:即sqlSessionFactory.getConfiguration().addMapper(XXXMapper.class);2.XML方式時,注意xml中的namespace的值為Mapp
關於串列埠通訊查詢與中斷兩種方式
void init_ser() //串列埠初始化 { TMOD=0x20; //定時器1工作於方式2 TH1=0xf3; //娤初值波特率為2400 TL1=0xf3; TR1=1; //開定時器1 SCON=0x50; //設定串列埠方式1 允許接收
Nginx配置同一個域名同時支援http與https兩種方式訪問
server { listen 80; listen 443 ssl; ssl on; server_name 域名; index index.html index.htm index.php default.html default.htm default.php; ssl_certificate /usr
WPS以及它的兩種方式PIN與PBC的理解
WPS - Wi-Fi Protected Setup PBC - Push ButtonConfiguration 這個是不需要密碼的方式 PIN - Personal Information Number 這個是要用密碼的方式通常用在電子裝置的互通,例如和電視機啥的 WPS分為PBC(BUT
建立的程序的兩種方式與常用屬性
建立程序的兩種方式 第一種使用multprocessing 開啟子程序第二種使用自定義的方式(設計繼承程序類的方式) from multiprocessing import Process class MyProcess(Process): def run(self): p
WKWebView與H5互動的兩種方式
互動方式一:原生互動(以WKWebView為栗子) 1.原生呼叫H5方法 [wkWebView evaluateJavaScript:@"js方法名" completionHandler:^(id _Nullable response, NSError * _Nullable err
div控制顯示與隱藏狀態的兩種方式
要點: 1.本人原來用的是IDEA編譯器,因為什麼環境都配置好了,程式碼提示功能也好,介面也優美,可惜什麼都好導致太龐大。本人在自習室敲程式碼,筆記本電池管不了一上午,後用sublime,真輕便哈哈。但是裡面的外掛的程式碼其實,應該是隻收錄了js的關鍵字,然後給的提示,並不會篩選。這裡,因為前段
linux系統中的防火牆(iptables與firewalld)——iptables
iptables 關閉firewalld開啟iptables 相關概念 IPTABLES 是與最新的 3.5 版本 Linux 核心整合的 IP 資訊包過濾系統。如果 Linux 系統連線到因特網或 LAN、伺服器或連線 LAN 和因特網的代理伺服器, 則該系統有利於在 Lin
linux系統中的防火牆(iptables與firewalld)——firewalld
防火牆 防火牆是整個資料包進入主機前的第一道關卡。防火牆主要通過Netfilter與TCPwrappers兩個機制來管理的。 1)Netfilter:資料包過濾機制 2)TCP Wrappers:程式管理機制 關於資料包過濾機制有兩個軟體:firewalld與iptables cento
兩種方式的交替列印 基於Synchronized 與 ReentrantLock
public class PrintABCTest { public static void main(String[] args) { PrintABC printABC = new PrintABC(); new Thread(()->{ for(int i = 1;i
SAP與金稅連線有兩種方式:元件介面及文字介面。
SAP與金稅連線有兩種方式:元件介面及文字介面。 文字介面為例: 1、SAP取發票資料,主要來自合同,銷售訂單,交貨單,發票,客戶供應商主資料等 2、SAP處理:合併,拆分,折扣等 3、匯出TXT文字 4、金稅開票機讀取文字:通過引數傳遞資料,注意1分錢誤差問題(引數傳遞導致) 5、回寫
建立github遠端倉庫與本地連線的兩種方式
準備 下好Git Bash和註冊github賬號 建立ssh公鑰 bash下 ssh-keygen -t rsa -C "[email protected]" 到C:\Users\City.ssh下複製id_rsa.pub的內容 在github 賬號 的setti
Spark-Streaming獲取kafka資料的兩種方式:Receiver與Direct的方
簡單理解為:Receiver方式是通過zookeeper來連線kafka佇列,Direct方式是直接連線到kafka的節點上獲取資料 回到頂部 使用Kafka的高層次Consumer API來實現。receiver從Kafka中獲取的資料都儲存在Spark Exec
GreenDao+RxJava 聯合使用,普通與響應式兩種方式
由於在進行資料庫的增刪改查時,是需要一部分執行時間的,而我們需要的是在資料庫更新操作完成之後操作UI,如果資料庫未讀寫完畢,我們就進行了UI資料操作,則達不到我們的業務需求,也會產生一定的BUG,所以採用 Rxjava輔助GreenDao資料庫。 常用API
JavaScript與html結合的兩種方式
JavaScript與html結合有兩種方式,下面就來介紹這兩種方式: (1)<script type="text/javascript">js程式碼</script> <!DOCTYPE html> <html lang="
input與label聯合使用的兩種方式
當用戶選擇label標籤時,瀏覽器會自動將焦點轉移到個label相關的input上 1.通過為input設定屬性id,在label標籤中設定for=id使label文字與對應的inpu他結合起來。 <label for="name">Name:</lab