ブロードキャストなICMP Echo Requestを無視する
OSはUbuntu 14.04。
結論から書くと、
echo "net.ipv4.icmp_echo_ignore_broadcasts=1" > /etc/sysctl.d/60-icmp-echo.conf service procps start
でOK(のはず)。
設定前
$ ping 192.168.33.255 PING 192.168.33.255 (192.168.33.255): 56 data bytes 64 bytes from 192.168.33.1: icmp_seq=0 ttl=64 time=0.081 ms 64 bytes from 192.168.33.20: icmp_seq=0 ttl=64 time=0.395 ms 64 bytes from 192.168.33.1: icmp_seq=1 ttl=64 time=0.125 ms 64 bytes from 192.168.33.20: icmp_seq=1 ttl=64 time=0.665 ms
設定後
$ ping 192.168.33.255 PING 192.168.33.255 (192.168.33.255): 56 data bytes 64 bytes from 192.168.33.1: icmp_seq=0 ttl=64 time=0.081 ms 64 bytes from 192.168.33.1: icmp_seq=1 ttl=64 time=0.134 ms
以下、調べたことをメモしておく。
/etc/init/procps.conf
$ cat /etc/init/procps.conf # procps - set sysctls from /etc/sysctl.conf # # This task sets kernel sysctl variables from /etc/sysctl.conf and # /etc/sysctl.d snip... task script cat /etc/sysctl.d/*.conf /etc/sysctl.conf | sysctl -e -p - end script
このタスクにより、起動時に/etc/sysctl.d/ と /etc/sysctl.conf が適用される。
デーモン化するわけじゃないことに注意。単に task として sysctl コマンドにパイプしてるつくりなので。
/etc/sysctl.d/
README曰く..
This directory contains settings similar to those found in /etc/sysctl.conf. In general, files in the 10-*.conf range come from the procps package and serve as system defaults. Other packages install their files in the 30-*.conf range, to override system defaults. End-users can use 60-*.conf and above, or use /etc/sysctl.conf directly, which overrides anything in this directory.
なので、今回の設定は /etc/sysctl.d/60-icmp-echo.conf にしておいた。