课程第五天内容《基础交换 五》

课程内容回顾:
       
    IP地址浪费解决方案:
        公有地址/私有地址;
        子网划分
            优点
            缺点
        IPv6 - 128bit ;
             
      
    ARP  
      MAC :物理地址,全球范围内,唯一的指定一个物理设备;
       
      确定通信设备/终端, 一定要 IP 地址与 MAC 地址结合;
 
      即,必须形成IP地址与MAC地址的对应关系,如下:
             IP --- MAC         
      对应关系的形成方式:
                 手动 -  
                 自动 - ARP  
                     分类 -  ARP  
                             代理ARP
                             ARP病毒
                             无故ARP
                        
     R1 -----  R2   ----  R3    
      
    R1 : ping 192.168.23.3
                源IP - 192.168.12.1  
                目标IP - 192.168.23.3                 
                问题: 不通 ;  
                定位:路由;
                定义:什么是路由?如何实现?
                     不同网段之间的设备互通,称之为路由;  
                     通过 具有路由功能的设备来实现:
                                路由器
                                多层交换机
                                    本质:
                                        路由表;
                                        
    路由器的工作过程:
          仅仅关注数据包的”目标IP地址“
          然后将其与路由表中的路由条目进行”匹配“
               匹配成功,则转发;
               不成功,则丢弃;
 
          条目匹配举例:
              数据包 - 192.168.12.1  ----> 192.168.23.3  
               
              查看路由表 --- R1# show ip route  
               
              C 192.168.12.0 /24  is directly   gi0/0  
               
              手动添加去往目标IP地址所需要的路由:
              R1(config)# ip route 192.168.23.0 255.255.255.0
                                               192.168.12.2  
               
              R1# show ip route  
              S 192.168.23.0 /24 [1/0] via , 192.168.12.2  
              C 192.168.12.0 /24  is directly   gi0/0  
               
    路由 与 ARP 关系:
        1、首先通过路由,确定数据转发方向;
        2、其次获得具体目标IP对应的物理地址;即 ARP ;  
 
------------------------------------------------------
Router 作为 DHCP 服务器:  
 
1、配置 Router 地址:
    Router(config)#hostname GateWay
    GateWay(config)#interface gi0/0
    GateWay(config-if)# no shutdown  
    GateWay(config-if)# ip address 192.168.1.1 255.255.255.0
 
2、启动 DHCP 服务 :
GateWay(config)# service dhcp  
 
3、配置 DHCP 地址池:
   GateWay(config)# ip dhcp pool CCIE
   GateWay(dhcp-config)# network 192.168.1.0 255.255.255.0
   GateWay(dhcp-config)# default-router 192.168.1.254
   GateWay(dhcp-config)# dns-server 8.8.8.8  
4、配置 DHCP 客户端 :
     点击 - ”DHCP“ ;
 
5、验证命令:
       在服务器端的验证命令:
                   GateWay# show ip dhcp binding  
                   GateWay# show running-config  
       在客户端的验证:
                    运行--> cmd ---> ipconfig /all        
 
 
