QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 792|回复: 7

怪事-RH9启动时 rc.local 无法运行脚本

[复制链接]
发表于 2003-5-13 12:13:10 | 显示全部楼层 |阅读模式
怪事-RH9启动时 rc.local 中 IPTABLES 的命令(附后面)
不能运行,提示:
------------------------------------------------
[root@redhat9 root]# cd /etc/rc.d
[root@redhat9 rc.d]# ./rc.local
: command not found:
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
: command not found:
'ptables v1.2.7a: Invalid target name `MASQUERADE
Try `iptables -h' or 'iptables --help' for more information.
: command not found:
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found:
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found:
: 娌℃湁閭d釜鏂囦欢鎴栫洰褰?/proc/sys/net/ipv4/ip_forward
[root@redhat9 rc.d]# iptables -F
[root@redhat9 rc.d]# iptables -t nat -F
[root@redhat9 rc.d]#
------------------------------------------------


IPTABLES 的命令如下:
------------------------------------------------
# Then flush all rules
iptables -F
iptables -t nat -F

# Below means 'route 192.168.1.x'
iptables -t nat -A POSTROUTING -d ! 192.168.1.0/24 -j MASQUERADE

iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -s ! 192.168.1.0/24 -j DROP

# port 113 is evil ;)
iptables -A INPUT --protocol udp --source-port 113 -j DROP
iptables -A INPUT --protocol udp --destination-port 113 -j DROP

# Turn on IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
------------------------------------------------

受-微-软-压迫中

HELP!

先谢了!
 楼主| 发表于 2003-5-13 12:55:00 | 显示全部楼层


help !!!

回复

使用道具 举报

 楼主| 发表于 2003-5-14 10:07:56 | 显示全部楼层
怪!!!
回复

使用道具 举报

 楼主| 发表于 2003-5-14 10:08:23 | 显示全部楼层
我用的是双网卡
回复

使用道具 举报

发表于 2003-5-14 13:00:43 | 显示全部楼层
没什么好怪的,rc.local内容写错了
回复

使用道具 举报

 楼主| 发表于 2003-5-14 14:42:46 | 显示全部楼层
命令行上一步步执行时没问题
放到脚本 firewall 中:
--------------------------------------------------------
#! /bin/bash
# Load required modules
#insmod ip_tables
#insmod ip_conntrack
#insmod iptable_nat
#insmod ipt_MASQUERADE

modprobe iptable_nat
modprobe ip_table
modprobe ip_nat_table
modprobe ip_conntrack
modprobe ip_conntrack_ftp


# Then flush all rules
/sbin/iptables -F
/sbin/iptables -t nat -F

# Below means 'route 192.168.1.x'
/sbin/iptables -t nat -A POSTROUTING -d ! 192.168.1.0/24 -j MASQUERADE

/sbin/iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -d 192.168.1.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -s ! 192.168.1.0/24 -j DROP

# port 113 is evil  
/sbin/iptables -A INPUT --protocol udp --source-port 113 -j DROP
/sbin/iptables -A INPUT --protocol udp --destination-port 113 -j DROP

# Turn on IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
--------------------------------------------------------

单独执行这个脚本的情况如下:
--------------------------------------------------------
[root@redhat9 rc.d]# ./firewall
: bad interpreter: 娌℃湁閭d釜鏂囦欢鎴栫洰褰?[root@redhat9 rc.d]# firewall
bash: firewall: command not found
[root@redhat9 rc.d]# bash firewall
modprobe: Can't locate module
modprobe: Can't locate module
: command not found
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
: command not found
'ptables v1.2.7a: Invalid target name `MASQUERADE
Try `iptables -h' or 'iptables --help' for more information.
: command not found
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found
: 娌℃湁閭d釜鏂囦欢鎴栫洰褰昿roc/sys/net/ipv4/ip_forward
[root@redhat9 rc.d]#
--------------------------------------------------------
我们原来用 I S A 作防火墙, (全-部-盗-板)
现被-微-软-查到,只好买了正版瘟酒吧,防火墙改用REDHAT9
我们用的是ADSL专线,有固定IP

先谢了!
回复

使用道具 举报

发表于 2003-5-14 15:28:59 | 显示全部楼层
#! /bin/bash
# Load required modules
#insmod ip_tables
#insmod ip_conntrack
#insmod iptable_nat
#insmod ipt_MASQUERADE


modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp


# Then flush all rules
/sbin/iptables -F
/sbin/iptables -t nat -F

# Below means 'route 192.168.1.x'
/sbin/iptables -t nat -A POSTROUTING -d ! 192.168.1.0/24 -j MASQUERADE

/sbin/iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -d 192.168.1.0/24 -j ACCEPT
/sbin/iptables -A FORWARD -s ! 192.168.1.0/24 -j DROP

# port 113 is evil
/sbin/iptables -A INPUT --protocol udp --source-port 113 -j DROP
/sbin/iptables -A INPUT --protocol udp --destination-port 113 -j DROP

# Turn on IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward



保存为firewall,加上可执行属性
回复

使用道具 举报

 楼主| 发表于 2003-5-14 16:46:24 | 显示全部楼层
保存为firewall,加上可执行属性后
还是一样
输出贴出如下:
_________________

[root@redhat9 root]# cd /etc/rc.d
[root@redhat9 rc.d]# ./firewall
iptables: No chain/target/match by that name
iptables: No chain/target/match by that name
: command not found
'ptables v1.2.7a: Invalid target name `MASQUERADE
Try `iptables -h' or 'iptables --help' for more information.
: command not found
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found:
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.2.7a: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
: command not found:
: 没有那个文件或目录?/proc/sys/net/ipv4/ip_forward
[root@redhat9 rc.d]#
回复

使用道具 举报

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

本版积分规则

GMT+8, 2024-10-2 12:27 , Processed in 0.061196 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

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