iptables 學習總結--規則管理(三)
檢視規則
[[email protected] ~]# iptables -t filter -nvL INPUT --line
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 369 32355 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
2 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
3 11 1961 INPUT_direct all -- * * 0.0.0.0/0 0.0.0.0/0
4 11 1961 INPUT_ZONES_SOURCE all -- * * 0.0.0.0/0 0.0.0.0/0
5 11 1961 INPUT_ZONES all -- * * 0.0.0.0/0 0.0.0.0/0
6 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
7 10 1897 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
清除規則
[root@localhost ~]# iptables -t filter -F INPUT
[root@localhost ~]# iptables -t filter -nvL INPUT --line
Chain INPUT (policy ACCEPT 9 packets, 636 bytes)
num pkts bytes target prot opt in out source destination
ping 該主機
新增規則
[[email protected] ~]# iptables -t filter -I INPUT -s 192.168.1.39 -j DROP
[[email protected] ~]# iptables -t filter -nxL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 192.168.1.39 0.0.0.0/0
ping不通
-I --表示新增
-s 表示源地址
-j --表示執行的動作
[[email protected] ~]# iptables -t filter -nxvL INPUT
Chain INPUT (policy ACCEPT 41 packets, 3289 bytes)
pkts bytes target prot opt in out source destination
231 19404 DROP all -- * * 192.168.1.39 0.0.0.0/0
APPEND 追加規則不生效,原因是同一個規則,只要在最前面才生效
[[email protected] ~]# iptables -t filter -A INPUT -s 192.168.1.39 -j ACCEPT
[[email protected] ~]# iptables -t filter -nxvL INPUT
Chain INPUT (policy ACCEPT 7 packets, 488 bytes)
pkts bytes target prot opt in out source destination
393 33012 DROP all -- * * 192.168.1.39 0.0.0.0/0
0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
新增的方式加規則,通了
[[email protected] ~]# iptables -t filter -nxvL INPUT
Chain INPUT (policy ACCEPT 8 packets, 588 bytes)
pkts bytes target prot opt in out source destination
74 6216 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
595 49980 DROP all -- * * 192.168.1.39 0.0.0.0/0
0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
指定新增規則位置
[root@localhost ~]# iptables -t filter -I INPUT 1 -s 192.168.1.39 -j DROP
刪除規則
兩種方式刪除
1.根據規則號去刪除
[[email protected] ~]# iptables -t filter -nxvL INPUT --line
hain INPUT (policy ACCEPT 9 packets, 636 bytes)
num pkts bytes target prot opt in out source destination
1 298 25032 DROP all -- * * 192.168.1.39 0.0.0.0/0
2 157 13188 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
3 595 49980 DROP all -- * * 192.168.1.39 0.0.0.0/0
4 0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
[[email protected] ~]# iptables -t filter -D INPUT 1
[[email protected] ~]# iptables -t filter -nxvL INPUT --line
Chain INPUT (policy ACCEPT 7 packets, 488 bytes)
num pkts bytes target prot opt in out source destination
1 163 13692 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
2 595 49980 DROP all -- * * 192.168.1.39 0.0.0.0/0
3 0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
2.根據具體的比配條件以及動作刪除
[[email protected] ~]# iptables -t filter -nxvL INPUT --line
Chain INPUT (policy ACCEPT 19 packets, 1352 bytes)
num pkts bytes target prot opt in out source destination
1 286 24024 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
2 595 49980 DROP all -- * * 192.168.1.39 0.0.0.0/0
3 0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
[[email protected] ~]# iptables -t filter -D INPUT -s 192.168.1.39 -j ACCEPT
[[email protected] ~]# iptables -t filter -nxvL INPUT --line
Chain INPUT (policy ACCEPT 7 packets, 488 bytes)
num pkts bytes target prot opt in out source destination
1 599 50316 DROP all -- * * 192.168.1.39 0.0.0.0/0
2 0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
刪除某張表的所有的規則
iptables -t filter -F
刪除某張表的對應的鏈下的所有的規則
iptables -t filter -F INPUT
修改規則
[[email protected] ~]# iptables -t filter -nxL INPUT --line
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 192.168.1.39 0.0.0.0/0
2 ACCEPT all -- 192.168.1.39 0.0.0.0/0
修改預設策略iptables -t 表 -P 鏈 動作
[[email protected] ~]# iptables -t filter -nxvL INPUT --line
Chain INPUT (policy ACCEPT 20 packets, 1424 bytes)
num pkts bytes target prot opt in out source destination
1 124 10416 REJECT all -- * * 192.168.1.39 0.0.0.0/0 reject-with icmp-port-unreachable
2 0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
[root@localhost ~]# iptables -t filter -P INPUT DROP
iptables -t filter -P INPUT ACCEPT
[[email protected] ~]# iptables -t filter -xnvL INPUT
Chain INPUT (policy ACCEPT 92 packets, 8623 bytes)
pkts bytes target prot opt in out source destination
444 37296 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
0 0 ACCEPT all -- * * 192.168.1.39 0.0.0.0/0
儲存規則
上面所做的操作都是臨時的,重啟就失效了,所以得儲存起來
配置好yum源以後安裝iptables-service
# yum install -y iptables-services
#停止firewalld
# systemctl stop firewalld
#禁止firewalld自動啟動
# systemctl disable firewalld
#啟動iptables
# systemctl start iptables
#將iptables設定為開機自動啟動,以後即可通過iptables-service控制iptables服務
# systemctl enable iptables
[[email protected] ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ 確定 ]
cat /etc/sysconfig/iptables
iptables-save >/etc/sysconfig/iptables
過載iptable
iptables-restore </etc/sysconfig/iptables
參考:
規則管理
相關推薦
iptables 學習總結--規則管理(三)
檢視規則 [[email protected] ~]# iptables -t filter -nvL INPUT --line Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts by
學習總結:工程管理與makefile
管理 用法 ron 有效 第一個 可執行 多目錄 log 包含 工程管理與makefile 一、為什麽需要makefile和make 一個工程中的源文件可能很多,按照類型、功能、模塊分別放在若幹個目錄中,為了有效地管理軟件工程,更高效地編譯整個工程,需要用到makefile
javaweb學習總結(十)——TCP三次握手 四次握手
在談及TCP建立連線和釋放連線過程,先來簡單認識一下TCP報文段首部格式的的幾個名詞 序列號seq:佔4個位元組,用來標記資料段的順序,TCP把連線中傳送的所有資料位元組都編上一個序號,第一個位元組的編號由本地隨機產生;給位元組編上序號後,就給每一
strom學習總結——我從三個緯度開始:maven工程、徐明明部落格和應用場景。
關於storm學習,我從三個緯度開始:maven工程、徐明明部落格和應用場景。 1、maven工程 pom檔案配置 <repositories> <repository> <id>central</id> <na
iptables(三)iptables規則管理(增、刪、改)
學會 人的 pan 刪除 accept 查看命令 風格 啟動 字段 上一篇文章中,我們已經學會了怎樣使用iptables命令查看規則,那麽這篇文章我們就來總結一下,怎樣管理規則。 之前,我們把查看iptables規則的操作比作"增刪改查"當中的"查",那麽在這篇文章中,我們
微信開發學習總結(三)——訊息管理(2)-接受普通訊息和被動回覆使用者訊息
上一節內容: 微信開發學習總結(三)——訊息管理(1) https://blog.csdn.net/qq_29914837/article/details/82903594 訊息管理具有的各個子模組功能,現在我們將一個詳細介紹如何使用 一、接受普通訊息介面介紹 1.1
微信開發學習總結(三)——訊息管理(1)
上一節內容: 微信開發學習總結(二)——微信開發環境準備(2) https://blog.csdn.net/qq_29914837/article/details/82896861 接收普通訊息 當普通微信使用者向公眾賬號發訊息時,微信伺服器將POST訊息的XML資料包到開
2018-2019-1 20189215 《文獻管理與資訊分析》第三週課程學習總結
第三週 RSS 同步世界最新資訊 學習內容總結 RSS可以幫助我們實現知識工作自動化,避免將大部分時間都用在可重複的繁複工作中,不要搶機器人飯碗。 3.1我們需要怎樣的資訊工具 人是資訊的集合體 資訊質量決定了人與人之間的差異 見多識廣,視野才會更加開闊 持續積累,才能成為
Solr學習總結(三)Solr web 管理後臺
前面講到了Solr的安裝,按道理,這次應該講講.java與資料庫的內容,java如何操作Solr索引等。不過我還是想先講一些基礎的內容,比如solr查詢引數如何使用,各個引數都代表什麼意思? 還有solr 自帶的web 管理系統如何使用等。只有先明白了solr的基本內容,
2014025665《嵌入式系統程序設計》第三、四周學習總結
-i 源代碼 nss gcc 一個 usr 交叉開發 64位 操作系統 第三周1.我們在帶三周的嵌入式程序設計中學到了如何搭建嵌入式Linux交叉開發環境。其實主要是解決64位系統下如何安裝32位程序的問題。①若聯網:Syum install Id-Linux.so.2②若
2014025635(09)《嵌入式程序設計》第三,四周學習總結
efi 必須 修改 update input 找不到 變量 pwd 都是 1.第三四周學習情況 本周學習進度不慢,上課也能跟著老師敲代碼了,老師說一些指令也知道是什麽意思了,這兩周我認為非常重要的快捷鍵就是tab鍵,補全代碼,我自己手敲肯定出現很多錯誤,必須Tab鍵!!!!
2014025670《嵌入式系統程序設計》第三,四周學習總結
進行 中學 linu 搭建 學習總結 64位 系統 問題 com 第三周我們在帶三周的嵌入式程序設計中學到了如何搭建嵌入式Linux交叉開發環境。其實主要是解決64位系統下如何安裝32位程序的問題。 進行實驗樓實驗的時候真的一定要特別細致,環環相扣,做了兩次實驗到最後都
20140256985《嵌入式程序設計》第三、四周學習總結
變量 學習總結 通過 印象 nbsp 安裝 內容 問題 代碼 1.第三四周學習情況 上課能跟上,而且新的虛擬機非常好使,編輯代碼的時候很是方便,沒有上一個虛擬機那麽復雜,非常好用! 2實驗樓學習內容 (1).安裝並解壓arm-linux-gcc交叉編譯工具 (
js學習總結----函數的三種角色
也有 {} pro -- 之間 fin bsp fine ons 註意:Function.prototype是函數數據類型的值,但是相關操作和之前的一模一樣->Empty/anonymous 函數本身也會有一些自己的屬性: length :形參的個數 nam
dubbo學習總結三 消費端
註意 服務端 註意點 發送 blog dubbo tro http ref 消費端跟服務端類似 註意點是dubbo:reference 和服務端的dubbo:service做區分 消費端主要是處理發送過來的請求 dubbo學習總結三 消費端
js學習總結----crm客戶管理系統之node編寫API接口
準備 獲取 ring length urn 使用 col asc ati 具體API代碼如下 var http = require(‘http‘), url = require(‘url‘), fs = require(‘fs‘); var server
js學習總結----crm客戶管理系統之前端頁面開發及數據渲染
bmi length element || useradd attribute xxx tle exe 具體代碼如下: index.html <!DOCTYPE html> <html lang="en"> <head> <
JavaScript學習總結(三、函數聲明和表達式、this、閉包和引用、arguments對象、函數間傳遞參數)
rem [1] incr foo i++ scrip erro ren 推薦 一、函數聲明和表達式 函數聲明: function test() {}; test(); //運行正常 function test() {}; 函數表達式: var test = fun
Spring學習之路(三)bean註解管理AOP操作
spec resource 自定義屬性 開始 java framework XML 方法名 jar包 在類上面、方法上面、屬性上面添加註解;並用bean來管理; 書寫方法:@註解名稱(屬性名稱=值) 第一步:導入jar包 導入spring-aop.jar(spri
JSP學習總結(三)
vol actor time 為什麽 pso ack sta instance 9.png 四、為什麽jsp就是servlet? 打開Tomcat服務器的work目錄,找到jsp文件翻譯的java文件。類聲明如下 package org.apache.jsp; im