1、如何實現一台伺服器為兩個不同網段提供DHCP服務
DHCP多作用域設置
DHCP伺服器使用單一的作用域,大部分時間能夠滿足網路的需求,但是有些特殊情況下,按照網路規劃我們需要配置多作用域。
網路中如果計算機和其他設備數量增加,IP地址需要進行擴容才能滿足需求。小型網路可以對所有設備重新分配IP地址,其網路內部客戶機和伺服器數量較少,實現起來比較簡單。但如果是一個大型網路,重新配置整個網路的IP地址是不明智的,如果操作不當,可能會造成通信暫時中斷以及其他網路故障。我們可以通過多作用域的設置,即DHCP伺服器發布多個作用域實現IP地址增容的目的。
公司IP地址規劃為192.168.2.0/24網段,可以容納254台設備,使用DHCP伺服器建立一個192.168.2.0網段的作用域,動態管理網路IP地址,但網路規模擴大到500台機器,顯然一個C類網的地址無法滿足要求了。這時,可以再為DHCP伺服器添加一個新作用域,管理分配192.168.3.0/24網段的IP地址,為網路增加254個新的IP地址,這樣既可以保持原有IP地址的規劃,又可以擴容現有的網路IP地址。
(1)簡單實現DHCP多作用域
對於多作用域的配置,必須保證DHCP伺服器能夠偵聽所有子網客戶機的請求信息,下面將講解配置多作用域的基本方法,為DHCP添加多個網卡連接每個子網,並發布多個作用域的聲明。
注意:劃分子網時,如果選擇直接配置多作用域實現動態IP分配的任務,則必須要為DHCP伺服器添加多塊網卡,並配置多個IP地址,否則DHCP伺服器只能分配與其現有網卡IP地址對應網段的作用域。
採用雙網卡實現兩個作用域
1)網卡配置IP地址
DHCP伺服器有多塊網卡時,需要使用ifconfig命令為每塊網卡配置獨立的IP地址,但要注意,IP地址配置的網段要與DHCP伺服器發布的作用域對應哈~
ifconfig eth0 192.168.2.1 netmask 255.255.255.0
ifconfig eth1 192.168.3.1 netmask 255.255.255.0
2)編輯dhcpd.conf主配置文件
當DHCP伺服器網路環境搭建完畢後,我們可以編輯dhcpd.conf主配置文件完成多作用域的設置。
ddns-update-style none;
ignore client-updates;
subnet 192.168.2.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
option time-offset -18000; # Eastern Standard Time
# 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.2.50 192.168.2.250;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.3.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
option time-offset -18000; # Eastern Standard Time
# 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.3.50 192.168.3.250;
default-lease-time 21600;
max-lease-time 43200;
max-lease-time 43200;
}
保存退出哈~
3)測試驗證
重啟DHCP服務後檢查系統日誌,檢測配置是否成功,使用tail命令動態顯示日誌信息。
tail -F /etc/log/messages
經過設置,對於DHCP伺服器將通過eth0和eth1兩塊網卡偵聽客戶機的請求,並發送相應的回應。
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth1
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
2、如何使DHCP伺服器為多個網段分配IP地址?請不不要復制謝謝。
為多個網段分配地址首先需要DHCP伺服器上配置多個對應的地址池!然後網路設備上要配置DHCP伺服器的IP地址,具體配置方法不同伺服器和網路設備的方法不一樣...
3、DHCP伺服器要分配客服端提供多個網段的IP地址,一般需要創建什麼啊!
IP地址池...就是客戶機獲得的IP地址范圍以及對應的網關...
DNS地址...上網必須的...
其他都是可選配置...另外看你的DHCP伺服器是啥...不同的伺服器配置方法不一樣...
4、dhcp伺服器能不能跨網段分配ip
DHCP(Dynamic Host Configuration Protocol,抄動態主機配置協襲議)是一個區域網的網路協議,使用UDP協議工作, 主要有兩個用途:給內部網路或網路服務供應商自動分配IP地址,給用戶或者內部網路管理員作為對所有計算機作中央管理的手段,在RFC 2131中有詳細的描述。DHCP有3個埠,其中UDP67和UDP68為正常的DHCP服務埠,分別作為DHCP Server和DHCP Client的服務埠;546號埠用於DHCPv6 Client,而不用於DHCPv4,是為DHCP failover服務,這是需要特別開啟的服務,DHCP failover是用來做"雙機熱備"的。
5、做了個dhcp伺服器,有兩個網段,在route 上,怎麼設置,大概說下。。。。。。。。謝了
路由上設置靜態路由,我知道思科上是這樣設置的
設置單臂路由
router(config)#interface f0/0
router(config-if)#no shutdown
router(config)#interface f0/0.1
router(config-subif)#ip address 192.168.1.1 255.255.255.0
router(config-subif)#encapsulation dot1Q 1
router(config)#interface f0/0.2
router(config-subif)#ip address 192.168.2.1 255.255.255.0
router(config-subif)#encapsulation dot1Q 2
我設定1.0網段回作為DHCP服務答器 那麼如果客戶端是在2.0網段 那麼我們可以先在DHCP伺服器上面設置作用域其中有分配2.0的網段
然後在2.0網段安裝一台中繼伺服器 用來轉發2.0網段的IP地址
有不清楚的可以給我留言.
6、DHCP伺服器跨網段分配IP的問題。
你可以設置「DHCP伺服器中繼代理」,這樣就可以實現不同子網的DHCP服務!
http://www.chinadv.com/tech/327311/
你去內參考一下 !
至於哪台PC取得哪個網段容的地址,你可以將所有PC劃分3個VLAN。把DHCP伺服器和192.168.0網段的PC劃為一個VLAN,然後把DHCP中繼代理伺服器和192.168.1網段的PC劃到另一個VLAN,然後最後把兩個DHCP伺服器再劃到一個VLAN!你看看這樣還可以!
7、怎樣設置多網段dhcpd?
首先你要把網卡搞清楚,然後才可以進到下一步
第一步:創建
VLAN
Switch>Vlan Database
Switch(Vlan)>Vlan 2 Name server
Switch(Vlan)>Vlan 3 Name work01
Switch(vlan)>Vlan 4 Name work02
第二步:啟用DHCP中繼代理:
關鍵一步,缺少以下兩條命令,VLAN中使用「IP HELPER
-ADDRESS DHCP
伺服器地址」指定DHCP伺服器,客戶機仍然不能獲得IP地址
Switch>Enable
Switch#Config t
Switch(Config)Service Dhcp
Switch(Config)Ip Dhcp Relay Information Option
第三步:設置
VLAN IP
地址:
Switch(Config)>Int Vlan 2
Switch(Config-vlan)Ip Address 192.168.2.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 3
Switch(Config-vlan)Ip Address 192.168.3.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)>Int Vlan 4
Switch(Config-vlan)Ip Address 192.168.4.1 255.255.255.0
Switch(Config-vlan)No Shut
Switch(Config-vlan)Exit
注意:由於此時沒有將埠分配置到VLAN2,3,4,所以各VLAN會DOWN掉,待將埠分配到各VLAN後,VLAN會起來
第四步:設置埠全局參數
Switch(Config)Interface Range Fa 0/1 - 24
Switch(Config-if-range)Switchport Mode Access
Switch(Config-if-range)Spanning-tree Portfast
第五步:將埠添加到VLAN2,3,4中 /*將埠1-8添加到VLAN 2*/
Switch(Config)Interface Range Fa 0/1 - 8
Switch(Config-if-range)Switchport Access Vlan 2 *
將埠9-16
添加到VLAN 3*/ Switch(Config)Interface Range Fa 0/9 - 16
Switch(Config-if-range)Switchport Access Vlan 3 *
將埠17-24添加到VLAN 4*/
Switch(Config)Interface Range Fa 0/17 - 24
Switch(Config-if-range)Switchport Access Vlan 4
Switch(Config-if-range)Exit /*經過這一步後,各VLAN會起來
第六步:在VLAN3和4中設定DHCP伺服器地址
VLAN 2中不須指定DHCP伺服器地址
Switch(Config)Int Vlan 3
Switch(Config-vlan)Ip Helper-address 192.168.2.10
Switch(Config)Int Vlan 4
Switch(Config-vlan)Ip Helper-address 192.168.2.10
第七步啟用路由
路由啟用後各VLAN間主機可互相訪問,若需進一步控制訪問許可權,則需應用到訪問控制列表
Switch(Config)Ip Routing
第八步:結束並保存配置
Switch(Config-vlan)End
Switch#Copy Run Start
8、兩個網段怎麼配置一個DHCP伺服器?
(1)簡單實現DHCP多作用域
對於多作用域的配置,必須保證DHCP伺服器能夠偵聽所有子網客戶機的請求信息,下面將講解配置多作用域的基本方法,為DHCP添加多個網卡連接每個子網,並發布多個作用域的聲明。
注意:劃分子網時,如果選擇直接配置多作用域實現動態IP分配的任務,則必須要為DHCP伺服器添加多塊網卡,並配置多個IP地址,否則DHCP伺服器只能分配與其現有網卡IP地址對應網段的作用域。
採用雙網卡實現兩個作用域
1)網卡配置IP地址
DHCP伺服器有多塊網卡時,需要使用ifconfig命令為每塊網卡配置獨立的IP地址,但要注意,IP地址配置的網段要與DHCP伺服器發布的作用域對應哈~
ifconfig eth0 192.168.2.1 netmask 255.255.255.0
ifconfig eth1 192.168.3.1 netmask 255.255.255.0
2)編輯dhcpd.conf主配置文件
當DHCP伺服器網路環境搭建完畢後,可以編輯dhcpd.conf主配置文件完成多作用域的設置。
ddns-update-style none;
ignore client-updates;
subnet 192.168.2.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
option time-offset -18000; # Eastern Standard Time
# 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.2.50 192.168.2.250;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.3.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
option time-offset -18000; # Eastern Standard Time
# 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.3.50 192.168.3.250;
default-lease-time 21600;
max-lease-time 43200;
max-lease-time 43200;
}
保存退出。
3)測試驗證
重啟DHCP服務後檢查系統日誌,檢測配置是否成功,使用tail命令動態顯示日誌信息。
tail -F /etc/log/messages
經過設置,對於DHCP伺服器將通過eth0和eth1兩塊網卡偵聽客戶機的請求,並發送相應的回應。
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth1
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
9、DHCP多網段劃分問題
是不是你復的交換制機不支持VLan呢 你可以參考下http://www.linuxsir.org/bbs/thread215393.html