文档库 最新最全的文档下载
当前位置:文档库 › Cisco IP nat 常用命令及原理详解

Cisco IP nat 常用命令及原理详解

Cisco IP nat 常用命令及原理详解
Cisco IP nat 常用命令及原理详解

Cisco IP nat常用命令及原理详解

ipnat

语法:

ipnat {inside | outside}

noipnat {inside | outside}

本命令用于设置应用NAT的内网和外网的接口。使用no 选项可使接口不再应用NAT。

参数:

inside:表示该接口连接内部网络。

outside:表示该接口连接外部网络。

缺省值:接口上没有应用NAT。

命令模式:接口配置模式。

说明:数据包只有在outside 接口和inside 接口之间路由时,并且符合一定规则的,才会进行NAT 转换。所以实现NAT的路由器必须配置至少一个outside 接口和一个inside 接口,也可配置多个。

范例:

cisco(config)#interfacef0/0

cisco(config-if)#ipaddress 192.168.10.1 255.255.255.0

cisco(config-if)#ipnat inside

cisco(config-if)#noshutdown

cisco(config-if)#interfacef0/1

cisco(config-if)#ipaddress 200.19.12.17 255.255.255.0

cisco(config-if)#ipnat outside

cisco(config-if)#noshutdown

本例路由器的fastethernet 0/0 连接的是内网,被定义为inside 接口,fastethernet 0/1 连接的是外网,被定义为outside 接口。

相关命令:

showipnat statistics 查看NAT统计数据和规则,包括inside和outside接口

ipnat inside destination

语法:

ipnat inside destination list access-list-number pool pool-name

noipnat inside destination list access-list-number pool pool-name

启用NAT内部目标地址转换。使用no 选项可关闭NAT内部目标地址转换。

参数:

access-list-number:访问控制列表的表号。它指定由哪个访问控制列表来定义目标地址的规则。

pool-name:IP地址池名字。该地址池定义了用于NAT转换的内部本地地址。

缺省值:没有启用NAT内部目标地址转换。

命令模式:全局配置模式。

说明:NAT内部目标地址转换可用于实现TCP负载均衡,你可以用一台虚拟主机代替多台实际主机接收用户的TCP请求,由NAT把这些请求轮流映射到各个实际主机上,达到负载分流的目的。

配置TCP负载均衡时,访问控制列表定义的是虚拟主机的地址,IP地址池中定义的是各台实际主机的地址。

范例:

cisco(config)#ipnat pool np 192.168.1.1 192.168.1.3 netmask 255.255.255.0 type rotary

cisco(config)#access-list1 permit 60.8.1.1 0.0.0.0

cisco(config)#ipnat inside destination list 1 pool np

本例定义了一个TCP负载均衡,虚拟主机地址为60.8.1.1,由access-list 1定义,实际主机地址为192.168.1.1~192.168.1.3,由地址池np定义。

相关命令:

ipnat pool 创建一个NAT地址池

access-list 定义访问控制列表

ipnat inside source list

语法:

ipnat inside source list access-list-number {pool pool-name | interfaceinterface-id} [overload]

noipnat inside source list access-list-number

启用内部源地址转换的动态NAT。使用no 选项可关闭该动态NAT。

参数:

access-list-number:访问控制列表的表号。它指定由哪个访问控制列表来定义源地址的规则。

pool-name:IP地址池名字。该地址池定义了用于NAT转换的内部全局地址。

interface-id:接口号。指定用该接口的IP地址作为内部全局地址。

overload:启用端口复用,使每个全局地址可以和多个本地地址建立映射,在多对一的nat转换中才会使用overload,以使多个地址同时通过一个nat地址来通信,如果不加此命令则一个时间片内只有一条内部地址可以通信。此命令在nat地址下加子接口。

缺省值:没有启用NAT。

命令模式:全局配置模式。

说明:在锐捷路由器中,端口复用默认是启用的,有没有overload关键字都是一样的,保留这个参数是为了和Cisco的命令兼容。

配置内部源地址的动态NAT时,访问控制列表定义的是内部本地地址的规则,IP地址池中定义的是内部全局地址,它通常是注册的合法地址。

范例1:

cisco(config)#ipnat pool np 200.10.10.1 200.10.10.9 netmask 255.255.255.0

cisco(config)#access-list1 permit 192.168.1.0 0.0.0.255

cisco(config)#access-list1 permit 172.16.0.0 0.0.255.255

cisco(config)#ipnat inside source list 1 pool np overload

本例定义了一个内部源地址动态NAT,内部本地地址为192.168.1.*和172.16.*.*的格式,由access-list 1定义,只有这两种地址才会进行NAT转换。内部全局地址为200.10.10.1~200.10.10.9,共9个地址,由地址池np定义。每个全局地址都可以和多个本地地址建立映射,用端口号区分各个映射。

范例2:

Ruijie(config)#access-list1 permit 192.168.0.0 0.0.255.255

Ruijie(config)#ipnat inside source list 1 interface s1/0 overload

本例定义了一个内部源地址动态NAT,内部本地地址为192.168.*.*的格式,由access-list 1定义。内部全局地址为Serial 1/0 的IP地址。所有本地地址都会映射为这一个IP地址,用端口号区分各个映射。

相关命令:

ipnat pool 创建一个NAT地址池

access-list 定义访问控制列表

