#include <stdio.h>
#include <stdlib.h> //必要的头文件
#include<string.h>
#include<unistd.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
int main(){
int len=0;
char *poststr; char text[100]={'\0'};
char ip[20],gw[20];
char cmd[100];
char abc[100];
struct in_addr s;
int AF_INT;
printf("Content-Type:text/plain\n\n");
if(getenv("CONTENT-LENGTH"))
len=atoi(("CONTENT-LENGTH"));
poststr=getenv("QUERY_STRING");
len = sprin

这是一个C语言编写的CGI程序,用于在Linux系统中动态修改以太网接口eth0的IP地址和网关。程序首先获取环境变量QUERY_STRING中的IP和网关信息,然后通过inet_pton和inet_ntop函数进行IP地址的解析与转换,最后调用system函数执行ifconfig命令来更新IP配置。
最低0.47元/天 解锁文章
1389

被折叠的 条评论
为什么被折叠?



