中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

asp動態(tài)網(wǎng)站建設(shè)模擬搜索點擊軟件

asp動態(tài)網(wǎng)站建設(shè),模擬搜索點擊軟件,做一個商城網(wǎng)站需要什么流程,免費單頁網(wǎng)站文章目錄前言iptable簡介iptable命令使用iptables的四表五鏈nftables簡介nftables命令的時候nftables與iptables的區(qū)別iptables-legacy和iptables-nft實例將指定protocol:ip:port的流量轉(zhuǎn)發(fā)到本地指定端口前言 本文展示了,iptables和nftable命令的使用。 # 實驗環(huán)…

文章目錄

    • 前言
    • iptable簡介
      • iptable命令使用
      • iptables的四表五鏈
    • nftables簡介
      • nftables命令的時候
      • nftables與iptables的區(qū)別
    • iptables-legacy和iptables-nft
    • 實例
      • 將指定`protocol:ip:port`的流量轉(zhuǎn)發(fā)到本地指定端口

前言

本文展示了,iptables和nftable命令的使用。

# 實驗環(huán)境
5.15.0-58-generic #64~20.04.1-Ubuntu x86_64 GNU/Linux

iptable簡介


iptable命令使用

參考:iptables 命令,Linux iptables 命令詳解:Linux上常用的防火墻軟件 - Linux 命令搜索引擎、IptablesHowTo - Community Help Wiki

詳細見上方連接,命令結(jié)構(gòu)如下:

iptables -t 表名 <-A/I/D/R> 規(guī)則鏈名 [規(guī)則號] <-i/o 網(wǎng)卡名> -p 協(xié)議名 <-s 源IP/源子網(wǎng)> --sport 源端口 <-d 目標IP/目標子網(wǎng)> --dport 目標端口 -j 動作

下方是一個簡單的demo,阻斷指定(域名)地址的訪問。

# 列出filter表中(不同鏈的)已經(jīng)設(shè)置的規(guī)則
## -t參數(shù)不指定,默認是filter表
## sudo iptables-legacy -L
sudo iptables-legacy -t filter -nvL# 禁止訪問百度
sudo iptables-legacy  -t filter -A OUTPUT -d www.baidu.com -j REJECT# 刪除添加的規(guī)則
## 查看規(guī)則的序號
sudo iptables-legacy -t filter  -L --line-numbers
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  anywhere             180.101.50.188       reject-with icmp-port-unreachable
2    REJECT     all  --  anywhere             180.101.50.242       reject-with icmp-port-unreachable## 刪除規(guī)則
sudo iptables-legacy -t filter -D OUTPUT 1
sudo iptables-legacy -t filter -D OUTPUT 1# 清空整個fitter表所有鏈的規(guī)則
sudo iptables-legacy -t filter  -F

iptables的四表五鏈

參考:來,今天飛哥帶你理解 Iptables 原理!-51CTO.COM

上面命令的使用過程,可以讓我們對iptables這個命令,混個臉熟。

但是想要使用好iptbles規(guī)則,我們必須知道:1)明白規(guī)則,鏈,表之間的關(guān)系;2)數(shù)據(jù)的流向(即,經(jīng)過哪些點,哪些規(guī)則會起作用)

總的來說,邏輯理解上應(yīng)該是這樣:

  • 協(xié)議棧上存在鉤子函數(shù),數(shù)據(jù)在流經(jīng)協(xié)議棧的過程中,執(zhí)行相應(yīng)的鉤子函數(shù)。而這些鉤子函數(shù),即是規(guī)則,通過用戶層執(zhí)行iptables命令的方式放入。當條件匹配的時候,執(zhí)行相應(yīng)的動作。

  • 這些規(guī)則,根據(jù)目的/功能的不同,在不同的表中。表分為四種,raw,mangle,nat,filter。nat和filter比較常用,分別是地址轉(zhuǎn)換和包過濾。

  • 流量流經(jīng)不同的位置,存在不同的鏈。一個鏈,可以將不同表中不同的規(guī)則串聯(lián)起來。鉤子函數(shù)順著該鏈,執(zhí)行規(guī)則。

下面這兩張圖來自上面連接,我復(fù)制過來。

在這里插入圖片描述

上圖:數(shù)據(jù)接收過程走的是 1 和 2,發(fā)送過程走的是 4 、5,轉(zhuǎn)發(fā)過程是 1、3、5。有了這張圖,我們能更清楚地理解 iptables 和內(nèi)核的關(guān)系。

