木头虫在家

  • 系统
  • 安全
  • 应用
  • 技术
木头虫在家
蜘蛛网
  1. 首页
  2. 安全
  3. 正文

iptables规则的添加,查看及删除-怎么查看及删除一条已有的iptables规则

2019年6月20日 318点热度 0人点赞 0条评论

iptables -I INPUT -s 111.225.147.0/24 -j DROP

添加一条拒绝访问111.225.147.0/24的规则

 

[root@tp ~]# iptables -L INPUT --line-numbers

列出INPUT 链所有的规则

num target prot opt source destination
1 DROP all -- 110.249.202.0/24 anywhere
2 DROP all -- 111.225.148.0/24 anywhere
3 DROP all -- 110.249.202.0/24 anywhere
4 DROP all -- 220.243.0.0/24 anywhere
5 DROP all -- 110.249.201.0/24 anywhere
6 DROP all -- 111.225.0.0/24 anywhere

删除指定的第4行规则:

[root@tp ~]# iptables -D INPUT 4

注意如果要连续删除的时候请每次都使用iptables -L INPUT --line-numbers 列出查询后再删除行。以免删错行。因为每次删除后行号都是在变动的。

 

添加一个tcp的9000端口允许通过

# 在/etc/sysconfig/iptables加上这句
-A INPUT -p tcp -m tcp --dport 9000 -j ACCEPT

# 重启iptables
service iptables restart

 

Views: 59
标签: iptables
最后更新:2023年2月21日

admin

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

您需要 登录 之后才可以评论

COPYRIGHT © 2023 blog.qmun.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

浙ICP备11036795号