SyntaxHighlighter

2012年12月4日火曜日

[Gentoo Linux] DHCPサーバについてのメモ

最近はネットワークの勉強を兼ねてDNSとDHCPサーバを構築しました。
しかし、DHCPがどうも調子がおかしかったので調べていたら解決したので
その時のメモ

カーネルを更新して再起動するとdhcpdの起動に失敗するようになる。
以下のようなログが残ってた


Dec  3 23:54:57 gentooserver dhcpd: Internet Systems Consortium DHCP Server 4.2.4-P2 Gentoo-r0
Dec  3 23:54:57 gentooserver dhcpd: Copyright 2004-2012 Internet Systems Consortium.
Dec  3 23:54:57 gentooserver dhcpd: All rights reserved.
Dec  3 23:54:58 gentooserver dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Dec  3 23:54:58 gentooserver dhcpd: Wrote 0 deleted host decls to leases file.
Dec  3 23:54:58 gentooserver dhcpd: Wrote 0 new dynamic host decls to leases file.
Dec  3 23:54:58 gentooserver dhcpd: Wrote 5 leases to leases file.
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd: No subnet declaration for start (no IPv4 addresses).
Dec  3 23:54:58 gentooserver dhcpd: ** Ignoring requests on start.  If this is not what
Dec  3 23:54:58 gentooserver dhcpd:    you want, please write a subnet declaration
Dec  3 23:54:58 gentooserver dhcpd:    in your dhcpd.conf file for the network segment
Dec  3 23:54:58 gentooserver dhcpd:    to which interface start is attached. **
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd: Not configured to listen on any interfaces!
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd: This version of ISC DHCP is based on the release available
Dec  3 23:54:58 gentooserver dhcpd: on ftp.isc.org.  Features have been added and other changes
Dec  3 23:54:58 gentooserver dhcpd: have been made to the base software release in order to make
Dec  3 23:54:58 gentooserver dhcpd: it work better with this distribution.
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd: Please report for this software via the Gentoo Bugzilla site:
Dec  3 23:54:58 gentooserver dhcpd:     http://bugs.gentoo.org/
Dec  3 23:54:58 gentooserver dhcpd:
Dec  3 23:54:58 gentooserver dhcpd: exiting.



結局何が原因だったのかというと、NICのIPアドレスを固定していなかったのが原因だった。
NICに割り振られているIPアドレスと、dhcpd.confに設定してある内容が食い違っていた。



(そういえばルータからIP取得するようにしていたんだけど今ルータのDHCP切っているんだった...)
(ルータの方のDHCPは切っていたら当然外から取ってくるわけで192.168.xxx.xxxとはなるはずないよね...)

ネットワーク機器にはAPIPAという機能があるらしい

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 169.254.40.106  netmask 255.255.0.0  broadcast 169.254.255.255 



eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 169.254.229.118  netmask 255.255.0.0  broadcast 169.254.255.255


てなってた




IPアドレスを固定するために
/etc/conf.d/net
config_eth0="192.168.0.3"
config_eth1="192.168.0.4"
と記入



あと、
# cd /etc/init.d
# ln -s net.lo net.eth0
# ln -s net.lo net.eth1
# rc-update add net.eth0 default
# rc-update add net.eth1 default
/etc/init.d/net.eth0 stop
/etc/init.d/net.eth0 start
/etc/init.d/net.eth1 stop
/etc/init.d/net.eth1 start

も(何故かしてなかったので)しておく。



あとは満を持して
# /etc/init.d/dhcpd start

として終わり


あとはnamedが

# /etc/init.d/named restart


てしないとポートをlistenしないのが何なのかわかれば終わりかなー