ipnat inside source static

语法:

ipnat inside source static local-address global-address [permit-inside]

noipnat inside source static local-address global-address [permit-inside]

ipnat inside source static protocol local-address local-port global-addressglobal-port [permit-inside]

noipnat inside source static protocol local-address local-port global-addressglobal-port [permit-inside]

启用内部源地址转换的静态NAT。使用no 选项可删除该静态NAT。

参数:

local-address:内部本地地址。是主机在网络内部的IP地址,一般是未注册的私有地址。

global-address:内部全局地址。是内部主机在外部网络表现出的地址,一般是注册的合法地址。

protocol:协议。可以是TCP 或UDP。

local-port:本地地址的服务端口号。

global-port:全局地址的服务端口号,它可以和local-port不同。

permit-inside:允许内部用户使用全局地址访问本地主机。

缺省值:没有启用NAT。

命令模式:全局配置模式。

说明:静态NAT主要用于那些对需要对外部用户开放的服务,如Web服务器等,它可以把本地地址映射为指定的全局地址。

第一种格式实现的是一对一的NAT映射。第二种格式可实现一对多的映射,即一个全局地址可映射多个内部地址,用端口号区分各个映射。

范例1:

cisco(config)#ipnat inside source static 192.168.1.6 200.10.10.2

本例定义了一个内部源地址静态NAT,内部本地地址为192.168.1.6,内部全局地址为200.10.10.2。外网用户只能用200.10.10.2访问这台主机,内网用户只能用192.168.1.6访问这台主机,如果加上permit-inside 关键字,内网用户也能用200.10.10.2访问。

范例2:

cisco(config)#ipnat inside source static tcp 192.168.1.6 80 200.10.10.2 80

cisco(config)#ipnat inside source static tcp 192.168.1.8 80 200.10.10.2 8080

本例定义了两个内部源地址静态NAT,两个服务都是Web服务,内网用户可以用http://192.168.1.6和http://192.168.1.8访问这两个网站,外网用户需要用http://200.10.10.2和http://200.10.10.2:8080访问这两个网站。

ipnat outside source list

语法:

ipnat outside source list access-list-number pool pool-name

noipnat outside source list access-list-number

启用外部源地址转换的动态NAT。使用no 选项可关闭该动态NAT。

参数:

access-list-number:访问控制列表的表号。它指定由哪个访问控制列表来定义源地址的规则。

pool-name:IP地址池名字。该地址池定义了用于NAT转换的外部本地地址。

缺省值:没有启用NAT。

命令模式:全局配置模式。

说明:外部源地址NAT用于有地址重叠的情况。当两个需要互访的私有网络使用了同样的IP地址,或一个私有网络和公有网络使用了同样的IP地址,则产生地址重叠。这时需要把外部全局地址映射为一个本地没有的外部本地地址才能实现互访。

配置外部源地址的动态NAT时,访问控制列表定义的是外部全局地址的格式,IP地址池中定义的是外部本地地址,它应该和内部本地地址没有重叠。

范例:

cisco(config)#ipnat pool outp 172.18.1.1 172.18.1.254 netmask 255.255.255.0

cisco(config)#access-list1 permit 192.168.1.0 0.0.0.255

cisco(config)#ipnat outside source list 1 pool outp

本例定义了一个外部源地址动态NAT,外部全局地址为192.168.1.*的格式,由access-list 1定义,它和内部地址有重叠。外部本地地址为172.18.1.1~172.18.1.254,由地址池outp定义,这组地址是内部网络中不使用的可路由地址。当从外部来的数据包,源地址是192.168.1.*的格式时,用172.18.1.*的地址替换,再进入内部网络。

相关命令:

ipnat pool 创建一个NAT地址池

access-list 定义访问控制列表

ipnat outside source static

语法:

ipnat outside source static global-address local-address

noipnat outside source static global-address local-address

ipnat outside source static protocol global-address global-port local-addresslocal-port

noipnat outside source static protocol global-address global-port local-addresslocal-port

启用外部源地址转换的静态NAT。使用no 选项可删除该静态NAT。

参数:

global-address:外部全局地址。是外部主机在外部网络的地址。

local-address:外部本地地址。是外部主机在网络内部表现的IP地址。

protocol:协议。可以是TCP 或UDP。

global-port:外部全局地址的服务端口号。

local-port:外部本地地址的服务端口号,它可以和global-port不同。

缺省值:没有启用NAT。

命令模式:全局配置模式。

说明:外部源地址静态NAT用于有地址重叠的情况。第一种格式实现的是一对一的NAT映射。第二种格式可实现一对多的映射,即一个本地地址可映射多个全局地址,用端口号区分各个映射。

范例:

Ruijie(config)#ipnat outside source static 192.168.1.1 172.18.1.6

本例定义了一个外部源地址静态NAT,外部全局地址为192.168.1.1,外部本地地址为172.18.1.6。当从外部来的数据包,源地址是192.168.1.1时,用172.18.1.6的地址替换,再进入内部网络。

ipnat pool

语法:

ipnat pool pool-name start-address end-address {netmasksubnet-mask|prefix-lengthprefix-length} [type rotary]

ipnat pool pool-name {netmasksubnet-mask|prefix-length prefix-length} [typerotary]

noipnat pool pool-name

