第一步:确定dhcp server位置,配置DHCP SERVER
dhcp enable
#
ip pool vlanif10
gateway-list 192.168.1.1
network 192.168.1.0 mask 255.255.255.0
lease day 10 hour 0 minute 0
dns-list 8.8.8.8 114.114.114.114
第二步:确定dhcp sever的出接口
#
interface GigabitEthernet0/0/0
ip address 10.1.1.1 255.255.255.0
dhcp select global
第三步:设置路由
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 10.1.1.0 0.0.0.255
第四步:确定中继位置、配置服务器指向
interface Vlanif20
ip address 192.168.1.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.1.1.1
第五步:配置路由
所有的interface vlanif 接口都相当于直连路由
interface Vlanif10
ip address 20.1.1.2 255.255.255.0
#
interface Vlanif20
ip address 192.168.1.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.1.1.1
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
第六步:确认路由连通性
[sw1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/24 OSPF 10 2 D 20.1.1.1 Vlanif10
20.1.1.0/24 Direct 0 0 D 20.1.1.2 Vlanif10
20.1.1.2/32 Direct 0 0 D 127.0.0.1 Vlanif10
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Vlanif20
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif20
注意:vlanif 是直连路由