第三章 三层交换_职场

三 实验要求

1实现VLAN 之间的通信

2实现各VLAN内的主机能够访问路由器连接的主机

3在三层交换机上配置DHCP中继,实现企业网内各VLAN主机能够动态获得IP地址

4路由器配置成DHCP SERVER(连接路由器的PC也可以动态获取IP地址) PC机获取IP的命令:IP ADD DHCP

5仔细观察交换机,路由器,三层交换机上的CEF表,清楚表中的内容

基本思路:

(一)对于路由器

1:命名

2:配置端口IP并激活

3:开启DHCP

4:配置各个vlan 的地址池

5:配置默认路由

(二)对于三层交换机

1:命名

2:添加vlan

3:配置trunk

4:启用路由功能

5:激活路由端口并配置IP

6:配置各个vlan 的IP以及帮助地址

7:配置默认路由

(三)对于二层交换机

1:命名

2:添加vlan

3:将相应的端口添加到相应的vlan中

4:配置trunk

(四)对于PC

1:命名

2:禁用路由功能

3:配置自动获取IP

4:激活端口

----------------------------------------------------------

R1:

en

conf t

host R1

int f1/0

ip add 192.168.3.1 255.255.255.0 //配置端口ip

no sh

exit

int f0/0

ip add 192.168.4.1 255.255.255.0

no sh

exit

service dhcp //开启dhcp,作为dhcp服务器

ip dhcp pool vlan2 //配置dhcp地址池

network 192.168.1.0 255.255.255.0 //对应各个网段

default-router 192.168.1.2 //配置各个网段的网关地址

dns-server 1.1.1.1 //配置DNS服务器

exit

ip dhcp pool vlan3

network 192.168.2.0 255.255.255.0

default-router 192.168.2.2

dns-server 1.1.1.1

exit

ip dhcp pool pc3

network 192.168.4.0 255.255.255.0

default-router 192.168.4.1

dns-server 1.1.1.1

exit

ip route 0.0.0.0 0.0.0.0 192.168.3.2 //配置默认路由

end

wr

--------------------------------------------------------

3l-sw1:

en

conf t

host 3l-sw1

exit

vlan da //创建vlan

vlan 2

vlan 3

exit

conf t

int range f0/1 2 //配置trunk

switchport mode trunk

exit

ip routing //开启路由功能

int f0/0 //配置路由端口的IP

no switchport

ip add 192.168.3.2 255.255.255.0

exit

int vlan 2 //配置网关地址

ip add 192.168.1.2 255.255.255.0

no sh

ip helper-address 192.168.3.1 //配置帮助地址,为了到DHCP上获取IP

exit

int vlan 3

ip add 192.168.2.2 255.255.255.0

no sh

ip helper-address 192.168.3.1

exit

ip route 0.0.0.0 0.0.0.0 192.168.3.1 //配置默认路由

end

wr

--------------------------------------------------------

2l-sw1:

en

conf t

host 2l-sw1

exit

vlan da //添加vlan

vlan 2

exit

conf t

int f0/2 //将相应的端口添加到对应的vlan

switchport access vlan 2

exit

int f0/1 //配置trunk

switchport mode trunk

end

wr

--------------------------------------------------------

2l-sw2:

en

conf t

host 2l-sw2

exit

vlan da

vlan 3

exit

conf t

int f0/2

switchport access vlan 3

exit

int f0/1

switchport mode trunk

end

wr

--------------------------------------------------------

pc1:

en

conf t

host pc1

no ip routing //这里把路由器当作pc,必须禁用路由功能

int f0/0

ip address dhcp //设置自动获取IP

no sh //激活端口

end

wr

---------------------------------------------------------

pc2:

en

conf t

host pc2

no ip routing

int f0/0

ip address dhcp

no sh

end

wr

---------------------------------------------------------

pc3:

en

conf t

host pc3

no ip routing

int f0/0

ip address dhcp

no sh

end

wr

测试截图:

第三章 三层交换_职场_02第三章 三层交换_休闲_03第三章 三层交换_休闲_04第三章 三层交换_职场_05

第三章 三层交换_三层交换_06