定义一个IP地址池。使用no 选项可删除地址池。

参数:

pool-name:地址池名字。在动态NAT配置命令中用这个名字引用地址池。

start-address:地址块起始IP地址。

end-address:地址块结束IP地址。

subnet-mask:地址块的子网掩码。

prefix-length:使用长度表示的掩码,是掩码的简化写法。

typerotary:表示定义为轮转型地址池,每个地址分配的概率相等。锐捷路由器默认的地址池类型就是轮转型,所以有没有rotary 关键字都一样,保留此关键字是为了和Cisco 命令兼容。

缺省值:没有定义地址池。

命令模式:全局配置模式。

说明:第一种格式定义了一个包含地址块的地址池。第二种格式定义的是一个空地址池,之后可以用address 命令向其中添加一个或多个地址块。

范例1:

cisco(config)#ipnat pool np1 200.10.10.1 200.10.10.9 netmask 255.255.255.0

本例定义了一个名为np 的地址池,地址范围是200.10.10.1~200.10.10.9,掩码是255.255.255.0。

范例2:

cisco(config)#ipnat pool np2 200.10.10.1 200.10.10.9 prefix-length 24

本例定义的地址池和例1完全相同,只是掩码用的是长度写法。

范例3:

cisco(config)#ipnat pool np3 netmask 255.255.255.0

cisco(config)#address200.10.10.1 200.10.10.9

cisco(config)#address201.15.8.17 201.15.8.25

本例先定义了一个空地址池,再用addess命令向其中加入了两个地址块。

相关命令:

addess向NAT地址池中添加地址

ipnat translation

语法:

ipnat translation 参数名参数值

noipnat translation 参数名

配置NAT转换记录的超时时间和转换记录条数限制。使用no 选项可恢复缺省配置。

该命令有多种用法:

ipnat translation dns-timeout seconds

定义DNS转换记录的超时时间,单位为秒。缺省值为60 秒。

ipnat translation finrst-timeout seconds

定义TCP连接FIN及RESET后转换记录的超时时间,单位为秒。缺省值为60 秒。

ipnat translation icmp-timeout seconds

定义ICMP转换记录的超时时间,单位为秒。缺省值为60 秒。

ipnat translation syn-timeout seconds

定义TCP发出syn后没有收到应答的超时时间,单位为秒。缺省值为60 秒。

ipnat translation tcp-timeout seconds

定义TCP连接转换记录的超时时间,单位为秒。缺省值为 1 天。

ipnat translation udp-timeout seconds

定义UDP连接转换记录的超时时间,单位为秒。缺省值为300 秒。

ipnat translation max-entries number

定义NAT转换记录的最大个数。缺省为30000 条。

ipnat translation pre-user user-ip [number]

指定内网某个用户所允许的最大转换记录数。user-ip时用户的IP地址,如果为0.0.0.0,则内网所有用户使用相同的条数限制。具体IP的配置优先级高于0.0.0.0 的配置。如果user-ip后没有给出具体数值,则为300条。缺省情况下,不做限制。

命令模式:全局配置模式。

范例1:

cisco(config)#ipnat translation pre-user 0.0.0.0 500

cisco(config)#ipnat translation pre-user 192.168.5.112 1000

本例对内网用户转换记录条数做了限制,用户192.168.5.112限制为1000条,其他用户统一限制为500条。

范例2:

cisco(config)#ipnat translation icmp-timeout 30

本例把ICMP的NAT转换记录的超时时间设置为30秒。

使用ipnat outside source list 命令(动态NAT)而不是ipnat outside source static 命令(静态NAT)的主要区别在于,在(为NAT配置的)路由器检验数据包的转换标准之前,在转换表中没有条目。在上例中,SA为172.16.88.1的数据包(进入Router 2514x的外部接口)符合访问列表1,即ipnat outside source list 命令使用的标准。因此,在内部网络的包可以与Router 2514w的loopback0接口通信之前,必须从外部网络始发数据包。

本例中需要注意两点:

第一,当数据包从外部传输到内部时,先进行转换,然后检查目的地的路由表。当数据包从内部传输到外部时,先检查目的地的路由表,然后进行转换。

第二,使用上述每条命令时,记录IP数据包的哪个部分被转换很重要。下表给出了一个纲要:

以上表明有多种方法可以转换包。根据您的具体要求,您应该确定如何定义NAT接口(内部或外部),以及路由表在转换之前或之后应该包含哪些路由。一定要记住,包被转换的部分取决于该包传输的方向以及您如何配置NAT。

思科交换机命令大全

