1.手動設(shè)置工作量大且容易沖突
2.用DHCP可以減少工作量和避免地址沖突
1.為相同網(wǎng)段的電腦分配IP地址—DHCP
2.跨網(wǎng)段為另一網(wǎng)段的電腦分配IP地址—DHCP中繼
1.減少管理員的工作量
2.避免輸入錯誤的可能
3.避免IP地址沖突
4.當(dāng)更改IP地址段時,不需要重新配置每個用戶的IP地址
5.提高了IP地址的利用率
6.方便客戶端的配置
以找工作為例:
DHCP Discover——客戶端用來尋找DHCP服務(wù)器的報(bào)文
我向公司投簡歷來找工作
DHCP Offer——DHCP服務(wù)器用來響應(yīng)DHCP Discover報(bào)文的報(bào)文。該報(bào)文攜帶了各種配置信息,例如IP地址,DNS等
公司收到我的求職簡歷后給我發(fā)了一份offer
DHCP Request——客戶端請求配置確認(rèn),或者續(xù)借租期
我收到offer之后跟公司確認(rèn)
DHCP ACK——服務(wù)器對Request報(bào)文的確認(rèn)響應(yīng)
公司說我ok沒問題,可以過來上班 ,我找到工作了
①自動分配:
當(dāng)DHCP客戶機(jī)第一次成功地從DHCP服務(wù)器獲取到一個IP地址后,就永久的使用這個IP地址
②手動分配:
由DHCP服務(wù)器管理員專門指定IP地址
③動態(tài)分配:
當(dāng)DHCP客戶機(jī)第一次從DHCP服務(wù)器獲得IP地址后,并非永久的使用該地址,而是在每次使用完后,DHCP客戶機(jī)就會釋放這個IP地址,供其他客戶機(jī)使用
主配置文件:/etc/dhcpd.conf
執(zhí)行程序:/usr/sbin/dhcpd、usr/sbin/dhcrelay
ddns-update-style interim; #全局配置參數(shù) ...... subnet 192.168.0.0 netmask 255.255.255.0 { #subnet以上的都是全局配置參數(shù);網(wǎng)段聲明(網(wǎng)段、子網(wǎng)掩碼、默認(rèn)網(wǎng)關(guān)地址) option routers 192.168.0.1; #配置選項(xiàng) ...... default-lease-time 21600; #配置參數(shù) host ns { ...... fixed-address 207.175.42.254; #主機(jī)聲明(固定一個IP給主機(jī)用的) } }
range參數(shù):設(shè)置用于分配的IP地址池
option subnet-mask參數(shù):設(shè)置客戶機(jī)的子網(wǎng)掩碼
option routers參數(shù):設(shè)置客戶機(jī)的默認(rèn)網(wǎng)關(guān)地址
實(shí)驗(yàn)拓?fù)鋱D如下
注:配置完“Cloud”之后才能用串口線連接
<Huawei>undo terminal monitor <Huawei>system-view [L2-SW1]user-interface console 0 [L2-SW1-ui-console0]idle-timeout 0 0 [L2-SW1-ui-console0]quit [L2-SW1]vlan batch 10 20 100 [L2-SW1]interface Ethernet 0/0/1 [L2-SW1-Ethernet0/0/1]port link-type access [L2-SW1-Ethernet0/0/1]port default vlan 10 [L2-SW1-Ethernet0/0/1]quit [L2-SW1]interface Ethernet 0/0/2 [L2-SW1-Ethernet0/0/2]port link-type access [L2-SW1-Ethernet0/0/2]port default vlan 20 [L2-SW1-Ethernet0/0/2]quit [L2-SW1]interface Ethernet 0/0/3 [L2-SW1-Ethernet0/0/3]port link-type access [L2-SW1-Ethernet0/0/3]port default vlan 100 [L2-SW1-Ethernet0/0/3]quit [L2-SW1]interface Ethernet 0/0/4 [L2-SW1-Ethernet0/0/4]port link-type access [L2-SW1-Ethernet0/0/4]port default vlan 100 [L2-SW1-Ethernet0/0/4]quit [L2-SW1]interface GigabitEthernet0/0/1 [L2-SW1-GigabitEthernet0/0/1]port link-type trunk [L2-SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 100 [L2-SW1-GigabitEthernet0/0/1]quit
<Huawei>undo terminal monitor <Huawei>system-view [Huawei]sysname L3-SW2 [L3-SW2]user-interface console 0 [L3-SW2-ui-console0]idle-timeout 0 0 [L3-SW2-ui-console0]quit [L3-SW2]vlan batch 10 20 100 [L3-SW2]interface GigabitEthernet0/0/1 [L3-SW2-GigabitEthernet0/0/1]port link-type trunk [L3-SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 100 [L3-SW2-GigabitEthernet0/0/1]quit [L3-SW2]interface Vlanif 10 [L3-SW2-Vlanif10]ip address 192.168.10.1 255.255.255.0 [SW2-Vlanif20]un sh [L3-SW2]interface Vlanif 20 [L3-SW2-Vlanif20]ip address 192.168.20.1 255.255.255.0 [SW2-Vlanif20]un sh [L3-SW2]interface Vlanif 100 [L3-SW2-Vlanif100]ip address 192.168.100.1 255.255.255.0 [SW2-Vlanif20]un sh [SW2-Vlanif100]int g0/0/1 [SW2-GigabitEthernet0/0/1]port link-type trunk [SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[L3-SW2]dhcp enable ##開啟DHCP功能 [L3-SW2]interface Vlanif 10 ##配置虛接口ip,選擇dhcp中繼模式,請求指向dhcp服務(wù)器ip [L3-SW2-Vlanif10]dhcp select relay [L3-SW2-Vlanif10]dhcp relay server-ip 192.168.100.100 [L3-SW2-Vlanif10]quit [L3-SW2]interface Vlanif 20 [L3-SW2-Vlanif20]dhcp select relay [L3-SW2-Vlanif20]dhcp relay server-ip 192.168.100.100 [L3-SW2-Vlanif20]quit [L3-SW2]interface Vlanif 100 [L3-SW2-Vlanif100]dhcp select relay [L3-SW2-Vlanif100]dhcp relay server-ip 192.168.100.100 [L3-SW2-Vlanif100]quit
[root@xjj ~]# yum -y install dhcp 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 軟件包 12:dhcp-4.2.5-58.el7.centos.x86_64 已安裝并且是最新版本 無須任何處理 [root@xjj ~]# cd /etc/dhcp/ ##dhcp的配置文件是/etc/dhcp/dhcpd.conf [root@xjj dhcp]# ls dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts [root@xjj dhcp]# less dhcpd.conf ##查看一下內(nèi)容 [root@xjj ~]# cd /usr/share/doc/dhcp-4.2.5/ 到該目錄下去尋找dhcp配置模板 [root@xjj dhcp-4.2.5]# ls ##“dhcpd.conf.example” dhcpd6.conf.example dhcpd.conf.example ldap [root@xjj dhcp-4.2.5]# cp dhcpd.conf.example /etc/dhcp/dhcpd.conf ##將模板覆蓋到/etc/dhcp/dhcpd.conf中 cp:是否覆蓋"/etc/dhcp/dhcpd.conf"? y [root@xjj ~]# cd /etc/dhcp/ ##回到/etc/dhcp目錄下 [root@xjj dhcp]# ls dhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts [root@xjj dhcp]# less dhcpd.conf ##查看配置文件并進(jìn)行下一步編輯
編輯dhcp配置文件
[root@xjj dhcp]# systemctl stop firewalld se[root@jj dhcp]# setenforce 0 ##記得重啟一下網(wǎng)卡! [root@xjj dhcp]# systemctl restart dhcpd [root@xjj dhcp]# ping 192.168.100.1 ...略 [root@xjj dhcp]# ping 192.168.10.1 ...略 [root@xjj dhcp]# ping 192.168.20.1 ...略
pc1和pc2成功?。?!
以上就是超詳細(xì)講解Linux DHCP服務(wù)的詳細(xì)內(nèi)容,更多關(guān)于Linux DHCP服務(wù)的資料請關(guān)注腳本之家其它相關(guān)文章!
標(biāo)簽:朝陽 蕪湖 松原 周口 銅川 泰州 慶陽 那曲
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《超詳細(xì)講解Linux DHCP服務(wù)》,本文關(guān)鍵詞 超,詳細(xì),講解,Linux,DHCP,服務(wù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。