LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 986|回复: 9

小白问题,关于FOR的,试了好多次都是失败~~请指教

[复制链接]
发表于 2005-9-18 19:40:52 | 显示全部楼层 |阅读模式
for ok in 53 80 10000 21 22;
do

iptables -A IPNUT -p tcp --dport $ok -j ACCEPT

done

失败~~~请指教一二~~~
发表于 2005-9-18 19:57:08 | 显示全部楼层
Post by jd_chen
for ok in 53 80 10000 21 22;
do

iptables -A IPNUT -p tcp --dport $ok -j ACCEPT

done

失败~~~请指教一二~~~


iptables -A INPUT -p tcp -m multiport --dport 53,80,10000,21,22 -j ACCEPT

或者
for port in 53 80 10000 21 22
do
    iptables -A INPUT -p tcp --dport $port -j ACCEPT
done
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-18 20:12:22 | 显示全部楼层
Post by Freebird
for port in 53 80 10000 21 22
do
    iptables -A IPNUT -p tcp --dport $port -j ACCEPT
done

跟我那个,有什么不同呢????。。小弟看不出来~~~
回复 支持 反对

使用道具 举报

发表于 2005-9-18 20:21:52 | 显示全部楼层
Post by jd_chen
跟我那个,有什么不同呢????。。小弟看不出来~~~

你眼睛不好使、再看一次,你多了一个;
不过,申明的是,;本来不会影响到效果。也许是你没有指定好iptables命令的路径。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-18 20:22:13 | 显示全部楼层
哦,,,这个;是什么意思呀,说明一下,  让大家 学习学习嘛 ~~~
回复 支持 反对

使用道具 举报

发表于 2005-9-18 20:27:31 | 显示全部楼层
试试
for x in  53 80 10000 21 22;do /sbin/iptables -A INPUT -p tcp --dport $x -j ACCEPT;done
因为很有可能是你的iptables路径没指定好。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-18 20:30:15 | 显示全部楼层
不是,,我运行我自己的脚本,是IPTABLES报错,

iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
回复 支持 反对

使用道具 举报

发表于 2005-9-18 20:36:39 | 显示全部楼层
Post by jd_chen
不是,,我运行我自己的脚本,是IPTABLES报错,

iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name


你TM早说。既然知道脚本没问题。还发到Shell区? :beat 很明显你的命令写错了!
iptables -A IPNUT -p tcp --dport $ok -j ACCEPT

IPNUT 这个链嘛??
回复 支持 反对

使用道具 举报

发表于 2005-9-18 20:37:23 | 显示全部楼层
再看一遍我写的。。真眼拙。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-18 20:55:02 | 显示全部楼层
.....汗。。。知道了~
我当初以为是iptables -A INPUT -p tcp --dport "这里当成中文的80" -j ACCEPT~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表