思科交换机命令大全集团文件发布号:(9816-UATWW-MWUB-WUNN-INNUL-DQQTY-

思科交换机常用命令大全 1.1 用户模式与特权模式 用户模式:可以使用一些基本的查询命令 特权模式:可以对交换机进行相关的配置 进入特权模式命令:Switch>enable 退出特权模式命令:Switch#exit 启用命令查询: 时间设置:Switch#clock set 时间(自选参数,参数必须符合交换机要求) 显示信息命令:Switch#show 可选参数 注意:可以用TAB键补齐命令,自选参数为用户自定义参数,可选参数为交换机设定参数 查看交换机配置: Switch#show running-config 保存交换机配置:Switch#copy running-config startup-config Switch#wr

查看端口信息:Switch#show interface 查看MAC地址表:Switch#show mac-address-table 查看交换机CPU的状态信息:Switch#show processes 1.2 全局配置模式 进入全局配置模式:Switch#configure terminal 主机名修改:Switch(config)#hostname 主机名(自选参数) 特权模式进入密码: Switch(config)#enable secret 密码(自选参数) 取消特权模式密码:Switch(config)#no enable secret 取消主机名设置: Switch(config)#no hostname 退出配置模式: Switch(config)#exit 需要特别注意的是在配置模式中无法使用show命令,如果要使用 的话show前必须加do和空格,例如:do show * 指定根交换机命令:Switch(config)#spanning-tree vlan 自选参数(VLAN号) root primary 例如: Switch(config)#spanning-tree vlan 1 root primary

思科交换机-常用命令及配置

思科交换机-常用命令及配置 switch> 用户模式 1:进入特权模式enable switch> enable switch# 2:进入全局配置模式configure terminal switch> enable switch#configure terminal switch(conf)# 3:交换机命名hostname name 以cisco001 为例 switch> enable switch#c onfigure terminal switch(conf)#hostname cisco001 cisco001(conf)# 4:配置使能口令(未加密)enable password cisco 以cisco 为例switch> enable switch#configure terminal cisco001(conf)# enable password cisco 5:配置使能密码(加密)enable secret ciscolab 以cicsolab 为例switch> enable switch#configure terminal switch(conf)# enable secret ciscolab

6:设置虚拟局域网vlan 1 interface vlan 1 switch> enable switch#configure terminal switch(conf)# interface vlan 1 switch(conf)# ip address 192.168.1.1 255.255.255.0 配置交换机端口ip 和子网掩码 switch (conf-if)#no shut 激活端口 switch (conf-if)#exit switch (conf)#ip default-gateway 192.168.254 设置网关地址 7:进入交换机某一端口interface fastehernet 0/17 以17 端口为例 switch> enable switch#configure terminal switch(conf)# interface fastehernet 0/17 switch(conf-if)# 8:查看命令show switch> enable switch# show version 察看系统中的所有版本信息 show interface vlan 1 查看交换机有关ip 协议的配置信息 show running-configure 查看交换机当前起作用的配置信息 show interface fastethernet 0/1 察看交换机1 接口具体配置和统计信息 show mac-address-table 查看mac 地址表

思科交换机命令大全

思科交换机常用命令大全 1.1 用户模式与特权模式 用户模式:可以使用一些基本的查询命令 特权模式:可以对交换机进行相关的配置 进入特权模式命令:Switch>enable 退出特权模式命令:Switch#exit 启用命令查询:? 时间设置:Switch#clock set 时间(自选参数,参数必须符合交换机要求) 显示信息命令:Switch#show 可选参数 注意:可以用TAB键补齐命令,自选参数为用户自定义参数,可选参数为交换机设定参数 查看交换机配置: Switch#show running-config 保存交换机配置:Switch#copy running-config startup-config Switch#wr 查看端口信息:Switch#show interface 查看MAC地址表:Switch#show mac-address-table 查看交换机CPU的状态信息:Switch#show processes 1.2 全局配置模式 进入全局配置模式:Switch#configure terminal

主机名修改:Switch(config)#hostname 主机名(自选参数) 特权模式进入密码: Switch(config)#enable secret 密码(自选参数) 取消特权模式密码:Switch(config)#no enable secret 取消主机名设置: Switch(config)#no hostname 退出配置模式: Switch(config)#exit 需要特别注意的是在配置模式中无法使用show命令,如果要使用 的话show前必须加do和空格,例如:do show * 指定根交换机命令:Switch(config)#spanning-tree vlan 自选参数(VLAN号)root primary 例如: Switch(config)#spanning-tree vlan 1 root primary 需要注意的是:设置根交换机是基于VLAN的 关闭生成树协议命令:Switch(config)#no spanning-tree vlan 自选参数(VLAN 号) 例如: Switch(config)#no spanning-tree vlan 1 1.3 接口配置模式 进入接口配置模式:Switch(config)#interface 端口名称(可选参数) 启用端口:Switch(config-if)#no shutdown 停用端口:Switch(config-if)#shutdown 进入同种类型多端口配置:Switch(config)# interface range fastethernet 0/1-5 进入不同类型多端口配置:Switch(config)#interface range fastethernet 0/1-5,gigabitethernet 0/1-2

思科交换机路由器命令大全

思科交换机路由器命令 大全 YUKI was compiled on the morning of December 16, 2020

1. 交换机支持的命令:交换机基本状态: 交换机口令设置: switch>enable ;进入特权模式switch#config terminal ;进入全局配置模式 switch(config)#hostname ;设置交换机的主机名 switch(config)#enable secret xxx ;设置特权加密口 令switch(config)#enable password xxa ;设置特权非 密口令switch(config)#line console 0 ;进入控制台 口switch(config-line)#line vty 0 4 ;进入虚拟终端 switch(config-line)#login ;允许登录 switch(config-line)#password xx ;设置登录口令 xxswitch#exit ;返回命令 交换机VLAN设置:

switch(vlan)#vlan 2 ;建VLAN 2switch(vlan)#no vlan 2 ;删vlan 2switch(config)#int f0/1 ;进入端 口1switch(config-if)#switchport access vlan 2 ; 当前端口加入vlan 2switch(config-if)#switchport mode trunk ;设置为干线switch(config- if)#switchport trunk allowed vlan 1,2 ;设置允许 的vlanswitch(config-if)#switchport trunk encap dot1q ;设置vlan 中继switch(config)#vtp domain ;设置发vtp域名switch(config)#vtp password ;设置发vtp密码switch(config)#vtp mode server ;设置发vtp模式switch(config)#vtp mode client ;设置发vtp模式 交换机设置IP地址: 交换机显示命令:

CISCO命令全集

CISCO命令全集-思科命令汇总 视图模式介绍: 普通视图router> 特权视图router# /在普通模式下输入enable 全局视图router(config)# /在特权模式下输入config t 接口视图router(config-if)# /在全局模式下输入int 接口名称例如int s0或int e0 路由协议视图router(config-route)# /在全局模式下输入router 动态路由协议名称 1、基本配置: router>enable /进入特权模式 router#conf t /进入全局配置模式 router(config)# hostname xxx /设置设备名称就好像给我们的计算机起个名字 router(config)#enable password /设置特权口令 router(config)#no ip domain lookup /不允许路由器缺省使用DNS解析命令 router(config)# Service password-encrypt /对所有在路由器上输入的口令进行暗文加密 router(config)#line vty 0 4 /进入设置telnet服务模式 router(config-line)#password xxx /设置telnet的密码 router(config-line)#login /使能可以登陆 router(config)#line con 0 /进入控制口的服务模式 router(config-line)#password xxx /要设置console的密码 router(config-line)#login /使能可以登陆 2、接口配置: router(config)#int s0 /进入接口配置模式serial 0 端口配置(如果是模块化的路由器前面加上槽位编号,例如serial0/0 代表这个路由器的0槽位上的第一个接口) router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码

Cisco IOS 基本命令

Cisco IOS 基本命令一、基本路由器的检验命令 show version show processes show protocols show mem show ip route show startup-config show running-config show flash show interfaces 二、基本路由配置命令 进入:config terminal/memory/network 配置网络时常采用的命令:copy和load 1.标识:hostname 标识名 2.启动标识:banner 启动标识 3.接口:interface 端口号 4.密码:line 0 6 login passwd 口令 enable password/secret 口令 5.接口:

1)配置端口 interface 端口号 clock rate 时钟速率(64000)/* 在串口中配置*/ bandwidth 带宽(缺省56)/* 在串口中配置*/ media-type 介质类型/* 在以太网口上*/ early-token release /* 在令牌环网口上*/ ring-speed 16 /* 在令牌环网口上*/ no shutdown write memory 2)检验端口 show interfaces show controllers 6.配置环境 1)引导方式 boot system flash IOS-filename boot system tftp IOS-filename tftp-address boot system rom 2)配置Register值 config-register 0x2102 7.查看邻居路由 show cdp interface show cdp neighbors [detail]

