首页 > 代码库 > DHCP + 静态路由 练习
DHCP + 静态路由 练习
环境:DHCP 服务器地址 : 192.168.0.100/24 .
首选配置DHCP服务器
为DHCP服务器配置静态IP地址信息
配置DHCP服务
再添加2.0 网段 和 3.0网段
注意:网关要设置成相应网段的网关
配置两台路由
Router 0:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip add 192.168.0.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#int s0/0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#clock rat
Router(config-if)#clock rate 64000
Router(config-if)#no shut
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
Router(config-if)#exit
Router(config)#ip route
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.1.2
Router(config)#exit
Router#show ip route
%SYS-5-CONFIG_I: Configured from console by console
192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.0.0/24 is directly connected, GigabitEthernet0/0
L 192.168.0.1/32 is directly connected, GigabitEthernet0/0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, Serial0/0/0
L 192.168.1.1/32 is directly connected, Serial0/0/0
S 192.168.2.0/24 [1/0] via 192.168.1.2
S 192.168.3.0/24 [1/0] via 192.168.1.2
Router 1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip add 192.168.2.1 255.255.255.0
Router(config-if)#ip helper-address 192.168.0.100
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#in g0/1
Router(config-if)#ip add 192.168.3.1 255.255.255.0
Router(config-if)#ip helper-address 192.168.0.100
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
Router(config-if)#exit
Router(config)#int s0/0/1
Router(config-if)#ip add 192.168.1.2 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/1, changed state to up
Router(config-if)#exit
Router(config)#ip
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/1, changed state to
Router(config)#ip route
Router(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1
Router(config)#exit
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.0.0/24 [1/0] via 192.168.1.1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, Serial0/0/1
L 192.168.1.2/32 is directly connected, Serial0/0/1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/0
L 192.168.2.1/32 is directly connected, GigabitEthernet0/0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/1
L 192.168.3.1/32 is directly connected, GigabitEthernet0/1
查看PC是否获取到IP地址
0网段PC1
2网段PC3
3网段Laptop 0
可以看到三个网段的电脑都获得了IP地址。
测试连通性:
Laptop 0
本文出自 “罗西技术博客” 博客,请务必保留此出处http://guoxin123.blog.51cto.com/2360312/1412615