【千锋网安教程】自学day13 IP包头详解跟静态路由


typora-copy-images-to: ./
typora-root-url: ./


IP包头详解:

在这里插入图片描述

交换机隔离不了网段,而路由器可以,且路由器必须要连接不同网段
为交换机配置管理IP:
  conf t
  int vlan 1
    ip add 10.1.1.253 255.255.255.0
    no shut
30.为交换机配置默认网关:
  目的:可被跨网段管理!
  conf t
  ip default-gateway 10.1.1.254
31.关闭自动解析功能:
   conf t
   no ip domain-lookup  //这个关了等指令输错的次数多了,就不会跳255让我们等着
路由:
从源主机到目标主机的一个互联网络来转发数据包的过程,我将它理解我从源地点到目标地点的路线
tracert   目标网站  //查看到目标站点所经过的路径
路由表
– 路由器中维护的路由条目的集合
– 路由器根据路由表做路径选择
路由表的形成
– 直连网段
• 配置IP地址,端口UP状态,形成直连路由
– 非直连网段
静态路由
– 由管理员手工配置的,是单向的
– 缺乏灵活性
静态路由配置:
conf t
ip route 目标网段 子网掩码 下一跳IP  //设置路由表
如:
ip route 70.1.1.0 255.255.255.0 20.1.1.2  //这句话的意思,要跳到70.1.1.0这个网段,
默认路由
当路由器在路由表中找不到目标网络的路由条目时,路由器
把请求转发到默认路由接口,我理解为就是给0.0.0.0网段配置下一跳IP
默认路由配置:
conf t
ip route 0.0.0.0  0.0.0.0 下一跳IP  //0.0.0.0代表就是任何网段
如:
ip route 0.0.0.0  0.0.0.0 20.1.1.2  //任何网段的数据都丢到20.1.1.2处理
浮动路由:
在静态或默认路由后加空格+数字(正整数)

ip route 0.0.0.0 0.0.0.0 20.1.1.2
ip route 0.0.0.0 0.0.0.0 30.1.1.1 2 //最后一位我理解为优先级
查看路由表:
show ip route
查看接口列表:
show ip int b

sh run
交换机与路由对比
路由工作在网络层

	– 根据“路由表”转发数据

	– 路由选择

	– 路由转发

交换机工作在数据链路层

	– 根据“MAC地址表”转发数据

	– 硬件
小练习一:

在这里插入图片描述

此实验,首先先创建好此图的拓扑图,然后在第一台路由器中进行配置,配置内容如下

enable
conf t
-----先配置好IP地址,我的原则是左1右2上1下2
int f0/0
ip address 192.168.1.254 255.255.255.0
no shutdown
int f0/1
ip address 192.168.2.1 255.255.255.0
no shutdown

接着,对第二台路由器进行配置

enable
conf t
-----先配置好IP地址,我的原则是左1右2上1下2
int f0/1
ip address 192.168.2.2 255.255.255.0
no shutdown
int f0/0
ip address 192.168.3.1 255.255.255.0
no shutdown

第三台

enable
conf t
-----先配置好IP地址,我的原则是左1右2上1下2
int f0/0
ip address 192.168.3.2 255.255.255.0
no shutdown
int f0/0
ip address 192.168.4.254  255.255.255.0
no shutdown

完成了路由器IP地址的配置,那么接下来就是设置路由表了

第一台

conf t
ip route 0.0.0.0 0.0.0.0 192.168.2.2
do show ip route //查看路由表看是否配置成功

第二台

conf t
ip route 192.168.1.0 255.255.255.0 192.168.2.1
ip route 192.168.4.0 255.255.255.0 192.168.3.2

第三台

conf t
ip route 0.0.0.0 0.0.0.0 192.168.2.2

最后再给PC配置一下IP地址,跟网关即可ping成功,在这发生了个小插曲也记录一点,在配置过程中发现交换机如果参与那网络会ping不成功,解决办法,就是先将PC连接到路由器,ping一次之后,再将交换机加上去即可

小练习二:

在这里插入图片描述先给R1配置IP

enable
conf t
-----先配置好IP地址,我的原则是左1右2上1下2
int f0/0
ip address 192.168.3.254 255.255.255.0
no shutdown
int f1/0
ip address 192.168.1.1 255.255.255.0
no shutdown
int f1/1
ip address 192.168.2.1 255.255.255.0
no shutdown

给R2配置IP

enable
conf t
-----先配置好IP地址,我的原则是左1右2上1下2
int f0/0
ip address 192.168.4.254 255.255.255.0
no shutdown
int f1/0
ip address 192.168.1.2 255.255.255.0
no shutdown
int f1/1
ip address 192.168.2.2 255.255.255.0
no shutdown

给R1设置路由表

conf t
ip conf 192.168.4.0 255.255.255.0 192.168.1.2
ip conf 192.168.4.0 255.255.255.0 192.168.2.2 2

给R2设置路由表

conf t
ip conf 192.168.3.0 255.255.255.0 192.168.1.1
ip conf 192.168.3.0 255.255.255.0 192.168.2.1 2

再给PC配置好IP地址即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值