Cisco路由器配置DHCP服务,分配各PC的IP 会重金追赏
R1
en
conf t
hostname Router01 !设备重命名
int g0/0 !进入接口配置接口IP地址
ip add 172.168.10.2 255.255.255.0
no sh
exit
ip dhcp pool vlan10 !配置DHCP地址池
network 192.168.10.0 255.255.255.0 !配置地址池IP地址
default-router 192.168.10.1 !配置DHCP默认网关
dns-server 211.136.192.6 !配置DHCP分配的DNS
ip dhcp pool vlan20
network 192.168.20.0 255.255.255.0
default-router 192.168.20.1
dns-server 211.136.192.6
ip dhcp pool vlan30
network 192.168.30.0 255.255.255.0
default-router 192.168.30.1
dns-server 211.136.192.6
ip dhcp pool vlan40
network 192.168.40.0 255.255.255.0
default-router 192.168.40.1
dns-server 211.136.192.6
exit
ip dhcp excluded-address 192.168.10.1 !配置DHCP地址池排除IP地址(网关或其他保留地址)
ip dhcp excluded-address 192.168.20.1
ip dhcp excluded-address 192.168.30.1
ip dhcp excluded-address 192.168.40.1
ip route 192.168.0.0 255.255.0.0 172.168.10.3 !配置路由
end
wr
三层交换机
en
conf t
hostname SW_center
vlan 10 !创建vlan
name pc0 !vlan命名
vlan 20
name pc1
vlan 30
name pc2
vlan 40
pc3
vlan 100
name GuanLi
vlan 101
name GuanLi2
int vlan 10 !进入vlan接口
ip add 192.168.10.1 255.255.255.0 !配置vlan的ip地址作为网关
ip helper-address 172.168.10.2 !配置DHCP地址中继指向DHCP服务器
int vlan 20
ip add 192.168.10.1 255.255.255.0
ip helper-add 172.168.10.2
int vlan 30
ip add 192.168.10.1 255.255.255.0
ip helper-add 172.168.10.2
int vlan 40
ip add 192.168.10.1 255.255.255.0
ip helper-add 172.168.10.2
int vlan 100
ip add 172.168.10.3 255.255.255.0
int vlan 101
ip add 172.168.20.2 255.255.255.0
exit
int f0/24 !进入接口
sw mo acc !配置为access模式
sw acc vlan 100 !划分到vlan100作为接口IP地址使用
int rang g0/1-2 !进入多个接口
switchport trunk encapsulation dot1q !接口封装协议
switchport mode trunk !设置接口为trunk模式
exit
ip routing !开启路由功能
ip route 0.0.0.0 0.0.0.0 172.168.10.2 !设置默认路由
vtp domain test !建立vtp域名
vtp mode server !设置vtp模式
vtp password 123456 !设置vtp密码
vtp version 2 !设置vtp版本
end
wr
二层交换机1
en
conf t
vtp domain test
vtp mode client
vtp password 123456
vtp version 2
int g0/1
sw mo tr
int f0/1
sw mo acc
sw acc vlan 10
int f0/2
sw mo acc
sw acc vlan 20
exit
int vlan 100
ip add 172.168.10.1 255.255.255.0
exit
ip default-gateway 172.168.10.3 !设置二层交换机默认路由
end
wr
二层交换机2
en
conf t
vtp domain test
vtp mode client
vtp password 123456
vtp version 2
int g0/1
sw mo tr
int f0/1
sw mo acc
sw acc vlan 30
int f0/2
sw mo acc
sw acc vlan 40
exit
int vlan 101
ip add 172.168.20.1 255.255.255.0
exit
ip default-gateway 172.168.20.2
end
wr