Cisco交换机常用配置命令

Cisco交换机常用配置命令 CISCO交换机基本配置 switch>ena 進入特权模式 switch#erasenvram 全部清除交换机的所有配置 switch#reload 重新启动交换机(初始提示符为switch> ) ------------------------------------------------------------------------------------ CISCO交换机基本配置:Console端口连接 用户模式hostname>; 特权模式hostname(config)# ; 全局配置模式hostname(config-if)# ; 交换机口令设置: switch>enable ;进入特权模式 switch#config;进入全局配置模式 switch(config)#hostname cisco ;设置交换机的主机名 switch(config)#enable secret csico1 ;设置特权加密口令 switch(config)#enable password csico8 ;设置特权非密口令 switch(config)#line console 0 ;进入控制台口 switch(config-line)#line vty 0 4 ;进入虚拟终端 switch(config-line)#login ;虚拟终端允许登录 switch(config-line)#password csico6 ;设置虚拟终端登录口令csico6 switch#write 保存配置設置 switch#copy running-config startup-config 保存配置設置,與write一樣switch#exit;返回命令 配置终端过一会时间就会由全局配置模式自动改为用户模式,将超时设置为永不超时 switch#conf t switch(config)#line con 0 switch(config-line)#exec-timeout 0 --------------------------------------------------------------------------------- 交换机显示命令: switch#write;保存配置信息 switch#showvtp;查看vtp配置信息 switch#show run ;查看当前配置信息 switch#showvlan;查看vlan配置信息 switch#showvlan name vlan2 switch#show interface ;查看端口信息

思科交换机基本配置(非常详细)

