+ -
当前位置:首页 → 问答吧 → 关于uClinux boa 下使用 system()调用iptables 的问题

关于uClinux boa 下使用 system()调用iptables 的问题

时间:2010-05-17

来源:互联网

您好!
我写了这么一个程序:
#include<stdio.h>
int main()
{
        system("/iptables -P FORWARD DROP");
        printf("internet off.\n");
        return 0;
}
用gcc编译后,在我的RADHAT 9.0 上顺利跑起来了。即防火墙配置了, internet off也输出了。
然而
我用arm-elf-gcc编译后,在我的uClinux下跑的时候,只有防火墙配置了,internet off却没有被输出来!!!
这我就奇怪了。程序好像跑到system后就直接退出了,忽略了后面的语句。 有大侠知道解决办法吗?谢谢。
我在网上搜了一下,在uClinux下会找不到命令这一说法,要加上完整路径,我加了的。下面是我在uClinux下跑的程序。
(我的boa.conf 里面的 user group 都是 0 )
#include<stdio.h>
int main()
{
        system("/bin/iptables -P FORWARD DROP");
        printf("internet off.\n");
        return 0;
}


下面是我在系统上电后的一些操作信息:
/> cd home

/home> ls                                                                    /*程序放在 /home/目录下*/
internet_off.flt web             internet_on.flt httpd        
      
/home> iptables -L                                                    /*原始的iptables 表*/      
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

/home> ./internet_off.flt                                         /*运行程序*/

/home> iptables -L                                                  /*再看iptables 表*/
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy DROP)                             /* 变成了DROP 说明system是正确运行了。*/
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
/home>

作者: wz1988001   发布时间: 2010-05-17

求救啊。。。。

作者: wz1988001   发布时间: 2010-05-17

热门下载

更多