下圖:在每一個鏈上都可能是由許多個規(guī)則組成的。在 NF_HOOK 執(zhí)行到這個鏈的時候,就會把規(guī)則按照優(yōu)先級挨個過一遍。如果有符合條件的規(guī)則,則執(zhí)行規(guī)則對應(yīng)的動作。而這些規(guī)則根據(jù)用途的不同,又可以raw、mangle、nat 和 filter。從整體上看,四鏈五表的關(guān)系如下圖

在這里插入圖片描述


nftables簡介


nftables命令的時候

ubuntu20默認沒有安裝nftables,需要我們手動安裝下。參考:nftables - Debian Wiki

sudo apt install nftables
# sudo systemctl enable nftables.service

關(guān)于命令的使用,可以參考:Nftables HOWTO in Chinese、nftables 配置與使用記錄 - StarryVoid - Blog、nftables - ArchWiki、8.3.4. 使用 nft 命令管理表、鏈和規(guī)則 Red Hat Enterprise Linux 8 | Red Hat Customer Portal

# 目標:和上一節(jié)一樣,禁止訪問百度(ipv4)# 創(chuàng)建表
## 列出所有存在的表
sudo nft list tables
## 添加一個inet類型(family)的表,表名為filter
sudo nft add table inet filter# 創(chuàng)建鏈
## 從zsh切換到bash,否則語句中的shell執(zhí)行會報語法錯誤
bash
## 在inet類型的filter表中,添加一個名為OUTOUT的基礎(chǔ)鏈
## 這個基礎(chǔ)鏈是filter類型,掛在在output鉤子上,優(yōu)先級是filter類型(0),默認的策略是放行
sudo nft add chain inet filter OUTPUT { type filter hook output priority filter\; policy accept \; }## 列出指定表中的鏈
sudo nft list table inet filter
table inet filter {chain input {type filter hook input priority filter; policy accept;}chain forward {type filter hook forward priority filter; policy accept;}chain output {type filter hook output priority filter; policy accept;}chain OUTPUT {type filter hook output priority filter; policy accept;}
}# 添加規(guī)則
## 禁止訪問百度(ip)
# sudo nft add rule inet filter OUTPUT ip daddr {180.101.50.242, 180.101.50.242} drop
sudo nft add rule inet filter OUTPUT ip daddr 180.101.50.188 drop
sudo nft add rule inet filter OUTPUT ip daddr 180.101.50.242 drop
## 查看表中的規(guī)則
sudo nft -a list chain inet filter OUTPUTtable inet filter {chain OUTPUT { # handle 4type filter hook output priority filter; policy accept;ip daddr 180.101.50.188 drop # handle 5ip daddr 180.101.50.242 drop # handle 6}
}## 刪除規(guī)則
sudo nft delete rule inet filter OUTPUT handle 5
## 清空鏈
sudo nft flush chain inet filter OUTPUT
## 刪除鏈
sudo nft delete chain inet filter OUTPUT
## 清空表
sudo nft flush table inet filter
## 刪除表
sudo nft delete table inet filter

nftables與iptables的區(qū)別

關(guān)于兩者在使用上的區(qū)別,

  • nftables 使用教程(如果打不開這篇連接,可以參考CentOS 8 都發(fā)布了,你還不會用 nftables? - 掘金,內(nèi)容是一樣的。)

  • 繼iptables之后的新一代包過濾框架是nftables_dog250的博客-CSDN博客

總的來說,nftables寫起來,更加靈活。(至于內(nèi)核中的區(qū)別,母雞)


iptables-legacy和iptables-nft

可以看到,我上面并沒有使用iptablesiptables-nft命令。

那么iptables、iptables-legacy、nft、iptables-nft,這之間有什么區(qū)別?

可以閱讀:iptables - Debian Wiki、iptables: The two variants and their relationship with nftables | Red Hat Developer、Using iptables-nft: a hybrid Linux firewall

總的來說:

  • iptables-legacy命令就是我們熟知的iptables,背后是iptables的框架。

  • nft背后使用的是nftables框架。

  • iptables-nft在使用命令上,和iptables-legacy相同,只是背后是nftables。(iptables-translate命令,可以將iptables命令轉(zhuǎn)換成nft命令)

  • iptables是個軟連接,可以在iptables-legacyiptables-nft之間切換。


實例

將指定protocol:ip:port的流量轉(zhuǎn)發(fā)到本地指定端口

去年(2022年),谷歌關(guān)閉了在中國的翻譯服務(wù)。我是google翻譯的重度用戶,不得不去尋找其他替代品。如果可以將谷歌翻譯的流量轉(zhuǎn)發(fā)到本地的指定端口,或許對于繼續(xù)使用谷歌翻譯有幫助。我嘗試了下,流量確實轉(zhuǎn)發(fā)了,但是如何繼續(xù)這個流量似乎是個問題。

我們以這個例子,來事件下iptable/nftables的使用。

首先,進行DNS查找。

nslookup translate.googleapis.com 8.8.8.8
Server:        8.8.8.8
Address:    8.8.8.8#53Non-authoritative answer:
Name:    translate.googleapis.com
Address: 142.251.42.234

將google翻譯的流量轉(zhuǎn)發(fā)到本地端口。

# 創(chuàng)建一個新鏈transparent,被OUTPUT鏈引用
sudo iptables-legacy -t nat -N transparent
sudo iptables-legacy -t nat -I OUTPUT -p tcp -j transparent# 將tcp 142.251.42.234:443的流量轉(zhuǎn)發(fā)到1089端口
sudo iptables-legacy -t nat -A transparent -p tcp -d 142.251.42.234 --dport 443 -j REDIRECT --to-ports 1089
sudo iptables-legacy -t nat -nvL# 清空并刪除transparent鏈
sudo iptables-legacy -t nat -F transparent
sudo iptables-legacy -t nat -X transparent

至于如何使用nft命令該如何去寫,這里不實現(xiàn)。但,我們看下轉(zhuǎn)發(fā)的哪條規(guī)則該如何寫。

$ iptables-translate -t nat -A transparent -p tcp -d 142.251.42.234 --dport 443 -j REDIRECT --to-ports 1089
# 在這之前,需要先行創(chuàng)建一個名為nat的ip類型表。表中添加一個名為transparent的鏈。
## 鏈的類型為nat,hook為OUTPUT
nft add rule ip nat transparent ip daddr 142.251.42.234 tcp dport 443 counter redirect to :1089
http://www.risenshineclean.com/news/26894.html

相關(guān)文章:

  • 源碼下載網(wǎng)站源碼廣西網(wǎng)絡(luò)優(yōu)化seo
  • 網(wǎng)站下載的軟件怎么安裝代寫1000字多少錢
  • 集團網(wǎng)站建設(shè)要多少錢sem推廣軟件選哪家
  • 一級a做爰片免費觀網(wǎng)站看無碼滄州網(wǎng)站建設(shè)
  • 網(wǎng)站建設(shè)英語翻譯資料產(chǎn)品軟文范例軟文
  • 深圳做網(wǎng)站 漢獅網(wǎng)絡(luò)seo合作代理
  • 長沙網(wǎng)站策劃在線優(yōu)化網(wǎng)站
  • 鄂州市政府網(wǎng)長沙seo培訓
  • 青島學網(wǎng)站建設(shè)的大學搜索關(guān)鍵詞技巧
  • 做網(wǎng)站需要公司么中國制造網(wǎng)網(wǎng)站類型
  • 做dhl底單的網(wǎng)站是 什么網(wǎng)絡(luò)營銷與直播電商專業(yè)就業(yè)前景
  • 致遠oa協(xié)同管理系統(tǒng)優(yōu)化大師apk
  • 瑞安外貿(mào)網(wǎng)站制作網(wǎng)站管理系統(tǒng)
  • 帝國+只做網(wǎng)站地圖百度app怎么找人工客服
  • 網(wǎng)站開發(fā) 后端服務(wù)草根seo視頻大全
  • 做模型網(wǎng)站賺錢么高端網(wǎng)站建設(shè)制作
  • 廣東全網(wǎng)推廣手機流暢優(yōu)化軟件
  • 謝崗鎮(zhèn)仿做網(wǎng)站百度免費
  • 美女網(wǎng)站源碼策劃公司是做什么的
  • 兩學一做網(wǎng)站 新聞有什么功能
  • 清原招聘網(wǎng)站建設(shè)成crm軟件
  • 給手機做網(wǎng)站的公司優(yōu)化設(shè)計答案五年級上冊
  • ps 做網(wǎng)站切圖線上營銷活動主要有哪些
  • 做網(wǎng)站版頭圖片網(wǎng)頁設(shè)計與制作步驟
  • 免費做外貿(mào)的網(wǎng)站平臺國內(nèi)最新新聞事件
  • 搜索網(wǎng)站不顯示圖片品牌整合營銷推廣
  • 建設(shè)維護網(wǎng)站未簽訂合同網(wǎng)絡(luò)軟文寫作
  • 群暉nas做網(wǎng)站怎么可以讓百度快速收錄視頻
  • 在web服務(wù)器做網(wǎng)站高端網(wǎng)站公司
  • 網(wǎng)站建設(shè)推廣優(yōu)化有哪些基本方法seo課程多少錢