cisco交换机基本配置 1.Cisco IOS简介 Cisco Catalyst系列交换机所使用的操作系统是IOS(Internetwork Operating System,互联网际操作系统)或COS(Catalyst Operating System),其中以IOS使用最为广泛,该操作系统和路由器所使用的操作系统都基于相同的内核和shell。 IOS的优点在于命令体系比较易用。利用操作系统所提供的命令,可实现对交换机的配置和管理。Cisco IOS操作系统具有以下特点: (1)支持通过命令行(Command-Line Interface,简称CLI)或Web界面,来对交换机进行配置和管理。 (2)支持通过交换机的控制端口(Console)或Telnet会话来登录连接访问交换机。 (3)提供有用户模式(user level)和特权模式(privileged level)两种命令执行级别,并提供有全局配置、接口配置、子接口配置和vlan数据库配置等多种级别的配置模式,以允许用户对交换机的资源进行配置。 (4)在用户模式,仅能运行少数的命令,允许查看当前配置信息,但不能对交换机进行配置。特权模式允许运行提供的所有命令。 (5)IOS命令不区分大小写。 (6)在不引起混淆的情况下,支持命令简写。比如enable通常可简约表达为en。 (7)可随时使用?来获得命令行帮助,支持命令行编辑功能,并可将执行过的命令保存下来,供进行历史命令查询。 1.搭建交换机配置环境 在对交换机进行配置之前,首先应登录连接到交换机,这可通过交换机的控制端口(Console)连接或通过Telnet登录来实现。 (1)通过Console口连接交换机 对于首次配置交换机,必须采用该方式。对交换机设置管理IP地址后,就可采用Telnet登录方式来配置交换机。 对于可管理的交换机一般都提供有一个名为Console的控制台端口(或称配置口),该端口采用RJ-45接口,是一个符合EIA/TIA-232异步串行规范的配置口,通过该控制端口,可实现对交换机的本地配置。 交换机一般都随机配送了一根控制线,它的一端是RJ-45水晶头,用于连接交换机的控制台端口,另一端提供了DB-9(针)和DB-25(针)串行接口插头,用于连接PC机的COM1或COM2串行接口。Cisco的控制线两端均是RJ-45水晶头接口,但配送有RJ-45到DB-9和RJ-45到DB-25的转接头。 通过该控制线将交换机与PC机相连,并在PC上运行超级终端仿真程序,即可实现将PC机仿真成交换机的一个终端,从而实现对交换机的访问和配置。 Windows系统一般都默认安装了超级终端程序,对于Windows 2000 Server系统,该程序位于【开始】菜单下【程序】中【附件】的【通讯】群组下面,若没有,可利用控制面板中的【添加/删除程序】来安装。单击【通讯】群组下面的【超级终端】,即可启动超级终端。 首次启动超级终端时,会要求输入所在地区的电话区号,输入后将显示下图所示的连接创建对话框,在【名称】输入框中输入该连接的名称,并选择所使用的示意图标,然后单击确定按钮。 图9-2 超级终端连接创建对话框

思科交换机命令大全 + Cisco IOS 基本命令

思科交换机命令大全 (一) 序号/类别基于ios的交换机命令基于CLI的交换机命令 1.设置主机名/系统名switch(config)# hostname "hostname" switch(enable) set system name name-string 2.设置登录口令switch(config)# enable password level 1 password switch(enable) set password switch(enable) set enalbepass 3.设置远程访问switch(config)# inte***ce vlan 1 switch(config-if)# ip address ip-address netmask switch(config-if)# ip default-gateway ip-address switch(enable) set inte***ce sc0 ip-address netmask broadcast-address switch(enable) set inte***ce sc0 vlan switch(enable) set ip route default gateway 4.启用和浏览CDP信息switch(config-if)# cdp enable switch(config-if)# no cdp enable switch(enable) set cdp {enable|disable} module/port 5.查看Cisco邻接设备的CDP通告switch# show cdp inte***ce [type modle/port] switch# show cdp neighbors [type module/port] [detail] switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail] 6.端口描述switch(config-if)#description escription-string switch(enable)set port name module/number description-string 7.设置端口速度switch(config-if)# speed{10|100|auto} switch(enable) set port speed moudle/number {10|100|auto} switch(enable) set port speed moudle/number {4|16|auto} 8.设置以太网的链路模式switch(config-if)# duplex {auto|full|half} switch(enable) set port duplex module/number {full|half 9.配置静态VLAN switch# vlan database switch(vlan)# vlan vlan-num name vla switch(vlan)# exit switch# configure teriminal switch(config)#inte***ce inte***ce module/number switch(config-if)# switchport mode access switch(config-if)# switchport access vlan vlan-num switch(config-if)# end switch(enable) set vlan vlan-num [name name] switch(enable) set vlan vlan-num mod-num/port-list 10.配置VLAN中继线switch(config)# inte***ce inte***ce mod/port switch(config-if)# switchport mode trunk switch(config-if)#switchport trunk encapsulation {isl|dotlq} switch(config-if)# switchport trunk allowed vlan remove vlan-list switch(config-if)# switchport trunk allowed vlan add vlan-list switch(enable)set trunk module/port [on|off|desirable|auto|nonegotiate] Vlan-range [isl|dotlq|dotl0|lane|negotiate] 11.配置VTP管理域switch# vlan database

思科交换机配置常用命令(精编文档).doc

【最新整理,下载后即可编辑】 Cisco三层交换机配置命令及解释 (2011-07-11 08:54:50) 分类:IT资讯 标签: cisco 杂谈 基本配置 S> enable 进入特权模式 S# configure terminal 进入全局配置模式 S(config)# hostname name 改变交换机名称 S(config)# enable password level level_# password 设置用户口令(level_#=1)或特权口令(level_#=15) S(config)# line console 0 进入控制台接口 S(config-line)# password console_password 接上一条命令,设置控制台口令 S(config)# line vty 0 15 进入虚拟终端 S(config-line)# password telnet_password 接上一条命令,设置Telnet口令 S(config-line)# login 允许Telnet登录 S(config)# enable password|secret privilege_password 配置特权口令(加密或不加密) S(config)# interface ethernet|fastethernet|gigabitethernet slot_#/port_# 进入接口子配置模式 S(config-if)# [no] shutdown 关闭或启用该接口(默认启用) S(config)# ip address IP_address sunbet_mask 指定IP地址 S(config)# ip default-gateway router's_IP_address 指定哪台路由器地址为默认网关 S# show running-config 查看当前的配置 S# copy running-config startup-config 将RAM中的当前配置保存到NVRAM中

