vde*_*nne 3 firewall iptables docker
如果输入iptables -L,输出中将显示以下行:
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:http-alt
Run Code Online (Sandbox Code Playgroud)
我的容器是公开暴露的,我可以从任何地方(经过测试)请求一个虚拟http服务器。我尝试删除该规则,因此只有80个仅在服务器(localhost:80)内部公开。我试过了 :
root@ns25252:~# iptables -D DOCKER --destination 172.17.0.2 -p tcp --dport 80 -j ACCEPT
iptables: Bad rule (does a matching rule exist in that chain?).
Run Code Online (Sandbox Code Playgroud)
正如错误所暗示的,它找不到匹配的规则。我应如何键入以删除行?
通常,按数字删除更容易,除非在列出规则的时间与删除规则的时间之间数字可能会发生变化。
以下是按行号删除的方法:
# iptables -L --line-numbers
(snip)
Chain DOCKER (2 references)
num target prot opt source destination
1 ACCEPT tcp -- anywhere 172.17.0.2 tcp dpt:http
(snip)
# iptables -D DOCKER 1
Run Code Online (Sandbox Code Playgroud)
或者,您可以通过执行以获得完整的规范iptables -S。例:
# iptables -S
(snip)
-A DOCKER -d 172.17.0.2/32 -p tcp -m tcp --dport 80 -j ACCEPT
(snip)
Run Code Online (Sandbox Code Playgroud)
将-A变成a -D并将其用作args iptables删除规则:
# iptables -D DOCKER -d 172.17.0.2/32 -p tcp -m tcp --dport 80 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2727 次 |
| 最近记录: |