1、防止别人ping echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all 2、恢复 echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all 我们使用函数实现如下: /* Author : kj Timer: 2014-08-14 Function : 0 ~ allow ping int area of Lan and Internet 1 ~ forbit ping int area of Lan and Internet */ int Joseph_Net_Icmp_Control(char *value) { int Qy_Ret = JOSEPH_RET_OK; int Joseph_Icmp_Value = 0; if(strlen(value) != 1) { Qy_Ret = JOSEPH_RET_ERR1; return Qy_Ret; } Joseph_Icmp_Value = atoi(value); switch(Joseph_Icmp_Value) { case 0: { system("echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all"); break; } case 1: { system("echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all"); break; } default: { Qy_Ret = JOSEPH_RET_ERR1; break; } } return Qy_Ret; } |
嵌入式 Linux下怎么设置禁止别人PING我的IP(ICMP报文)
最新推荐文章于 2022-08-07 10:12:36 发布