6、特殊地址处理:
    内网有业务服务器,编址如下:
         web - 192.168.1.20    /24
         email  - 192.168.1.75 /24
         FTP - 192.168.1.88    /24  
          OA - 192.168.1.166   /24  
    DHCP 地址排除:
      GateWay(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
 
         注意:
            low 地址与 high 地址不同,则表示一段连续的IP;
            如果相同,则表示”排除一个地址“;
---------------------------------------------------------
Switch 作为 DHCP 服务器:
 
1、配置交换机的IP地址;
  Switch(config)# interface vlan 1  
  Switch(config-if)# no shutdown  
  Switch(config-if)# ip address 192.168.1.250 255.255.255.0    
2、启动 DHCP 服务 :
  Switch(config)# service dhcp
3、配置 DHCP 的排除地址:
  Switch(config)# ip dhcp excluded-address 192.168.1.1  
                                           192.168.1.20   
4、配置 DHCP 地址池 :
  Switch(config)# ip dhcp pool CCNP
    Switch(dhcp-config)# network 192.168.1.0 255.255.255.0
    Switch(dhcp-config)# default-router 192.168.1.1  
    Switch(dhcp-config)# dns-server  8.8.8.8
5、配置 DHCP 客户端 ;  
6、验证:
Switch#show ip interface brief  // 查看交换机接口IP地址配置;
Switch#show running-config     //查看 DHCP 的相关配置命令;
Switch#show ip dhcp binding //查看DHCP服务器分配成功的IP地址
   
    在 PC 上 :  
     ipconfig /all   // 在 PC 的命令行中查看自动获取的IP地址
      ping  x.x.x.x // 在 PC1 上 测试与 PC2 的 连通性;       
 
 
---------------------------------------------------------
 
需求:
   确保医院中的财务部、门诊部、药房 ,属于不同的网段;
   每个部门的主机,自动获取IP地址;
   网段分别为:
       财务部 - 192.168.1.0 / 24  ;  
                192.168.1.254 (网关)
                8.8.8.8 (DNS-server)
       门诊部 - 192.168.2.0 / 24  ;  
                192.168.2.254 (网关)
                7.7.7.7 (DNS-server)
       药房   - 192.168.3.0 / 24  ;  
                192.168.3.254 (网关)
                9.9.9.9 (DNS-server)
    确保部门内部和部门之间的主机都可以互相 Ping 通 ;  
 
路由器配置命令:
Router(config)#interface gi0/0     // 财务部网关接口;
Router(config-if)# no shutdown  
Router(config-if)# ip address 192.168.1.254   255.255.255.0
Router(config-if)#description    GW-CaiWu  
 
Router(config)#interface gi0/0     // 门诊部网关接口;
Router(config-if)# no shutdown  
Router(config-if)# ip address 192.168.2.254   255.255.255.0
Router(config-if)#description    GW-MenZhen  
 
Router(config)#interface gi0/0     // 药房网关接口;
Router(config-if)# no shutdown  
Router(config-if)# ip address 192.168.3.254   255.255.255.0
Router(config-if)#description    GW-YaoFang  
 
 
该项目出于成本控制方面的考虑,建议节省3台服务器,将
交换机作为 DHCP server :
 
SW1(config)#interface vlan 1  
SW1(config-if)#no shutdown
SW1(config-if)#ip address 192.168.1.250  255.255.255.0  
 
SW1(config)# ip dhcp pool CaiWu  
SW1(dhcp-config)# network 192.168.1.0  255.255.255.0
SW1(dhcp-config)# default-router 192.168.1.254
SW1(dhcp-config)# dns-server  8.8.8.8
SW1(dhcp-config)# exit
SW1(config)# service dhcp  
 
 
SW2(config)#interface vlan 1  
SW2(config-if)#no shutdown
SW2(config-if)#ip address 192.168.2.250  255.255.255.0  
 
SW2(config)# ip dhcp pool MenZhen  
SW2(dhcp-config)# network 192.168.2.0  255.255.255.0
SW2(dhcp-config)# default-router 192.168.2.254
SW2(dhcp-config)# dns-server  7.7.7.7
SW2(dhcp-config)# exit
SW2(config)# service dhcp  
 
 
SW3(config)#interface vlan 1  
SW3(config-if)#no shutdown
SW3(config-if)#ip address 192.168.3.250  255.255.255.0
 
SW3(config)# ip dhcp pool MenZhen  
SW3(dhcp-config)# network 192.168.3.0  255.255.255.0
SW3(dhcp-config)# default-router 192.168.3.254
SW3(dhcp-config)# dns-server  9.9.9.9
SW3(dhcp-config)# exit
SW3(config)# service dhcp   
 
 
-------------------------------------------------------
DHCP Relay 配置:(仅在门诊楼与药房的网关端口进行配置)
     将路由器 配置为 DHCP relay , 需要在每个部门的
     网关端口上进行配置 -  
Router(config)# interface gi0/2
Router(config-if)# description GW-YaoFang
Router(config-if)# ip helper-address  192.168.1.250
                      // 此时该网关端口接收到 DHCP  discover
                      报文以后,会将广播报文,以单播的方式
                      发送到该 DHCP 服务器 - 192.168.1.250 ;
                      并且源地址为 192.168.3.254 ,  
                        目标地址为 192.168.1.250 ,
Router(config)# service dhcp // 作为DHCP中继,必须要开启DHCP;
注意:
    当 DHCP 服务器上具有多个 DHCP 地址池时,
    服务器是通过 DHCP 报文 中的源IP地址来进行地址池区分的;
    在 DHCP relay 环境中,本质上就是根据每个部门的网关IP地址
    来决定的;
-----------------------------------------------------
在 DHCP 服务器 上,配置三个网关的 DHCP 地址池;
同时,在 DHCP 服务器上配置 ”网关IP“地址 :
        确保 DHCP 服务器能够回应其他部门/网段的  
        DHCP 客户端发送的 DHCP 报文;
 
------------------------------------------------------------
 
浮动静态路由回顾:
    作用 -  
       实现链路备份;
          当主链路活动的时候,针对主链路的路由,进入路由表;
          主链路故障以后,
          备份链路针对的路由(管理距离大于1的),进入路由表;
          主链路修复以后,管理距离为 1 的路由,会再次进入路由
          表,之前针对备份链路的路由,被排挤出路由表。
          因为,在路由表中,针对一个目标网络,只能是存在
          一个最好的,比较原则:
             首先比较 AD ,值越小越好;
             如果AD相同,则比较 Metric,值越小越好;
        
        此处的备份链路的路由,是通过调整 AD 值来实现的;
     
    浮动路由/备份路由 的 配置命令:
Router(config)# ip route 192.168.50.0 255.255.255.0  
                                       192.168.23.3   200
验证命令
     show ip route  
     show  ip  route  192.168.50.0  
         该命令查看的是一个具体的路由条目的详细信息:
例如:
R1#show ip route 192.168.50.0
Routing entry for 192.168.50.0/24
Known via "static", distance 1, metric 0
  Routing Descriptor Blocks:
  * 192.168.12.2

      Route metric is 0, traffic share count is 1



      本文转自云计算王森 51CTO博客,原文链接:http://blog.51cto.com/13426941/1978547,如需转载请自行联系原作者






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值