5、配置交換機的路由功能
說明:只有在三層交換機上才有路由功能,其他的二層接入交換機要想在不同的vlan之間傳送數據需要通過trunk口到核心交換機上進行完路由交換后才可以。
TEST(config)#ip routing # 使能三層交換機的路由功能,默認是關閉的
TEST(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1
# 配置交換機的默認路由,也就是總的出口路由。
TEST(config)#end # 退出驗證一下剛才的配置
TEST#sh ip rouet
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is 172.16.0.1 to network 0.0.0.0 C 192.168.106.0/24 is directly connected, Vlan60 # 這種類型的路由——標志為“C”的路由,為靜態直連路由。 C 192.168.107.0/24 is directly connected, Vlan70 C 192.168.104.0/24 is directly connected, Vlan40 C 192.168.105.0/24 is directly connected, Vlan50 C 192.168.110.0/24 is directly connected, Vlan100 C 192.168.111.0/24 is directly connected, Vlan110 C 192.168.108.0/24 is directly connected, Vlan80 172.16.0.0/30 is subnetted, 1 subnets C 172.16.0.0 is directly connected, Vlan2 C 192.168.115.0/24 is directly connected, Vlan160 C 192.168.113.0/24 is directly connected, Vlan1 C 192.168.112.0/24 is directly connected, Vlan120 C 192.168.102.0/24 is directly connected, Vlan20 C 192.168.103.0/24 is directly connected, Vlan30 C 192.168.100.0/24 is directly connected, Vlan150 C 192.168.101.0/24 is directly connected, Vlan10 S* 0.0.0.0/0 [1/0] via 172.16.0.1 # 為配置的默認路由
TEST#
6、配置交換機的DHCP功能
TEST#sh ip int b # 先顯示一下所有的端口配置
Interface IP-Address OK? Method Status Protocol FastEthernet1 unassigned YES NVRAM down down Vlan1 192.168.113.254 YES NVRAM up up Vlan2 172.16.0.2 YES NVRAM up up Vlan10 192.168.101.254 YES NVRAM up up Vlan20 192.168.102.254 YES NVRAM up up Vlan30 192.168.103.254 YES NVRAM up up Vlan40 192.168.104.254 YES NVRAM up up Vlan50 192.168.105.254 YES NVRAM up up Vlan60 192.168.106.254 YES NVRAM up up Vlan70 192.168.107.254 YES NVRAM up up Vlan80 192.168.108.254 YES NVRAM up up Vlan100 192.168.110.254 YES NVRAM up up Vlan110 192.168.111.254 YES NVRAM up up Vlan120 192.168.112.254 YES NVRAM up up # 此例中我們想讓vlan120提供DHCP功能 Vlan150 192.168.100.254 YES NVRAM up up Vlan160 192.168.115.254 YES NVRAM up up GigabitEthernet1/1 unassigned YES unset up up GigabitEthernet1/2 unassigned YES unset down down GigabitEthernet1/3 unassigned YES unset down down GigabitEthernet1/4 unassigned YES unset down down GigabitEthernet1/5 unassigned YES unset down down GigabitEthernet1/6 unassigned YES unset down down GigabitEthernet1/7 unassigned YES unset down down GigabitEthernet1/8 unassigned YES unset down down GigabitEthernet1/9 unassigned YES unset down down GigabitEthernet1/10 unassigned YES unset down down GigabitEthernet1/11 unassigned YES unset down down GigabitEthernet1/12 unassigned YES unset down down GigabitEthernet1/13 unassigned YES unset down down GigabitEthernet1/14 unassigned YES unset down down GigabitEthernet1/15 unassigned YES unset up up GigabitEthernet1/16 unassigned YES unset down down GigabitEthernet1/17 unassigned YES unset down down GigabitEthernet1/18 unassigned YES unset down down GigabitEthernet1/19 unassigned YES unset down down GigabitEthernet1/20 unassigned YES unset down down GigabitEthernet3/1 unassigned YES unset up up GigabitEthernet3/2 unassigned YES unset up up GigabitEthernet3/3 unassigned YES unset up up GigabitEthernet3/4 unassigned YES unset up up GigabitEthernet3/5 unassigned YES unset up up GigabitEthernet3/6 unassigned YES unset up up GigabitEthernet3/7 unassigned YES unset up up GigabitEthernet3/8 unassigned YES unset up up
TEST#
TEST#conf t
Enter configuration commands, one per line. End with CNTL/Z.
TEST(config)#ip dhcp pool wlan # 配置交換機的地址池並命名
TEST(config)#network 192.168.112.0 255.255.255.0 # 定義此地址池的網段
TEST(config)#default-router 192.168.112.254 # 定義分發下去的地址的默認網關
TEST(config)#dns-server 202.102.128.68 202.102.134.68
# 定義分發下去地址的DNS服務器,此處是2個中間用空格分隔。
TEST(config)#ip dhcp excluded-address 192.168.112.200 192.168.112.254
# 定義保留的ip地址端
TEST(dhcp-config)#end
TEST#sh run
##小結一下:至此所屬這個vlan的客戶機就可以通過自動獲取地址的方式來得到正確的ip、網關、dns等信息。