也想出现在这里? 联系我们

在Linux系统中给iptables规则添加注释的教程

作者 : 小编 本文共1536个字,预计阅读时间需要4分钟 发布时间: 2022-11-4 共2.21K人阅读
也想出现在这里? 联系我们

给iptables规则添加注释,以此给你的老板和同事一个好印象。方法如下:

什么是iptables的注释呢?

iptables的注释一般使用在每条规则的后面,注释一般用 /* */ 包住。(具体的见下面的iptables规则中的注释 /* allow SSH to this host from anywhere */ )

复制代码

代码如下:

$ sudo iptables -L Chain INPUT (policy DROP) target prot opt source destination ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED /* allow inbound traffic for established and related connections */ fail2ban-ssh tcp — anywhere anywhere multiport dports ssh ACCEPT tcp — anywhere anywhere tcp dpt:ssh /* allow SSH to this host from anywhere */ ACCEPT udp — anywhere anywhere udp dpt:route /* allow incoming RIP on the internal interface */ ACCEPT all — localhost localhost /* allow any local-only traffic */ ACCEPT ipv6 — tserv2.ash1.he.net anywhere /* allow IPv6 tunnel traffic from HE */ ACCEPT icmp — anywhere anywhere /* allow ICMP traffic to this host from anywhere */</p>
<p> Chain FORWARD (policy DROP) target prot opt source destination ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED /* allow inbound traffic for established and related connections */ ACCEPT all — anywhere anywhere /* allow all Internet bound traffic from the internal network */ ACCEPT icmp — anywhere anywhere /* forward any ICMP traffic */</p>
<p> Chain OUTPUT (policy ACCEPT) target prot opt source destination</p>
<p> Chain fail2ban-ssh (1 references) target prot opt source destination RETURN all — anywhere anywhere

为新的iptables规则添加注释

为新的iptables规则添加注释的语法为 : comment –comment “要添加的注释文字”具体的例子:下面添加一条允许ssh流量通过的规则,并且给这条规则添加注释:

复制代码

代码如下:

$ sudo iptables -A INPUT -p tcp -m tcp –dport 22 -m comment –comment \”allow SSH to this host from anywhere\” -j ACCEPT

然后用 -L 列出规则,就会看到刚才添加的规则和下面的一样:

复制代码

代码如下:

$ sudo iptables -L</p>
<p>ACCEPT tcp — anywhere anywhere tcp dpt:ssh /* allow SSH to this host from anywhere */

教程完!

1. 本站所提供的源码模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: rayer@88.com),我们会及时删除,给您带来的不便,我们深表歉意!
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者教程,可以到用户中心发布投稿,分享有金币奖励和额外收入!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务 请大家谅解!
5. 如有链接无法下载、失效或广告,请联系站长,可领回失去的金币,并额外有奖!
6. 如遇到加密压缩包,默认解压密码为"www.zyfx8.cn",如遇到无法解压的请联系管理员!
本站部分文章、资源来自互联网,版权归原作者及网站所有,如果侵犯了您的权利,请及时联系我站删除。免责声明
资源分享吧 » 在Linux系统中给iptables规则添加注释的教程

常见问题FAQ

免费下载或者VIP会员专享资源能否直接商用?
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
织梦模板使用说明
你下载的织梦模板并不包括DedeCMS使用授权,根据DedeCMS授权协议,除个人非盈利站点外,均需购买DedeCMS商业使用授权。购买地址: http://www.desdev.cn/service-dedecms.html

发表评论

Copyright 2015-2020 版权所有 资源分享吧 Rights Reserved. 蜀ICP备14022927号-1
开通VIP 享更多特权,建议使用QQ登录