大家好,欢迎来到IT知识分享网。
初学网络知识,欢迎各位兄弟姐妹交流沟通学习 :
需求
-公司有三个部门,财务部,市场部,技术部,为了内网安全,给每个部门单独划分一个VLAN
-财务部:vlan10、市场部:vlan20、技术部:vlan30
-公司所有部门,所有VLAN内的主机都通过DHCP服务器分发IP地址
-每个部门,每个VLAN的网关地址都为,192.168.xx.254
-SW5中每个vlanif 虚接口地址都为 192.168.xx.251
-SW5通过vlanif50 与DHCP进行通信,DHCP服务器管理IP:192.168.50.1
-所有的PC都通过SW5与DHCP服务器进行通信,获取IP地址,所以SW5是DHCP中继
配置代码:
1.创建vlan,配置接口模式
[sw1]vlan batch 10 20 30 50
[sw1]int g 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 20
[sw1-GigabitEthernet0/0/1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw2]vlan batch 10 20 30 50
[sw2]int g 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 20
[sw2-GigabitEthernet0/0/1]int g 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw3]vlan batch 10 20 30 50
[sw3]int g 0/0/1
[sw3-GigabitEthernet0/0/1]port link-type access
[sw3-GigabitEthernet0/0/1]port default vlan 30
[sw3-GigabitEthernet0/0/1]int g 0/0/2
[sw3-GigabitEthernet0/0/2]port link-type trunk
[sw3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw5]vlan batch 10 20 30 50
[sw5-GigabitEthernet0/0/5]port link-type access
[sw5-GigabitEthernet0/0/5]port default vlan 50
[sw5]port-group group-member g0/0/1 g0/0/2 g0/0/3
[sw5-port-group]port link-type trunk
[sw5-port-group]port trunk allow-pass vlan all
2.给每个vlanif添加ip地址
[sw5-Vlanif50]ip add 192.168.50.251 24
[sw5-Vlanif10]ip address 192.168.10.251 24
[sw5-Vlanif20]ip add 192.168.20.251 24
[sw5-Vlanif30]ip add 192.168.30.251 24
3.路由器开启DHCP
[R3-GigabitEthernet0/0/1]ip add 192.168.50.1 24
[R3]ip route-static 0.0.0.0 0 192.168.50.251 //添加静态路由
[R3]ip pool vlan10-pool //创建ip地址池
[R3-ip-pool-vlan10]network 192.168.10.0 mask 24 //配置ip地址池可分配的ip网段
[R3-ip-pool-vlan10-pool]gateway-list 192.168.10.254 //配置网关
[R3-ip-pool-vlan10-pool]dns-list 8.8.8.8 //配置dns地址,可不配
[R3-GigabitEthernet0/0/1]dhcp select global //开启全局DHCP
[R3]ip pool vlan20-pool
[R3-ip-pool-vlan20-pool]network 192.168.20.0 mask 24
[R3-ip-pool-vlan20-pool]gateway-list 192.168.20.254
[R3-ip-pool-vlan20-pool]dns-list 8.8.8.8
[R3]ip pool vlan30-pool
[R3-ip-pool-vlan30-pool]network 192.168.30.0 mask 24
[R3-ip-pool-vlan30-pool]gateway-list 192.168.30.254
[R3-ip-pool-vlan30-pool]dns-list 8.8.8.8
4.交换机开启中继功能
[sw5]dhcp enable //开启DHCP服务
[sw5-Vlanif10]dhcp select relay //开启中继功能
[sw5-Vlanif10]dhcp relay server-ip 192.168.50.1 //配置DHCP服务器地址
[sw5-Vlanif20]dhcp select relay
[sw5-Vlanif20]dhcp relay server-ip 192.168.50.1
sw5-Vlanif30]dhcp select relay
[sw5-Vlanif30]dhcp relay server-ip 192.168.50.1
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/148100.html