3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS6でZeroconfを使用しないように設定する

Last updated at Posted at 2013-11-26

CentOS6をインストールしてルーティングテーブルを表示するとこんなかんじに表示されると思います。

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.70.0    0.0.0.0         255.255.255.0   U     0      0        0 eth2
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.90.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1004   0        0 eth2
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

169.254.0.0/16のルーティングテーブルが勝手に追加されていますが、これはZeroconfによって自動的に作られたものです。
Zeroconfに関しては割愛します。

さて、サーバーとして使うのにZeroconfは通常不要と思いますので、これを無効にします。
/etc/sysconfig/network-scripts/ifcfg-ethXに次の行を追加するだけです。

NOZEROCONF=yes

明示的にNOZEROCONFの設定がされていない設定ファイルに対して、すべてNOZEROCONF=yesを有効にするbashスクリプトを書いてみました。シェバンを省いてコマンドラインにコピペしてもokです。

# !/bin/bash
for NIC in `ls -1 /etc/sysconfig/network-scripts/ifcfg-eth*`
do
  grep -q "^ *NOZEROCONF *= *.*" $NIC
  if [ $? -eq 1 ]; then
    echo "NOZEROCONF=yes" >> $NIC
  fi
done

追記: grep -q "^ *NOZEROCONF *= *.*" $NIC || echo "NOZEROCONF=yes" >> $NICとしようかとも思いましたが、どうやらファイルが見つからなかった等の理由で1以外が返ることもあるようですので、やめました。

追記: すべてのNICの設定に NOZEROCONF=yes しなくても /etc/sysconfig/network に書くだけで良いようです。つまり、上のようなスクリプトを書かなくても良いということです。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?