伺服器 Linux iptables 規則

2021-08-18 01:16:49 字數 1396 閱讀 6473

1.iptables 規則常見 管理控制選項

2.iptables防火牆常用的策略

1.拒絕進入防火牆的所有icmp協議資料報

iptables -i input -p icmp -j reject

2.允許防火牆**除icmp協議以外的所有資料報

iptables -a forward -p ! icmp -j accept

說明:使用「!」可以將條件取反。

3.拒絕**來自192.168.1.10主機的資料,允許**來自192.168.0.0/24網段的資料

iptables -a forward -s 192.168.1.11 -j reject

iptables -a forward -s 192.168.0.0/24 -j accept

說明:注意要把拒絕的放在前面不然就不起作用了啊。

4.丟棄從外網介面(eth1)進入防火牆本機的源位址為私網位址的資料報

iptables -a input -i eth1 -s 192.168.0.0/16 -j drop

iptables -a input -i eth1 -s 172.16.0.0/12 -j drop

iptables -a input -i eth1 -s 10.0.0.0/8 -j drop

5.封堵網段(192.168.1.0/24),兩小時後解封。

[root@server ~]# iptables -i input -s 10.20.30.0/24 -j drop

[root@server ~]# iptables -i forward -s 10.20.30.0/24 -j drop

[root@server ~]# at now +2 hours

at> iptables -d input 1

at> iptables -d forward 1

說明:這個策略咱們借助crond計畫任務來完成,就再好不過了。

[1]+ stopped at now +2 hours

6.只允許管理員從202.13.0.0/16網段使用ssh遠端登入防火牆主機。

iptables -a input -p tcp –dport 22 -s 202.13.0.0/16 -j accept

iptables -a input -p tcp –dport 22 -j drop

說明:這個用法比較適合對裝置進行遠端管理時使用,比如位於分公司中的sql伺服器需要被總公司的管理員管理時。

3.檢視iptables 全部規則

iptables –list

4.刪除iptables全部規則

iptables –flush

伺服器安裝Linux伺服器

新辦公需要搭建一台伺服器,之前也沒有怎麼搞過,不過有一些了解,於是和同事一起嘗試安裝一下伺服器。本人使用ultraiso燒錄u盤,系統檔案是centos 6.6 x86 64 bin 1.ios,使用urtraiso開啟iso檔案,然後如下圖 接著就可以寫入,u盤會被格式化的,注意備份,等待寫入就可...

mysql udp伺服器 UDP伺服器

傳輸層主要應用的協議模型有兩種,一種是tcp協議,另外一種則是udp協議。tcp協議在網路通訊中佔主導地位,絕大多數的網路通訊借助tcp協議完成資料傳輸。但udp也是網路通訊中不可或缺的重要通訊手段。相較於tcp而言,udp通訊的形式更像是發簡訊。不需要在資料傳輸之前建立 維護連線。只專心獲取資料就...

伺服器安裝apache伺服器

1.環境 centos7 2.鏈結伺服器 ssh username ip 3.安裝apache 4.設定apache在伺服器啟動時執行 5.在apache配置檔案中設定網域名稱 vi etc httpd conf httpd.conf,找到 servername 新增 網域名稱 80 儲存並退出。6...