導航:首頁 > 程序命令 > ubuntuiptables命令

ubuntuiptables命令

發布時間:2022-06-17 22:40:00

❶ ubuntu如何啟動iptables,無論怎麼弄都還是開啟失敗,導致路由轉發功能不可用

(一) 設置開機啟動iptables
# sysv-rc-conf --level 2345 iptables on

(二) iptables的基本命令
1. 列出當前iptables的策略和規則
# iptables -L -n
-n: 用數字形式顯示
# iptables -L -v
-v: 列印詳細的信息

2. 允許已經建立的連接接收數據
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

3. 開放埠22(SSH的默認埠),您要告訴iptables允許接受到的所有目標埠為22的TCP報文通過
iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
註:ssh代表22,可以在/etc/services中查到的服務都可以這樣使用。

4. 添加策略。策略也是一種規則,當所有規則都不匹配時,使用鏈的「策略」
鏈:INPUT, PREROUTING, FORWARD, POSTROUTING, OUTPUT

鏈策略的默認值是:ACCEPT。
表:filter (默認),nat,mangle。
#iptables -P INPUT DROP
#iptables -P OUTPUT ACCEPT
#iptables -P FORWARD DROP

root@patrick:~# iptables -L -n
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22

Chain FORWARD (policy DROP)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:22
----------------------------------------------------

5. 啟動包轉發功能
將內網的FTP請求轉發到外網的一個主機上。
iptables -t nat -A PREROUTING -p tcp -dport 21 -j DNAT --to-dest 10.25.1.7:21
查看:
# iptables -L -t nat
要實現包轉發,還需要編輯內核參數。
# cat /proc/sys/net/ipv4/ip_forward
0
默認包轉發是禁止的。於是需要打開。編輯/etc/sysctl.conf,然後執行sysctl -p。

(三)保存iptables的規則
step 1) 保存當前iptables的規則到文件中。
# iptables-save > /etc/iptables.up.rules
step 2) 開機恢復iptables的規則。方法是添加下面這行到文件『/etc/network/interfaces/』 的末尾。
pre-up iptables-restore < /etc/iptables.up.rules

(四)禁用防火牆
iptables -F
似乎Ubuntu中沒有類似service iptables stop這樣的命令來暫停iptables。只能使用這種方法來禁用iptables(防火牆)。
使用前,請保證規則已經備份在文件中。

❷ ubuntu14.04怎麼關掉防火牆

1.關閉ubuntu的防火牆 ufw disable

2.卸載了iptables apt-get remove iptables,用iptables -F這個命令來關閉防火牆,但是使用這個命令前,千萬記得用iptables。

具體如下:

電腦常見問題解決

1、無法自動識別硬碟控制器

使用非正版的個別操作系統光碟,在安裝系統時,容易出現此錯誤。原因是非正版光碟自動載入的硬碟控制器驅動不符合電腦自身需要的驅動。這種情況就建議換正版光碟安裝操作系統。

2、手動更新錯誤的驅動程序

windows操作系統正常使用,但手動更新驅動程序把硬碟控制器的驅動程序更新錯誤,導致此故障。解決方法是進入windows系統高級菜單,選擇最後一次的正常配置,即可正常進入系統。

3、bios設置變化後所導致

windows操作系統正常,但是由於某些原因,用戶修改了bios設置,導致0x0000007b故障。

❸ ubuntu 利用iptables如何實現使用代理上網

iptables -A PREROUTING -s 192.168.0.0/255.255.240.0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8082
如果還不行,再加下面哪條試一下
iptables -A OUTPUT -p tcp --m state --state NEW -m tcp --dport 8082 -j ACCEPT
同時注意策略規則順序

❹ ubuntu怎麼關閉iptables

1、關閉ubuntu的防火牆 ufw disable 開啟防火牆 ufw enable 2、卸載了iptables apt-get remove iptables 3、關閉ubuntu中的防火牆的其餘命令 iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables

❺ 我在Ubuntu系統上執行了iptables -P INPUT ACCEPT和iptables -P OUTPUT ACCEPT 請問如何刪除掉這兩條命令

如何使用手動方式清空與重置 iptables firewall rule?

