加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

DHCP服务器给每个vlan分配地址

(2013-01-15 18:19:00)
标签:

杂谈

分类: 西安深度博客

实验拓扑

http://www.norvel.com.cn/blog/wp-content/uploads/2013/01/360%E6%88%AA%E5%9B%BE20130115153712706-300x252.jpg

步骤:

第一步

首先打开SW1,配置它vlan信息

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1#vlan database

SW1(vlan)#vlan 10 name ccna

VLAN 10 added:

Name: ccna

SW1(vlan)#vlan 20 name ccnp

VLAN 20 added:

Name: ccnp

SW1(vlan)#exit

APPLY completed.

Exiting....

SW1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#int f0/1

SW1(config-if)#switchport access vlan 10

SW1(config-if)#int f0/2

SW1(config-if)#switchport access vlan 20

SW1(config-if)#int f0/0

SW1(config-if)#switchport mode trunk

*Mar  1 00:05:15.851: %DTP-5-TRUNKPORTON: Port Fa0/0 has become dot1q trunk

第二步

对DHCPServer的配置

DHCPServer#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

DHCPServer(config)#int f0/0

DHCPServer(config-if)#no shutdown    先打开它的物理接口

*Mar  1 00:06:12.583: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:06:13.583: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

DHCPServer(config-if)#int f0/0.10   创建一个子接口,用来单臂路由

DHCPServer(config-subif)#encapsulation dot1Q 10    一定要记住先对这个端口进行数据封装,再配置地址

DHCPServer(config-subif)#ip add 192.168.10.1 255.255.255.0

DHCPServer(config-subif)#int f0/0.20

DHCPServer(config-subif)#encapsulation dot1Q 20

DHCPServer(config-subif)#ip add 192.168.20.1 255.255.255.0

DHCPServer(config-subif)#exit

DHCPServer(config)#service dhcp   打开dhcp服务

DHCPServer(config)#ip dhcp pool vlan_10  创建vlan10的地址池

DHCPServer(dhcp-config)#network 192.168.10.0 /24

DHCPServer(dhcp-config)#dns-server 8.8.8.8

DHCPServer(dhcp-config)#lease 0 10 30

DHCPServer(dhcp-config)#default-router 192.168.10.1

DHCPServer(dhcp-config)#ip dhcp pool vlan_20

DHCPServer(dhcp-config)#network 192.168.20.0 /24

DHCPServer(dhcp-config)#dns-server 8.8.8.8

DHCPServer(dhcp-config)#lease 0 2

DHCPServer(dhcp-config)#default-router 192.168.20.1

DHCPServer(dhcp-config)#exit

DHCPServer(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.10

DHCPServer(config)#ip dhcp excluded-address 192.168.20.1 192.168.20.6

DHCPServer(config)#end

DHCPServer#show ip dhcp pool

Pool vlan_10 :

Utilization mark (high/low)    : 100 / 0

Subnet size (first/next)       : 0 / 0

Total addresses                : 254

Leased addresses               : 0

Pending event                  : none

1 subnet is currently in the pool :

Current index        IP address range                    Leased addresses

192.168.10.1         192.168.10.1     - 192.168.10.254    0

 

Pool vlan_20 :

Utilization mark (high/low)    : 100 / 0

Subnet size (first/next)       : 0 / 0

Total addresses                : 254

Leased addresses               : 0

Pending event                  : none

1 subnet is currently in the pool :

Current index        IP address range                    Leased addresses

192.168.20.1         192.168.20.1     - 192.168.20.254    0

DHCPServer#

第三步

对PC1、PC2的配置

PC1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

PC1(config)#no ip routing

PC1(config)#no ip do lo

PC1(config)#int f0/0

PC1(config-if)#ip add dhcp

PC1(config-if)#no shutdown

*Mar  1 00:15:20.463: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:15:21.463: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

*Mar  1 00:15:33.435: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 192.168.10.11, mask 255.255.255.0, hostname PC1

PC1(config-if)#end

PC1#show ip int b

Interface            IP-Address    OK? Method Status       Protocol

FastEthernet0/0     192.168.10.11   YES DHCP   up            up

PC2

 

PC2#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

PC2(config)#no ip routing

PC2(config)#no ip do lo

PC2(config)#int f0/0

PC2(config-if)#ip add dhcp

PC2(config-if)#no shutdown

PC2(config-if)#end

*Mar  1 00:17:51.691: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 00:17:51.735: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:17:52.735: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

PC2#show ip int b

Interface            IP-Address      OK? Method Status        Protocol

FastEthernet0/0     192.168.20.7      YES DHCP   up            up

 

第四步

我们可以对它们之间能否通信进行测试

PC2#ping 192.168.20.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/231/1028 ms

 

PC2#ping 192.168.10.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/32/56 ms

 

PC2#ping 192.168.10.11

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.10.11, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 20/38/60 ms

PC2#

 

它们之间能通信,实验成

查看原文:http://www.norvel.com.cn/blog/?p=1850

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有