LINUX DHCP搭建
生活随笔
收集整理的這篇文章主要介紹了
LINUX DHCP搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
-------陳功磊 2009-5-31<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> (說明:系統鏡像:[紅帽企業.Linux.5].rhel-5.2-server-i386-dvd.iso) 1、掛載鏡像 [root@linux01 ~]# ls -al /media total 16 drwxr-xr-x 2 root root 4096 Oct 11 2006 . drwxr-xr-x 24 root root 4096 May 31 19:57 .. [root@linux01 ~]# mkdir /media/cdrom [root@linux01 ~]# ls -al /media total 24 drwxr-xr-x 3 root root 4096 May 31 20:11 . drwxr-xr-x 24 root root 4096 May 31 19:57 .. drwxr-xr-x 2 root root 4096 May 31 20:11 cdrom [root@linux01 ~]# mount -t iso9660 /dev/cdrom /media/cdrom # 掛載鏡像 mount: block device /dev/cdrom is write-protected, mounting read-only [root@linux01 ~]# 2、安裝DHCP軟件包 [root@linux01 ~]# cd /media/cdrom/Server # 進入rmp軟件包文件夾 [root@linux01 Server]# ls -l dhcp* -rw-r--r-- 243 root root 895219 Apr 16 2008 dhcp-3.0.5-13.el5.i386.rpm -rw-r--r-- 263 root root 133868 Apr 16 2008 dhcp-devel-3.0.5-13.el5.i386.rpm -rw-r--r-- 91 root root 194686 Apr 26 2008 dhcpv6-1.0.10-4.el5.i386.rpm -rw-r--r-- 91 root root 122618 Apr 26 2008 dhcpv6-client-1.0.10-4.el5.i386.rpm [root@linux01 Server]# rpm -ivh dhcp-3.0.5-13.el5.i386.rpm # i安裝 v 詳細輸出 h進度 warning: dhcp-3.0.5-13.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:dhcp ########################################### [100%] [root@linux01 Server]# [root@linux01 Server]# rpm -qa | grep dhcp # 查看與dhcp相關的安裝軟件 dhcpv6-client-1.0.10-4.el5 dhcp-3.0.5-13.el5 [root@linux01 Server]# 3、配置/etc/dhcpd.conf文件 [root@linux01 ~]# vi /etc/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # ddns-update-style interim; # dhcpd啟動的必須項 default-lease-time 21600; # 默認租約時間(sec)(6小時) max-lease-time 43200; # 最大租約時間(sec)(12小時) option domain-name "benet.com.cn"; # 主機所在域名,可選項 option domain-name-servers 222.172.200.68,202.203.144.33; # DNS域名服務器的ip,可選項 subnet 192.168.7.0 netmask 255.255.255.0 { range 192.168.7.50 192.168.7.250; option subnet-mask 255.255.255.0; option broadcast-address 192.168.7.255; option routers 192.168.7.1; host linux01{????? # 靜態ip hardware ethernet 00:0C:29:BE:87:75; fixed-address 192.168.7.2; } } ~ ~ "/etc/dhcpd.conf" 15L, 383C written [root@linux01 ~]# service dhcpd restart Shutting down dhcpd: [ OK ] Starting dhcpd: [ OK ] [root@linux01 ~]# 4、查看DHCP本機網絡情況 [root@linux01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 # 網卡信息 # Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.7.255 HWADDR=00:0C:29:BE:87:75 IPADDR=192.168.7.2 NETMASK=255.255.255.0 NETWORK=192.168.7.0 ONBOOT=yes ~ ~ [root@linux01 ~]# [root@linux01 network-scripts]# vi /etc/sysconfig/network # 主機名和網關信息 NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=linux01 GATEWAY=192.168.7.1~ ~ [root@linux01 ~]# [root@linux01 etc]# cat hosts # 本機信息 # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 linux01 localhost.localdomain localhost # 主機名主機名.域名主機別名 ::1 localhost6.localdomain6 localhost6 [root@linux01 etc]# [root@linux01 etc]# cat hosts # 域名解析服務信息 # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 linux01 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 [root@linux01 etc]# 說明:在linux安裝時有配置好以上項目時,在下面路徑下也有這些信息及配置 [root@linux02 ~]# cd /etc/sysconfig/networking/profiles/default [root@linux02 default]# ls hosts ifcfg-eth0 network resolv.conf [root@linux02 default]# 5、客戶端獲取ip Linux客戶端 [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # 客戶端網絡配置 # Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth0 BOOTPROTO=dhcp # 使用dhcp自動獲取 HWADDR=00:0C:29:CD:40:C8 ONBOOT=yes TYPE=Ethernet USERCTL=no IPV6INIT=no PEERDNS=yes [root@localhost ~]# [root@linux01 ~]# /etc/init.d/network restart # 重啟網絡 客戶端Xp系統ip地址自動獲取驗證 <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /> 6、DHCP相關命令 [root@linux01 ~]# rpm -qa dhcpd # 查詢當前系統安裝的dhcp包 [root@linux01 ~]# rpm -qa dhcp* dhcpv6-client-1.0.10-4.el5 dhcp-3.0.5-13.el5 [root@linux01 ~]# [root@linux01 ~]# service dhcpd status # 查看當前dhcp服務狀態 dhcpd (pid 12946) is running... [root@linux01 ~]# [root@linux01 ~]# service dhcpd start/stop/restart # 開啟/停止/重啟dhcp服務 [root@linux01 ~]# chkconfig --list | grep dhcpd # 查看dhcpd的服務在不同模式下的狀態 dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@linux01 ~]# chkconfig --level 35 dhcpd on # 配置dhcpd服務在35系統模式下為自動隨機開啟 [root@linux01 ~]# 本文出自 “Gonglei Chen” 博客,轉載請與作者聯系!
?
轉載于:https://blog.51cto.com/sunxuewei/279251
總結
以上是生活随笔為你收集整理的LINUX DHCP搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#正则表达式整理备忘
- 下一篇: 新装WINDOWS XP系统 必须安装的