DHCP大家应该不陌生吧!想必也很清楚,不过我还是想在这写有关DHCP配置需要注意的地方。
先看一个示例图:
网络环境:
路由器作为DHCP servers ,交换机提供VLAN接口,三台电脑模拟三个不同网段VLAN1:192.168.1.0/24、VLAN2:192.168.2.0/24、VLAN3:192.168.3.0/24。
路由器配置:
第一种解决方法:使用路由口与接入交换机相连。
ip dhcp pool vlan1
network 192.168.1.0 255.255.255.0
dns-server 1.1.1.1
ip dhcp pool vlan2
network 192.168.2.0 255.255.255.0
dns-server 2.2.2.2
ip dhcp pool vlan3
network 192.168.3.0 255.255.255.0
dns-server 3.3.3.3
interface FastEthernet0/1
no ip address
duplex auto
speed auto
!
interface FastEthernet0/1.1
encapsulation dot1Q 1 native
ip address 192.168.1.2 255.255.255.0
!
interface FastEthernet0/1.2
encapsulation dot1Q 2
ip address 192.168.2.2 255.255.255.0
!
interface FastEthernet0/1.3
encapsulation dot1Q 3
ip address 192.168.3.2 255.255.255.0
交换机配置:
interface FastEthernet0/1
switchport mode trunk
!
interface FastEthernet0/2
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
switchport access vlan 2
!
interface FastEthernet0/11
switchport access vlan 2
!
interface FastEthernet0/12
switchport access vlan 2
!
interface FastEthernet0/13
switchport access vlan 2
!
interface FastEthernet0/14
switchport access vlan 2
!
interface FastEthernet0/15
switchport access vlan 2
!
interface FastEthernet0/16
switchport access vlan 3
!
interface FastEthernet0/17
switchport access vlan 3
!
interface FastEthernet0/18
switchport access vlan 3
!
interface FastEthernet0/19
switchport access vlan 3
!
interface FastEthernet0/20
switchport access vlan 3
!
interface FastEthernet0/21
switchport access vlan 3
!
interface FastEthernet0/22
switchport access vlan 3
!
interface FastEthernet0/23
switchport access vlan 3
!
interface FastEthernet0/24
switchport mode trunk
!
interface GigabitEthernet1/1
!
interface GigabitEthernet1/2
!
interface Vlan1
no ip address
!
interface Vlan2
no ip address
!
interface Vlan3
no ip address
==================================================================
第二种解决方法:使用交换口与接入交换机相连。
interface FastEthernet0/0/0
switchport mode trunk
!
interface FastEthernet0/0/1
switchport access vlan 2
switchport mode access
shutdown
!
interface FastEthernet0/0/2
switchport access vlan 3
switchport mode access
shutdown
!
interface Vlan1
ip address 192.168.1.1 255.255.255.0
!
interface Vlan2
ip address 192.168.2.1 255.255.255.0
!
interface Vlan3
ip address 192.168.3.1 255.255.255.0