作者fordmvp (无名氏)
看板Linux
标题Re: [问题] Ubuntu server 18.04的iptables怪怪的
时间Sat Jan 4 20:08:59 2020
※ 引述《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://webptt.com/cn.aspx?n=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://webptt.com/cn.aspx?n=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
1F:→ guardlan: 你确定你内网的电脑预设闸道是这台linux吗...01/04 22:09
我也怀疑过,但我把这台主机关机过,内网的电脑就无法上网了。
而且我也检查过线路。
不然明天我再去检查一次。
※ 编辑: fordmvp (59.126.170.22 台湾), 01/04/2020 22:12:54
2F:推 Gold740716: -A 是加在最後,不然你用 -I 插在第一条看看?01/05 19:30
我查过线路,确定没问题。
我也测过把规则全清乾净,只预设drop和封某个ip都没用!
实在不知道怎麽办了!
请神人解救!
※ 编辑: fordmvp (111.253.104.87 台湾), 01/06/2020 21:29:24
3F:推 chang0206: 看一下封包路径怎麽跑的01/07 09:40
请问怎麽看?
※ 编辑: fordmvp (223.141.132.69 台湾), 01/07/2020 14:26:31
4F:→ sky791127: tracepath 01/07 15:53