|
|
想编个程序来直接添加一个iptables规则,但是怎么会这样呢?
[root@anuode anuode]# cat login.c
#include <unistd.h>
int main(int argc,char *argv[])
{
char *arg[8]={"iptables","-A","FORWARD","-s",argv[1],"-j","ACCEPT",(char *)0};
execve("/sbin/iptables",arg,(char **)0);
arg[3]="-d";
execve("/sbin/iptables",arg,(char **)0);
return(0);
}
[root@anuode anuode]# ./login 10.10.10.1
[root@anuode anuode]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 10.10.10.1 anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination |
|