若是純手動的方始清空所有規則設定,一般可以採用下列方式:

1. iptables -F # 若是沒有加上 -t 指定 table,預設是使用 -t filter
2. iptables -X
3.

4. iptables -F -t nat
5. iptables -X -t nat
6.

7. iptables -F -t mangle
8. iptables -X -t mangle

其中 -F 表示清除指定 table 內所有 chain 項目內的規則清單設定。 -X 則是表示刪除使用者自訂的 chain 項目。

除了清除外,建議需要把過濾預設的政策設定為 ACCEPT,也就是允許任何封包的傳輸不會被阻擋。

1. iptables -P INPUT ACCEPT # 沒加上 -t 指定 table,預設使用 -t filter
2. iptables -P OUTPUT ACCEPT
3. iptables -P FORWARD ACCEPT
4.

5. iptables -t nat -P OUTPUT ACCEPT
6. iptables -t nat -P PREROUTING ACCEPT
7. iptables -t nat -P POSTROUTING ACCEPT
8.

9. iptables -t mangle -P PREROUTING ACCEPT
10. iptables -t mangle -P POSTROUTING ACCEPT
11. iptables -t mangle -P INPUT ACCEPT
12. iptables -t mangle -P OUTPUT ACCEPT
13. iptables -t mangle -P FORWARD ACCEPT

同時,後續若是手動打造 iptables firewall rule 的時候,該技巧也應該用上,也就是先清除之前規則外,包含把預設的政策都改成 ACCEPT,這樣配置 firewall 規則才不會混亂不堪。

❻ ubuntu 使用iptables 如何禁止任何和埠5353的訪問

iptables -A INPUT -S port:5353 deny 就是禁止任意IP的源口為5353的包入站
或者

iptables -A OUTPUT -d port:5353 deny 禁止任意IP的目的口為5353的包出站
可以設置行為禁止做丟棄包,這是對你本機,轉發的要另寫

❼ ubuntu16.04怎麼開iptables

(一) 設置開機啟動iptables # sysv-rc-conf --level 2345 iptables on (二) iptables的基本命令 1. 列出當前iptables的策略和規則 # iptables -L -n -n: 用數字形式顯示 # iptables -L -v -v: 列印詳細的信息 2. 允許已經建立的連接接收數...

❽ ubuntu怎麼關防火牆

ubuntu 9.10默認的便是UFW防火牆,它已經支持界面操作了。在命令行運行ufw命令就可以看到提示的一系列可進行的操作。
最簡單的一個操作:sudo ufw status可檢查防火牆的狀態,我的返回的是:不活動
sudo ufw version防火牆版本:
ufw 0.29-4ubuntu1
Copyright 2008-2009 Canonical Ltd.
ubuntu 系統默認已安裝ufw.
1.安裝
sudo apt-get install ufw
2.啟用
sudo ufw enable
sudo ufw default deny

❾ 在ubuntu虛擬系統下實現iptables的配置,為什麼輸入命令後全部顯示「找不到命令」呢

iptables -L, iptables -F,注意,iptables與後面的參數中間有個空格

閱讀全文

與ubuntuiptables命令相關的資料

熱點內容
水經注pdf 瀏覽:551
android多線程編程實例 瀏覽:534
蘋果和安卓用什麼軟體可以傳軟體 瀏覽:883
伺服器上如何設置ip許可權 瀏覽:445
linux好玩游戲 瀏覽:7
我的世界三種命令方塊有什麼不同 瀏覽:905
單片機spi常式 瀏覽:508
安卓撥號器怎麼使用 瀏覽:609
uc書城是什麼app 瀏覽:935
安卓手機如何打開bin文件cad看圖c 瀏覽:732
單片機ram數據 瀏覽:598
螺桿製冷壓縮機原理 瀏覽:991
ug加工命令的說明大全 瀏覽:787
程序員icu吐槽 瀏覽:258
證券投資基礎pdf 瀏覽:736
aarr計演算法高血壓 瀏覽:916
向右轉英語怎麼讀app 瀏覽:574
c英文版pdf 瀏覽:592
了不起的程序員2021出版日期 瀏覽:198
程序員那麼可愛下載在線 瀏覽:136