思科交换机配置常用命令

Cisco三层交换机配置命令及解释 (2011-07-11 08:54:50) 标签: 分类:IT资讯 cisco 杂谈 基本配置 S> enable 进入特权模式 S# configure terminal 进入全局配置模式 S(config)# hostname name 改变交换机名称 S(config)# enable password level level_# password 设置用户口令(level_#=1)或特权口令(level_#=15) S(config)# line console 0 进入控制台接口 S(config-line)# password console_password 接上一条命令,设置控制台口令 S(config)# line vty 0 15 进入虚拟终端 S(config-line)# password telnet_password 接上一条命令,设置Telnet口令 S(config-line)# login 允许Telnet登录 S(config)# enable password|secret privilege_password 配置特权口令(加密或不加密)S(config)# interface ethernet|fastethernet|gigabitethernet slot_#/port_# 进入接口子配置模式 S(config-if)# [no] shutdown 关闭或启用该接口(默认启用) S(config)# ip address IP_address sunbet_mask 指定IP地址 S(config)# ip default-gateway router's_IP_address 指定哪台路由器地址为默认网关 S# show running-config 查看当前的配置 S# copy running-config startup-config 将RAM中的当前配置保存到NVRAM中 S> show interface [type slot_#/port_#] 查看所有或指定接口的信息 S> show ip 显示交换机的IP配置(只在1900系列上可用) S> show version 查看设备信息 S# show ip interface brief 验证IP配置 S(config-if)# speed 10|100|auto 设置接口速率 S(config-if)# duplex auto|full|half 设置接口双工模式 S> show mac-address-table 查看CAM表 S# clear mac-address-table 清除CAM表中的动态条目 1900(config)# mac-address-table permanent MAC_address type [slot_#/]port_# 在CAM 表中创建静态条目 2950(config)# mac-address-table static MAC_address vlan VLAN_# interface type [slot_#/] port_# 在CAM表中创建静态条目 1900(config)# mac-address-table restricted static MAC_address source_port list_of_allowed_interface 设置静态端口安全措施 1900(config-if)# port secure 启用粘性学习 1900(config-if)# port secure max-mac-count value 设置粘性学习特性能够学到的地址数量(默认132,取值范围是1-132)

CISCO基本命令

端口速度:设置端口速度为:100Mbps/s 半双工模式 Switch# configure terminal Switch(config)# interface range gigabitethernet0/1 - 2 Switch(config-if-range)# speed 100 Switch(config-if)# duplex half 定义端口聚合并存储到NVRAM:定义名称为enet_list的端口组。 Switch# configure terminal Switch(config)# define interface-range enet_list gigabitethernet0/1 - 2 Switch(config)# end Switch# show running-config | include define Switch# define interface-range enet_list gigabitethernet0/1 – 2 Switch# configure terminal Switch(config)# no define interface-range enet_list Switch(config)# end Switch# show run | include define Switch# 设置端口类型: Switch(config-if)media-type auto-select | rj45 | sfp Switch#show interfaces interface-id transceiver properties

CISCO 常用命令解释

视图模式介绍: 普通视图 router> 特权视图 router# /在普通模式下输入enable 全局视图 router(config)# /在特权模式下输入config t 接口视图 router(config-if)# /在全局模式下输入int 接口名称例如int s0或int e0 路由协议视图 router(config-route)# /在全局模式下输入router 动态路由协议名称 1、基本配置: router>enable /进入特权模式 router#conf t /进入全局配置模式 router(config)# hostname xxx /设置设备名称就好像给我们的计算机起个名字 router(config)#enable password /设置特权口令 router(config)#no ip domain lookup /不允许路由器缺省使用DNS解析命令 router(config)# Service password-encrypt /对所有在路由器上输入的口令进行暗文加密router(config)#line vty 0 4 /进入设置telnet服务模式 router(config-line)#password xxx /设置telnet的密码 router(config-line)#login /使能可以登陆 router(config)#line con 0 /进入控制口的服务模式 router(config-line)#password xxx /要设置console的密码 router(config-line)#login /使能可以登陆 2、接口配置: router(config)#int s0 /进入接口配置模式 serial 0 端口配置(如果是模块化的路由器前面加上槽位编号,例如serial0/0 代表这个路由器的0槽位上的第一个接口) router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码router(config-if)#enca hdlc/ppp 捆绑链路协议 hdlc 或者 ppp 思科缺省串口封装的链路层协议是HDLC所以在show run配置的时候接口上的配置没有,如果要封装为别的链路层协议例如PPP/FR/X25就是看到接口下的enca ppp或者enca fr router(config)#int loopback /建立环回口(逻辑接口)模拟不同的本机网段 router(config-if)#ip add xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx /添加ip 地址和掩码给环回口 在物理接口上配置了ip地址后用no shut启用这个物理接口反之可以用shutdown管理性的关闭接口 3、路由配置: (1)静态路由 router(config)#ip route xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx 下一条或自己的接口router(config)#ip route 0.0.0.0 0.0.0.0 s 0 添加缺省路由 (2)动态路由 rip协议 router(config)#router rip /启动rip协议 router(config-router)#network xxx.xxx.xxx.xxx /宣告自己的网段 router(config-router)#version 2 转换为rip 2版本 router(config-router)#no auto-summary /关闭自动汇总功能,rip V2才有作用 router(config-router)# passive-int 接口名 /启动本路由器的那个接口为被动接口

