admin 管理员组

文章数量: 887007

Cisco 的基本配置实例之五

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 - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is 172.16.0.1 to network 0.0.0.0C    192.168.106.0/24 is directly connected, Vlan60# 这种类型的路由——标志为“C”的路由,为静态直连路由。C    192.168.107.0/24 is directly connected, Vlan70C    192.168.104.0/24 is directly connected, Vlan40C    192.168.105.0/24 is directly connected, Vlan50C    192.168.110.0/24 is directly connected, Vlan100C    192.168.111.0/24 is directly connected, Vlan110C    192.168.108.0/24 is directly connected, Vlan80172.16.0.0/30 is subnetted, 1 subnetsC       172.16.0.0 is directly connected, Vlan2C    192.168.115.0/24 is directly connected, Vlan160C    192.168.113.0/24 is directly connected, Vlan1C    192.168.112.0/24 is directly connected, Vlan120C    192.168.102.0/24 is directly connected, Vlan20C    192.168.103.0/24 is directly connected, Vlan30C    192.168.100.0/24 is directly connected, Vlan150C    192.168.101.0/24 is directly connected, Vlan10S*   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                ProtocolFastEthernet1          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等信息。

 

转载于:.html

本文标签: Cisco 的基本配置实例之五