
//手動配置PC0的IP、子網掩碼、網管
//R1
ena //進入特權模式
conf t // 進入全局配置模式
host name R1 //為路由器改名字
int f0/0 //進去f0/0端口
ip add 192.168.1.254 255.255.255.0
no shut
int f0/1
ip add 192.168.2.254 255.255.255.0
no shut
int f1/1
ip add 192.168.0.1 255.255.255.0
no shut
//PC0已經手動設置
設置 DHCP
ip dhcp pool R1
network 192.168.2.0 255.255.255.0 //設置DHCP應用池網段
de 192.168.2.254 //設置網關
dns 222.88.88.88 //設置DNS
exit
ip dhcp exc 192.168.2.254 //排除IP
//R2
ena
conf t
host name R2
int f0/1
ip add 192.168.0.2 255.255.255.0
no shut
int f0/0
ip add 192.168.3.254 255.255.255.0
做DHCP
ip dhcp pool R2
network 192.168.3.0 255.255.255.0 //設置DHCP應用池網段
default 192.168.3.254 //設置網關
dns 222.88.88.88 設置DNS
exit
ip dhcp exc 192.168.3.254 //排除IP
查看靜態路由
show ip route //查看路由
R1#show ip route

少了 192.168.3.0段 所以R1不能訪問3.0段
繼續設置路由
conf t
ip route 192.168.3.0 255.255.255.0 192.168.0.2 //設置目標IP 子網掩碼 下一跳IP
同理做R2