nb思科交换机常用命令

1.在基于IOS的交换机上设置主机名/系统名: switch(config)# hostname hostname 在基于CLI的交换机上设置主机名/系统名: switch(enable) set system name name-string 2.在基于IOS的交换机上设置登录口令: switch(config)# enable password level 1 password 在基于CLI的交换机上设置登录口令: switch(enable) set password switch(enable) set enalbepass 3.在基于IOS的交换机上设置远程访问: switch(config)# interface vlan 1 switch(config-if)# ip address ip-address netmask switch(config-if)# ip default-gateway ip-address 在基于CLI的交换机上设置远程访问: switch(enable) set interface sc0 ip-address netmask broadcast-address switch(enable) set interface sc0 vlan switch(enable) set ip route default gateway 4.在基于IOS的交换机上启用和浏览CDP信息:

switch(config-if)# cdp enable switch(config-if)# no cdp enable 为了查看Cisco邻接设备的CDP通告信息: switch# show cdp interface [type modle/port] switch# show cdp neighbors [type module/port] [detail] 在基于CLI的交换机上启用和浏览CDP信息: switch(enable) set cdp {enable|disable} module/port 为了查看Cisco邻接设备的CDP通告信息: switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail] 5.基于IOS的交换机的端口描述: switch(config-if)# description description-string 基于CLI的交换机的端口描述: switch(enable)set port name module/number description-string 6.在基于IOS的交换机上设置端口速度: switch(config-if)# speed{10|100|auto} 在基于CLI的交换机上设置端口速度: switch(enable) set port speed moudle/number {10|100|auto} switch(enable) set port speed moudle/number {4|16|auto}

Cisco常用命令

路由器实验: router> enable 从用户模式进入特权模式 router# disable or exit 从特权模式退出到用户模式 router# show sessions 查看本机上的TELNET会话router# disconnect 关闭所有的TELNET会话 router# show users 查看本机上的用户 router# erase startupconfig 删除NVRAM中的配置 router# reload 重启路由器 router# config terminal 从用户模式进入特权模式 router(config)# hostname rl 配置用户名为rl router(config)# #banner welcome# 配置开机话语

router# show controllers serial0 查看串口0的物理层信息(主要是查看DTE/DCE)router# show ip interface 查看端口的IP配置信息 router# show hosts 查看主机表 end or ctrl+z 从各种配置模式退到特权模式 rl(config)# no ipdomainlookup 关闭动态域名解析 rl(config)# ipdomainlookup 打开动态域名解析 rl(config)# ipnameserver 202.106.0.20 打开动态域名解析之后便可以指定DNS服务rl(config)# interface serial 0 进入serial 0的接口配置模式 rl(configif)# no shutdown 路由器出厂默认所有端口关闭,使用此命令使它们打开rl(configif)# encapsulation ppp 封装ppp rl(configif)# clockrate 64000 如果是DCE使需要设置时钟速率,如果是DTE使不必设置

思科模拟器基本命令(交换机)

知识归纳 思科模拟器命令: 设置交换机名字为yzh Switch> 进入超级终端控制台 Switch>enable 进入交换机特权模式 Switch# Switch#configure terminal 进入交换机全局配置模式 Switch(configure)#hostname yzh 改变名字为XXX yzh(configure)# 显示改名成功 yzh(configure)#exit 退回上级操作模式,即返回特权模式 yzh# yzh#exit 返回到用户模式 yzh> 参看交换机有关信息 yzh# yzh#configure terminal 进入交换机全局配置模式 yzh#show version 查看交换机的版本信息 yzh#show vlan 查看交换机的VLAN信息,默认情况下所有借口均属于VLAN yzh#show running-config 查看交换机当前生效的配置信息 配置交换机接口f0/2 yzh> yzh>enable yzh# yzh#configure terminal 进入交换机配置模式 yzh(config)#interface fastEthernet 0/2 进入交换机接口fa0/2 yzh(config-if)# 进入接口配置模式 yzh(config-if)#speed 100 设置接口F0/2速率为100M yzh(config-if)#duplex half 配置接口的双工模式是半双工 yzh(config-if)#no shutdown 开启接口,使得处于工作状态,等待转发数据。yzh(config-if)#exit 输入exit返回全局模式 yzh(config)#exit 返回特权模式 yzh# 位于特权模式 yzh#show interfaces fastEthernet 0/2 查看刚才对接口f0/2配置情况 设置交换机Enable特权密码为admin yzh> 进入超级终端控制台 yzh>enable 进入交换机特权模式 yzh#configure terminal 进入交换机配置模式 yzh(config)#enable secret admin 设置Enable密码为admin 注:验证密码自己思考。 查看设备配置信息 yzh#show running-config

相关文档