目录
前言
一、路由器介绍
二、路由器配置
1、常用命令
| Router(config)#hostname | 设置主机名 |
| Router(config)#enable secret | 设置特权加密口令 |
| Router(config)#enable password | 设置特权非加密口令 |
| Router#show users | 查看本机上的用户 |
| Router# reload | 重启路由器 |
| Router# show ip interface | 查看端口的IP配置信息 |
| Router# show hosts | 查看主机表 |
| Router(config)#ip domain-lookup | 打开动态域名解析 |
| Router#show ip route | 查看路由表 |
| Router#show ip nat translation | 查看NAT转换情况 |
| Router#show startup-config | 显示已保存的配置信息 |
| Router#erase nvram | 删除已保存的配置信息 |
| Router(config-if)#no switchport | 启用可配置ip地址的路由口 |
2、配置永不超时(防止长时间无操作返回初始界面)
| swich(conf)#line con 0 | |
| swich(conf-line)#exec-timeout 0 0 |
3、防止配置命令被打断(启用显示同步)
| swich(conf)#line con 0 | |
| swich(conf-line)#logging synchronous |
4、禁用DNS查找
| swich(conf)#no ip domain-lookup |
5、配置arp
| Router#arp -a | 显示ARP缓存表 |
| Router#arp –d 192.168.1.2 | 删除arp缓存表特定arp条目 |
| Router#arp –s 192.168.1.2 00-83-56-C0-00-01 | 静态绑定arp地址 |
| Router#show arp | 显示路由器的ARP缓存表 |
| Switch# show mac-address-table | 显示交换机arp缓存表 |
| Switch# clear arp-cache | 清除交换机或路由器arp表 |
| 在网关路由器上绑定主机的IP和MAC地址 | |
| Router#(config-if)# arp 1.1.1.1 22.22.22.22 arpa f0/1 | 绑定IP:1.1.1.1 MAC:22.22.22.22 到f0/1端口 |
6、静态路由,默认路由
| Router(config)# ip route 目的网络地址段 255.255.255.0 下一跳地址 | 静态路由 |
| Router(config)# ip route 0.0.0.0 0.0.0.0 下一跳地址 | 默认路由 |
7、telenet远程登录设置
| Router(config)#line vty 0 4 | |
| Router(config-line)#password 密码 | |
| Router(config-line)#login | |
| Router(config)#access-list acl表号 permit ip地址 | 创建允许访问ip的acl规则 |
| Router(config)#line vty 0 4 | |
| Router(config-line)#access-class acl表号 in | 仅该acl规则允许的ip可访问 |
8、配置DHCP服务
| Router (cofig)# ip dhcp pool 名字 | 定义地址池 |
| Router(dhcp-config)# network 192.168.1.0 255.255.255.0 | 动态分配IP地址段 |
| Router(dhcp-config)# default-router 192.168.1.254 | 设定网关地址 |
| Router(dhcp-config)# dns-server 192.168.1.253 | 为客户端配置DNS地址 |
| Router(dhcp-config)# lease 3 | 设定地址租期,假设为3天 |
| Router(dhcp-config)# ip dhcp excluded-address 192.168.1.1 192.168.1.20 | 预留静态分配的IP地址范围 |
9、配置标准acl
| Router(config)#access-list acl表号{1~99} permit或deny 数据包源ip地址 反掩码 | 创建标准ACL |
| Router(config)#access-list acl表号{1~99} permit或deny host ip地址 echo可加可不加 | 创建标准ACL,echo为单向,不能双向通过 |
| Router(config)#access-list acl表号 deny 0.0.0.0 255.255.255.255 | 拒绝所有流量通过 |
| Router(config)#access-list acl表号 deny any | 拒绝所有流量通过 |
| Router(config)#no access-list acl表号 | 删除建立的acl |
| 将acl应用于接口 | |
| Router(config)#interface f1/0 | |
| Router(config-if)#ip access-group acl表号 in或out(入站或出站接口) | |
| Router#show access-lists | 查看acl配置 |
| Router#show access-lists acl表号 | 查看某个acl配置 |
10、配置标准命名和扩展命名ACL
(1)创建扩展ACL
| Router(config)#access-list acl表号(100~199) permit或deny 协议类型 源ip 源反码 目标ip 目标反码 lt小于gt大于eq等于neq不等于端口号 |
(2)创建扩展命名ACL
| Router(config)#ip access-list standard或extended(标准名或扩展名) acl名称 | |
| Router(config-std-nac1)#acl规则位置(第一条10,第二条20,叠加10) permit或deny 数据包源ip地址 源反掩码 | |
| Router(config-std-nac1)#permit any | |
| Router(config-std-nac1)#exit | |
| Router(config)#int f1/0 | |
| 应用acl | |
| Router(config-if)#ip access-group acl名称 in或out |
(3)删除已建立的命名acl
| Router(config)#no IP acl表号 standard或extended(标准名或扩展名) acl名称 |
11、NAT转换
(1)静态NAT配置
| 启用nat | |
| Router(config)#ip nat inside source static 内部ip 外部ip [extendable多次转,可选参数] | |
| Router(config)# int f0/0 | |
| Router(config-if)# ip nat inside | |
| Router(config)# int f1/0 | |
| Router(config-if)# ip nat outside | |
| NAT端口映射 | |
| Router(config)# ip nat inside source static 内网ip UDP/TCP协议号 外网ip UDP/TCP协议号 [extendable多次转,可选参数] |
(2)动态NAT配置
| 定义内部网络中允许访问外部网络的访问控制列表 | |
| Router(config)#access-list acl表号 permit或deny ip网段 反掩码 | |
| 定义合法IP地址池 | |
| Router(config)# ip nat pool 转换后地址池名称 起始ip 终止ip netmask 子网掩码 [type rotary地址池循环使用,可选参数] |
(3)网络地址转换
| Router(config)# ip nat inside source list acl表号(ip网段) pool 转换后地址池名称 [overload地址复用,用于PAT,可选参数] | |
| 如果有多个地址池,可以一一添加,以增加合法地址池的数量范围 | |
| Router(config)# ip nat inside source list acl表号(ip网段) pool 转换后地址池名称1 | |
| Router(config)# ip nat inside source list acl表号(ip网段) pool 转换后地址池名称2 |
12、配置PAT(多路复用)
(1)使用外部全局地址
| 定义内部网络中允许访问外部网络的访问控制列表 | |
| Router(config)# access-list acl表号 permit或deny ip网段 反掩码 | |
| 定义合法的IP地址池 | |
| Router(config)# ip nat pool 地址池名称 起始ip 终止ip netmask 子网掩码 | |
| 设置复用动态IP地址转换 | |
| Router(config)# ip nat inside source list acl表号 pool 地址池名称 [overload地址复用,用于PAT,可选参数] |
(2)复用路由器外部接口地址
| 定义内部访问控制列表 | |
| Router(config)# access-list acl表号 permit或deny ip网段 反掩码 | |
| 设置复用动态IP地址转换 | |
| Router(config)# ip nat inside source list acl表号 int f 0/0 overload | |
| Router#show ip nat translations | 查看pat转换情况 |
| Router#show ip nat translations verbose | 查看pat转换情况,显示更多信息 |
13、RIP的配置
| Router(config)# router rip | 启动 RIP 进程 |
| Router(config-router)# network 邻近网络段 | 通告网络 |
| Router#show ip route | 查看路由表 |
| Router#show ip protocols | 查看路由协议配置 |
14、RIP v2的配置
| Router(config)# router rip | |
| Router(config-router)#version 2 | 启用rip版本2 |
| Router(config-router)#no auto-summary | 关闭路由汇总功能 |
| Router(config-router)# network 邻近网络段 | 通告网络 |
| Router#show ip route | 查看路由表 |
| Router#show ip protocols | 查看路由协议配置 |
15、OSPF的配置
(1)OSPF基本配置
| Router(config)# router ospf 进程号(1~65535) | 启动 OSPF 进程 |
| Router(config-router)# network 邻近网络段 反掩码 area 区域号 | 通告网络及其所在的区域 |
| Router(config-if)ip ospf priority 优先级(默认1,范围0~255,设置为0不参与DR与BDR的选举) | 修改接口优先级 |
| Router(config-if)ip ospf cost cost值(1~65535) | 修改路径成本cost值 |
| Router#display ospf 进程号 perr | 查看OSPF邻居的信息 |
| Router#display ospf 进程号 interface | 查看OSPF接口的信息 |
| Router#display ospf 进程号 routing | 查看OSPF路由表的信息 |
| Router#display ospf 进程号 lsdb | 查看OSPF的LSDB信息 |
| Router#display ospf 进程号 brief | 查看OSPF的概要信息 |
| Router#display ospf 进程号 error | 查看ospf错误信息 |
| Router#show ip ospf neighbor | 查看邻居表及其状态 |
| Router#show ip ospf | 查看OSPF的配置 |
| Router#show ip ospf interface type number | 查看ospf接口数据结构 |
(2)配置末梢区域
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)# area 区域号 stub |
(3)配置完全末梢区域
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)# area 区域号 stub no-summary | |
| Router#show ip ospf database asbr-summary | 查看asbr汇总lsa信息 |
| Router#show ip ospf database external | 查看as外部lsa信息 |
(4)配置路由重发
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)#redistribute rip metric 重发度量值 subnets | |
| Router(config)# router rip | |
| Router(config-router)#redistribute ospf 进程号 metric 重发度量值 |
(5)重发静态路由
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)#redistribute static metric 重发度量值 subnets metric-type 重发路由类型(1或2,1即E1,2即E2) |
(6)重发默认路由
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)#default-information originate metric 重发度量值 subnets metric-type 重发路由类型(1或2,1即E1,2即E2) |
(7)重发直连路由
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)#redistribute connected subnets |
(8)NSSA区域
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)# area 区域号 nssa no-summary(可选参数,阻止lsa3,4) |
(9)区域间路由汇总
| Router(config-router)# area 区域号 range 汇总后网段地址 子网掩码 |
(10)外部路由汇总
| Router(config-router)#summary-address 汇总后网段地址 子网掩码 |
16、虚链路配置
| Router(config)# router ospf 进程号(1~65535) | |
| Router(config-router)# area 区域号 virtual-link 要建立虚链路的对方ip地址 | |
| 查看虚链路状态 | |
| Router#show ip ospf virtual-links |
17、配置CBWFQ,实现网络拥堵时保证最小带宽
(1)定义数据的分类策略
| Router(config)# access-list 101 permit udp host 10.10.10.10 host 10.10.10.20 | |
| Router(config)# access-list 102 permit udp host 10.10.10.10 host 10.10.10.20 | |
| Router(config)# class-map match-all 类名1 | |
| Router(config-cmap)# match access-group 101 | |
| Router(config-cmap)# exit | |
| Router(config)# class-map match-all 类名2 | |
| Router(config-cmap)# match access-group 102 | |
| Router(config-cmap)# exit |
(2)为每类数据定义其处理的策略
| Router(config)# policy-map 策略名 | |
| Router(config-pmap)# class 类名1 | |
| Router(config-pmap-c)# bandwidth 3000 | |
| Router(config-pmap-c)# queue-limit 30 | |
| Router(config-pmap-c)# exit | |
| Router(config-pmap)# class 类名2 | |
| Router(config-pmap-c)# bandwidth 2000 | |
| Router(config-pmap-c)# exit | |
| Router(config-pmap)# class class-default | 配置其他默认类流量 |
| Router(config-pmap-c)#fair-queue | 启用公平队列 |
| Router(config-pmap-c)# exit | |
| 将所定义的策略应用到接口上 | |
| Router(config)# interface e1/1 | |
| Router(config-if)# service-policy output 策略名 |
结语
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/199849.html原文链接:https://javaforall.net
