# chkconfig cups off # chkconfig avahi-daemon off # chkconfig avahi-dnsconfd off # chkconfig bluetooth off # chkconfig hidd off # chkconfig pcscd off # chkconfig smb off # chkconfig isdn off # chkconfig sendmail off # chkconfig ip6tables off # chkconfig smartd off
(Centos6の場合は、/etc/sysconfig/init)
# emacs /etc/inittab # Run gettys in standard runlevels 1:2345:respawn:/sbin/mingetty tty1 # 2:2345:respawn:/sbin/mingetty tty2 ←コメントアウト # 3:2345:respawn:/sbin/mingetty tty3 ←コメントアウト # 4:2345:respawn:/sbin/mingetty tty4 ←コメントアウト # 5:2345:respawn:/sbin/mingetty tty5 ←コメントアウト # 6:2345:respawn:/sbin/mingetty tty6 ←コメントアウト
Linuxではカーネルにおける各種設定ファイルとして、/etc/sysctl.conf ファイルが準備されている。これを活用したセキュリティ向上について解説する。
SYNクッキーとは、TCPプロトコルにおける3ウェイハンドシェイクの手続きの中でSYN,ACKフラグとセッションコードを、クッキーによってその有効性をチェックする機構である。
#emacs /etc/sysctl.conf net.ipv4.tcp_syncookies = 1
上の行を追加することで、次回起動時にSYNクッキーが自動起動される。 ちなみに現在の設定状況を確認するためには以下の通り。1なら設定済み。
# cat /proc/sys/net/ipv4/tcp_syncookies
ICMPではブロードキャストによる確認が行える、しかし転送元を偽装してブロードキャストを実行すると、同セグメントのマシンから一斉に返信が届き、サーバーの不可になる可能性がある。そのため、ICMPのブロードキャストだけをOFFにしておく機能である。
#emacs /etc/sysctl.conf net.ipv4.icmp_echo_ignore_broadcasts=1
ちなみに現在の設定状況を確認するためには以下の通り。1なら設定済み。
# cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
いろいろな国からの不法アクセスが多いわけだが、中国などは三国志や儒教の国とは思えないほど、モラルが低下しており、きわめて不法アクセスが多く無駄にlogファイルを増殖させている。よって、一部の国からのアクセスを禁止する方法を記載する。
最初にiptablesが稼動していることが条件となる。
# cd /usr/local # mkdir iptables # cd iptables # cp /etc/sysconfig/iptables <- 一応バックアップ
IPデータベースを落としてくる。(上から、ARIN,APNIC,RIPE,LACNIC,AfriNIC)
# wget ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest # wget ftp://ftp.apnic.net/pub/apnic/stats/apnic/delegated-apnic-latest # wget ftp://ftp.ripe.net/pub/stats/ripencc/delegated-ripencc-latest # wget ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest # wget ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
http://www2u.biglobe.ne.jp/~standard/code/country.htm