Re: [問題] Ubuntu server 18.04的iptables怪怪的

看板Linux作者 (無名氏)時間4年前 (2020/01/04 20:09), 4年前編輯推噓2(202)
留言4則, 4人參與, 4年前最新討論串2/3 (看更多)
※ 引述《fordmvp (無名氏)》之銘言: : 標題: [問題] Ubuntu server 18.04的iptables怪怪的 : 時間: Mon Dec 30 21:02:56 2019 : : 本來有ufw但不符需求,無法鎖網卡和增加時間參數等。 : : 後來我把ufw移除了,但iptables怪怪的,用script shell輸入後,查iptables -L,規則 : 輸入成功,但是實際執行起來都無效。 : : : 我的iptables是1.6.1版。 : : -- : ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.82.248.7 (臺灣) : ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1577710978.A.242.html : → newversion: 所以你要問什麼? 12/30 23: 31 : 請問iptables為何會無效?要怎麼改善? : ※ 編輯: fordmvp (163.19.173.88 臺灣), 12/31/2019 09:19:35 : 請問iptables在18.04還可以用嗎? : : 以前我用14.04還好好的。 : : 不知道16.04情況如何? : ※ 編輯: fordmvp (163.19.173.88 臺灣), 12/31/2019 17:16:27 : → ssdoz2sk: 你應該拿出你目前的iptables資訊(iptables -nvL --line) 01/01 20: 05 : → ssdoz2sk: 然後說你現在想要從外面或哪個內網 ip 連到這台的哪個 01/01 20: 06 : → ssdoz2sk: port 走啥協定ipv4 ipv6等等的,一些基本資料 01/01 20: 08 : → ssdoz2sk: 阿不然我這樣回答你 iptables 可以用啊 01/01 20: 10 : → ssdoz2sk: 16 18 19 我都在用...好了,你的問題我解決了? 01/01 20: 10 : → duckfly: iptables-persistent netfilter-persistent 01/01 22: 23 抱歉,我之前資訊不足 我主要是參考這篇 https://s2.dces.tn.edu.tw/download/Ubuntu1804asTransparentGate_1.1.pdf 我的通透式防火牆建好了 之前是nameserver 沒弄好,導致防火牆主機本身無法上網,也不能更新。 ssh只有同網域ip可登入,外部ip即使修改INPUT和OUTPUT規則 也沒用。但現在改好後,已解決。 但FORWARD的部分一直無效,即使設了規則,內網的電腦仍可上網 完全擋不住,通行無阻。 例如:我下了 iptables -A FORWARD -d xxx.xxx.xxx.23 -j DROP iptables -A FORWARD -s xxx.xxx.xxx.23 -j DROP 至於iptables -nvL --line的部分,因為我是用script shell 寫規則。但是內容太多且很多涉及隱私。 實在不方便提供。 我的etc/rc.local #!/bin/bash## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing./etc/init.d/route.sh exit 0 後來我直接下 iptables -F 然後 iptables -P FORWARD DROP 再查iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination 但是還是沒用 請大家提供意見。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.126.170.22 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1578139741.A.B0F.html ※ 編輯: fordmvp (59.126.170.22 臺灣), 01/04/2020 20:09:44 ※ 編輯: fordmvp (59.126.170.22 臺灣), 01/04/2020 20:31:14

01/04 22:09, 4年前 , 1F
你確定你內網的電腦預設閘道是這台linux嗎...
01/04 22:09, 1F
我也懷疑過,但我把這台主機關機過,內網的電腦就無法上網了。 而且我也檢查過線路。 不然明天我再去檢查一次。 ※ 編輯: fordmvp (59.126.170.22 臺灣), 01/04/2020 22:12:54

01/05 19:30, 4年前 , 2F
-A 是加在最後,不然你用 -I 插在第一條看看?
01/05 19:30, 2F
我查過線路,確定沒問題。 我也測過把規則全清乾淨,只預設drop和封某個ip都沒用! 實在不知道怎麼辦了! 請神人解救! ※ 編輯: fordmvp (111.253.104.87 臺灣), 01/06/2020 21:29:24

01/07 09:40, 4年前 , 3F
看一下封包路徑怎麼跑的
01/07 09:40, 3F
請問怎麼看? ※ 編輯: fordmvp (223.141.132.69 臺灣), 01/07/2020 14:26:31

01/07 15:53, 4年前 , 4F
tracepath
01/07 15:53, 4F
文章代碼(AID): #1U481TiF (Linux)
文章代碼(AID): #1U481TiF (Linux)