新たに建てたname serverのアドレスを配布すべく、DHCP serverを用意します。Home GWや無線APもDHCP serverの機能を持っているのですが、今後いろんな細工をするのに自由度の高いものを用意しておく方が便利だろうと思い、自前サーバーを用意します。
apt-get install udhcpd でbusybox DHCP serverを入れると/etc/udhcpd.confが配置されるので、このファイルを環境に合わせて変更します。
# Sample udhcpd configuration file (/etc/udhcpd.conf) # The start and end of the IP lease block # start 192.168.0.20 #default: 192.168.0.20 # end 192.168.0.254 #default: 192.168.0.254 start 192.168.1.192 #default: 192.168.0.20 ←IPアドレス配布範囲を設定 end 192.168.1.253 #default: 192.168.0.254 ここでは192.168.1.192-253の範囲 # The interface that udhcpd will use interface eth0 #default: eth0 【以下しばらく変更なし】 # The remainer of options are DHCP options and can be specifed with the # keyword 'opt' or 'option'. If an option can take multiple items, such # as the dns option, they can be listed on the same line, or multiple # lines. The only option with a default is 'lease'. #Examles # opt dns 192.168.10.2 192.168.10.10 # option subnet 255.255.255.0 # opt router 192.168.10.2 # opt wins 192.168.10.10 # option dns 129.219.13.81 # appened to above DNS servers for a total of 3 # option domain local # option lease 864000 # 10 days of seconds opt dns 192.168.1.8 ←この辺りを環境に合わせて変更 option subnet 255.255.255.0 opt router 192.168.1.1 option domain ws9.org option lease 864000 # 10 days of seconds 【以下変更なし】
この状態で
pi@raspie ! /etc/init.d/udhcpd start pi@raspie ! update-rc.d udhcpd enable
すると、クライアントにIPアドレスが振られ、デフォルトGWは192.168.1.1、name serverは192.168.1.8だと認識されるようになります。
ちなみに、このDHCP serverはIPアドレスがランダムに払い出されます。