Ping大小限制 – FreeBSD

在FreeBSD ping的手册页中:

-s packetsize Specify the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. Only the super-user may specify val- ues more than default. This option cannot be used with ping sweeps. 

有谁知道我怎么能让非超级用户发送大于56的乒乓? 我可以增加默认大小,或者以某种方式允许-s被非root用户使用吗? 我意识到安全隐患,这可能允许用户启动一个ping泛滥,所以如果我可以限制这只允许一个(无壳)的用户,一切都好。

考虑使用sudo,EX:

 coryj ALL = NOPASSWD: /bin/ping 

这应该让用户coryj运行/bin/ping警告:使用任何他喜欢的参数,而不仅仅是-s )而不需要密码。

注意这个的安全含义; 请参阅sudo(8)sudoers(5)手册页。

您可以修改源代码并更改行为。 在/usr/src/sbin/ping/下的ping.c的第98行可以使默认的大小更大。 或者,您可以通过将行replace为if (0) {来禁用第446行中的此function。 更改后,运行make install

我不得不想知道为什么你需要一个普通用户发送一个大的ICMP消息。