在Linux系統(tǒng)中給iptables規(guī)則添加注釋的教程
大步's blog 發(fā)布時(shí)間:2015-06-26 16:55:35 作者:佚名
我要評(píng)論

這篇文章主要介紹了在Linux系統(tǒng)中給iptables規(guī)則添加注釋的教程, iptables是Linux 內(nèi)核集成的IP信息包過濾系統(tǒng),需要的朋友可以參考下
給iptables規(guī)則添加注釋,以此給你的老板和同事一個(gè)好印象。方法如下:
什么是iptables的注釋呢?
iptables的注釋一般使用在每條規(guī)則的后面,注釋一般用 /* */ 包住。(具體的見下面的iptables規(guī)則中的注釋 /* allow SSH to this host from anywhere */ )
復(fù)制代碼
代碼如下:$ 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
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規(guī)則添加注釋
為新的iptables規(guī)則添加注釋的語(yǔ)法為 : comment --comment “要添加的注釋文字”
具體的例子:下面添加一條允許ssh流量通過的規(guī)則,并且給這條規(guī)則添加注釋:
復(fù)制代碼
代碼如下:$ sudo iptables -A INPUT -p tcp -m tcp --dport 22 -m comment --comment "allow SSH to this host from anywhere" -j ACCEPT
然后用 -L 列出規(guī)則,就會(huì)看到剛才添加的規(guī)則和下面的一樣:
復(fù)制代碼
代碼如下:$ sudo iptables -L</p>
<p>ACCEPT tcp -- anywhere anywhere tcp dpt:ssh /* allow SSH to this host from anywhere */
教程完!
相關(guān)文章
- 這篇文章主要介紹了Linux iptables的規(guī)則組成介紹,本文拆分了一條常規(guī)iptables命令,并分別介紹每個(gè)部份的作用,需要的朋友可以參考下2015-06-15
Linux iptables基礎(chǔ)知識(shí)和規(guī)則原理講解
這篇文章主要介紹了Linux iptables基礎(chǔ)知識(shí)和規(guī)則原理講解,本文講解了什么是iptables、什么是Netfilter、iptables規(guī)則原理等內(nèi)容,需要的朋友可以參考下2015-06-15linux下通過iptables只允許指定ip地址訪問指定端口的設(shè)置方法
這篇文章主要介紹了linux下通過iptables只允許指定ip地址訪問指定端口的設(shè)置方法,需要的朋友可以參考下2015-05-08