複製 sample檔
cp /usr/share/doc/dhcp-3.0.2/dhcpd.conf.sample /etc/dhcpd.conf
vi /etc/dhcpd.conf

ddns-update-style interim;
ignore client-updates;

# 動態IP配置設定
subnet 192.168.1.0 netmask 255.255.255.0 {

           default-lease-time 21600;       # 租約時間,秒
           max-lease-time 43200;

# — default gateway
           option routers                              192.168.1.1;           # gateway

#         option nis-domain                       "domain.org";
           option domain-name                   "ssorc.tw";
           option domain-name-servers       168.95.1.1, 168.95.192.1;    # DNS伺服器,','號分隔

           option time-offset                         28800;           # 本地時間與格林威治時間差(+8)
#         option ntp-servers                        192.168.1.1;
#         option netbios-name-servers        192.168.1.1;
# — Selects point-to-point node (default is hybrid). Don't change this unless
# — you understand Netbios very well
#         option netbios-node-type 2;

           range dynamic-bootp 192.168.1.21 192.168.1.31;
           option subnet-mask 255.255.255.0;
           option broadcast-address 192.168.1.255;

# 靜態IP配置設定
           # we want the nameserver to appear at a fixed address
           host cross {
#                    next-server marvin.redhat.com;
                      hardware ethernet 12:34:56:78:AB:CD;
                      fixed-address 192.168.1.11;
           }
}

從那一張網卡發配
vi /etc/sysconfig/dhcpd

DHCPDARGS="eth2"

   /etc/rc.d/init.d/dhcpd start
 
檢驗 ps axu | grep dhcp

root 25760 0.0 0.6 2880 1508 ? S 11:33 0:00 /usr/sbin/dhcpd eth2

確認正確的啟動 DHCP,觀察啟動的 port 號與登錄檔的訊息
more /var/log/messages

Nov 23 23:35:09 dhcpd: Wrote 0 deleted host decls to leases file.
Nov 23 23:35:09 dhcpd: Wrote 0 new dynamic host decls to leases file.
Nov 23 23:35:09 dhcpd: Wrote 0 leases to leases file.
Nov 23 23:35:09 dhcpd: dhcpd startup succeeded

看到 Wrote xxxx to leases file 以及 succeeded 的字眼,確定啟動成功

netstat -utl

Active Internet connections (only servers)
Proto Recv-Q Send-Q  Local Address  Foreign Address State
udp         0            0        *:bootps              *:*

Active Internet connections (only servers)
Proto Recv-Q Send-Q   Local Address  Foreign Address State
udp      0            0         0.0.0.0:67              0.0.0.0:*

[Q1.] 安裝好Linux DHCP Server後,網路上的其他主機還是沒辦法取得ip設定?
[A1.] 可能是linux server沒有辦法接收來自255.255.255.255 的DHCP client Request 封包,可以將255.255.255.255設進DHCP Server的routing table中
route add -host 255.255.255.255 dev eth2

Related posts 相關文章

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。