Cisco 路由配置语句汇总
Cisco 路由配置语句汇总
启动接口,分配IP地址:
router>
router> enable
router#
router# configure terminal
router(config)#
router(config)# interface Type Port
router(config-if)# no shutdown
router(config-if)# ip address IP-Address Subnet-Mask
router(config-if)# ^z
配置RIP路由协议:30秒更新一次
router(config)# router rip
router(config-if)# network Network-Number <--通告标准A,B,C类网-->
router(config-if)# ^z
配置IGRP路由协议:90秒更新一次
router(config)# router igrp AS-Number <-- AS-Number范围1~65535-->
router(config-if)# network Network-Number <--通告标准A,B,C类网-->
router(config-if)# ^z
配置Novell IPX路由协议:Novell RIP 60秒更新一次
router(config)# ipx routing [node address]
router(config)# ipx maximum-paths Paths <--设置负载平衡,范围1~512-->
router(config)# interface Type Port
router(config-if)# ipx network Network-Number [encapsulation encapsulation-type] [secondary] <--通告标准A,B,C类网-->
router(config-if)# ^z
配置DDR:
router(config)# dialer-list Group-Number protocol Protocol-Type permit [list ACL-Number]
router(config)# interface bri 0
router(config-if)# dialer-group Group-Number
router(config-if)# dialer map Protocol-Type Next-Hop-Address name Hostname Telphone-Number
router(config-if)# ^z
配置ISDN:
router(config)# isdn swith-type Swith-Type <--配置ISDN交换机类型,中国使用basic-net3-->
router(config-if)# ^z
__________________
配置Frame Relay:
router(config-if)# encapsulation frame-relay [cisco | ietf ]
router(config-if)# frame-relay lmi-type [ansi | cisco | q933a ]
router(config-if)# bandwidth kilobits
router(config-if)# frame-relay invers-arp [ Protocol ] [dlci ]
<--配置静态Invers ARP表:
router(config)# frame-relay Protocol Protocol-Address DLCI [ Broadcast ] [ ietf | cisco ] [ payload-compress | packet-by-packet ]
-->
<--设置Keepalive间隔:
router(config-if)# keepalive Number
-->
<--为本地接口指定DLCI:
router(config-if)# frame-lelay local-dlci Number
-->
<--子接口配置:
router(config-if)# interface Type Port.Subininterface-Number [ multipoint | point-to-point ]
router(config-subif)# ip unnumbered Interface
router(config-subif)# frame-lelay local-dlci Number
-->
router(config-if)# ^z
配置标准ACL:
router(config)# access-list Access-List-Number [ permit | deny ] source [ source-mask ] <-- Access-List-Number 范围:1~99标准ACL;100~199扩展ACL;800~9标准IPX ACL;900~999扩展IPX ACL;1000~1099 IPX SAP ACL;600~699Apple Talk ACL-->
router(config)# interface Type Port
router(config-if)# ip access-group Access-List-Number [ in | out ]
router(config-if)# ^z
配置扩展ACL:
router(config)# access-list Access-List-Number [ permit | deny ] [ Protocol | P
rotocol-Number ] source source-wildcard [ Source-Port ] destination destination-wildcard [ Destination-Port ] [ established ]
router(config)# interface Type Port
router(config-if)# ip access-group Access-List-Number [ in | out ]
router(config-if)# ^z
配置命名ACL:
router(config)# ip access-list [ standard | extended ] ACL-Name
router(config [ std- | ext- ] nacl)# [ permit | deny ] [ IP-Access-List-Test-Conditions ]
router(config [ std- | ext- ] nacl)# no [ permit | deny ] [ IP-Access-List-Test-Conditions ]
router(config [ std- | ext- ] nacl)# ^z
router(config)# interface Type Port
router(config-if)# ip access-group [ACL-Name | 1~199 ] [ in | out ]
router(config-if)# ^z
配置DCE时钟:
router# show controllers Type Port <--确定DCE接口-->
router(confin-if)# clock rate 000 <--进入DCE接口设置时钟速率-->
router(config-if)# ^z
配置PPP协议:
router(config)# username Name password Set-Password-Here <--验证方建立数据库-->
router(config)# interface Type Port
router(config-if)# encapsulation ppp <--启动PPP协议-->
router(config-if)# ppp outhentication [ chap | chap pap | pap chap | pap ] <--选择PPP认证-->
router(config-if)# ppp pap sent-username Name password Password <--发送验证信息-->
router(config-if)# ^z
PAP单向认证配置实例:
验证方:
router-server(config)# username Client password 12345 <--验证方建立数据库-->
router-server(config)# interface serial 0
router-server(config-if)# encapsulation ppp
router-server(config-if)# ppp authentication pap <--选择使用PAP实现PPP认证-->
router-server(config-if)# ^z
被验证方:
router-client(config-if)# encapsulation ppp
router-client(config-if)# ppp pap sent-username Client password 12345 <--发送验证信息-->
router-client(config-if)# ^z
PAP双向认证配置实例:
路由器 A:
routerA(config)# username B password 12345
routerA(config)# interface serial 0
routerA(config-if)# encapsulation ppp
routerA(config-if)# ppp authentication pap
routerA(config-if)# ppp pap sent-username A password 54321
routerA(config-if)# ^z
路由器 B:
routerB(config)# username A password 54321
routerB(config)# interface serial 1
routerB(config-if)# encapsulation ppp
routerB(config-if)# ppp authentication pap
routerB(config-if)# ppp pap sent-username B password 12345
routerB(config-if)# ^z
CHAP单向认证配置实例:
验证方:
router-server(config)# username router-client password 12345
router-server(config)# interface serial 0
router-server(config-if)# encapsulation ppp
router-server(config-if)# ppp authentication chap
router-server(config-if)# ^z
被验证方:
router-client(config-if)# encapsulation ppp
router-client(config-if)# ppp authentication chap
router-client(config-if)# ppp chap hostname router-client
router-client(config-if)# ppp chap password 12345
router-client(config-if)# ^
z
CHAP双向认证配置实例:
路由器 A:
routerA(config)# username routerB password 12345
routerA(config)# interface serial 0
routerA(config-if)# encapsulation ppp
routerA(config-if)# ppp authentication chap
routerA(config-if)# ppp chap hostname routerA
routerA(config-if)# ppp chap password 54321
routerA(config-if)# ^z
路由器 B:
routerB(config)# username routerA password 54321
routerB(config)# interface serial 1
routerB(config-if)# encapsulation ppp
routerB(config-if)# ppp authentication chap
routerB(config-if)# ppp chap hostname routerB
routerB(config-if)# ppp chap password 12345
routerB(config-if)# ^z
Telnet使用:
routerA# terminal monitor <--可以传回在远端主机执行Debug命令的结果-->
routerA# telnet IP-Address [ Router-Name ] <--Telnet到指定的地址或名字的主机-->
routerB# [ exit | logout ] <--退出Telnet-->
routerB# ++<6>再按 <--挂起Telnet-->
routerA# show sessions <--显示当前所有Telnet的信息,包括Connect-Number -->
routerA# Connect-Number <--返回指定的Telnet连接-->
routerA# disconnect IP-Address [ Router-Name ] <--断开指定地址或名字的主机的连接-->
routerA# show user <--显示Telnet到本机的连接信息-->
routerA# clear line [ 0 | 1 | 2 | 3 | 4 ] <--断开指定Telnet到本机的连接-->
禁止任何Telnet到本机:
router(config)# line vty 0 4
router(config-line)# access-class ACL-Number
router(config)# ^z
设置主机名:
router(config)# hostname Set-Hostname
router(config)# ^z
router(config)# ^z
设置用户模式密码:
router(config)# line console 0
router(config-line)# login
router(config-line)# password Set-Password
router(config-line)# ^z
设置Telnet密码:
router(config)# line vty 0 4
router(config-line)# login
router(config-line)# password Set-Password
router(config-line)# ^z
设置模式密码:
router(config)# enable password Set-Password <--不加密的密码,明码-->
router(config)# enable secret Set-Password <--经过加密的密码-->
router(config)# ^z
给所有密码加密:
router(config)# service password-ancryption Set-Password-Here
router(config)# no service password-ancryption <--取消加密-->
router(config)# ^z
设置登录Banner:
router(config)# banner motd 分隔符 Set-Banner-Information-Here 分隔符 <--前后分隔符一定要一致-->
设置接口的描述信息:
router(config-if)# description Set-Port-Information-Here
router(config)# ^z
CDP的控制:
router(config-if)# cdp enable <--在指定端口启用CDP,缺省-->
router(config-if)# no cdp enable <--在指定端口关闭CDP-->
router(config)# cdp run <--使所有端口启用CDP-->
router(config)# no cdp run <--使所有端口关闭CDP-->
__________________
Ping的使用:
router# ping IP-Address
router# ping <--扩展Ping命令-->
Protocol [ip]:[ Protocol-Type ] <--
选择协议类型-->
Target IP address:IP-Address <--输入测试地址-->
Repeat count [5]: <--选择发送的ICMP包数量-->
Datagram size [100]: <--选择每个包的大小-->
Timeout in seconds [2]: <--设置每个包的超时时间-->
Extended commands [n]:y <--使用扩展Ping命令-->
Sweep range of sizes [n]:
Tracke的使用:
router# trace IP-Address [ Host-Name ]
为Cisco 4000路由器指定媒体类型:
router(config-if)# media-type 10baset <--使AUI(默认)失效,改为使用RJ-45-->
router(config-if)# ^z
更改路由器启动顺序:
router(config)# boot system flash IOS-FileName
router(config)# boot system tftp IOS-FileName TFTP-IP-Address
router(config)# boot system rom
router(config)# ^z
修改寄存器数值:
router(config)# config-register value <--Cisco出厂默认value=0x2102,value范围:0x2100(进入ROM监视器),0x2101(使系统从ROM启动),0x2102~0x210F(使系统从NVRAM启动)。0x1=0x2101,从最小位开始改变-->
在ROM监视器中更改寄存器数值:
> o/r value
路由器密码的恢复:
冷关机,然后再开机并在60秒内按< Ctrl>+进入ROM监视器模式
> o/r 0x2142 <--25xx型路由器--> 或 > confreg 0x2142 <--16xx型路由器-->
router> I
router> n
router> enable
router# copy startup-config running-config
router# configure terminal
router(config)# enable secret New-Password
router(config)# config-register 0x2102
router(config)# ^z
router# copy running-config startup-config
router# reload
__________________
配置名称-主机入口:
router(config)# ip host Set-Name [ TCP-Port-Number ] IP-Address [ IP-Address 2 ]...
router(config)# ^z
定义DNS主机:
router(config)# ip name-server Server-Address [ Server-Address 2 ]...
router(config)# ^z
禁用DNS:
router(config)# no ip domain-lookup
router(config)# ^z
配置水平分割:
router(config-if)# ip split-horizon
router(config-if)# no ip split-horizon
router(config-if)# ^z
配置静态路由:
router(config)# ip route IP-Address Subnet-Mask [ Next-Hop-Address | Local-Out-Port ] [Distace ]
<--Distance范围:1~255,相当于优先权,越小越好。RIP=120;DSPF=110;IGRP=100;EIGRP=90-->
router(config)# ^z
配置缺省路由:
router(config)# ip defoult-network IP-Address <--动态缺省路由-->
router(config)# ip route 0.0.0.0 0.0.0.0 [ Next-Hop-Address | Local-Out-Port ] [Distace ] <--静态缺省路由-->
router(config)# ^z
其它命令:
router# show version
router# show running-config
router# show startup-config
router# show flash
router# show interface [ Type Port ]
router# show buffers
router# show protocol
router# show mem
router# show stacks
router# show processes
router# show cdp entry [ Device-Name ] <--显示指定邻居三层信息-->
router# show cdp neighbors
router# sho
w cdp neighbors detail <---显示所有邻居三层信息->
router# show ip router
router# show ipx router
router# show host
router# show ip protocol
router# show ip interface Type Port
router# show ipx interface Type Port
router# show ipx servers
router# show ipx traffic
router# show access-lists [ ACL-Number ]
router# show isdn status
router# show dialer <--查看ISDN拨号信息-->
router# show isdn active
router# show frame-relay pvc
router# show frame-relay map
router# show frame-relay lmi
router# erase startup-config
router# reload
router# setup
router# copy running-config startup-config
router# copy startup-config running-config
router# copy tftp running-config
router# copy running-config tftp
router# debug ipx routing activity
router# debug ipx sap
router# debug isdn q921
router# debug isdn q931
router# debug dialer
router# debug ip rip
router# clear interface bri [ 0 | 1 | 2 ]
Cisco VPN连接配置实例
在公司的南京办事处与上海办事处之间建立VPN联接。
南京办事处网络设置:
内网IP 10.1.1.0/24
IP 202.102.1.5/24
上海办事处网络设置:
内网IP 10.1.2.0/24
IP 202.102.1.6/24
南京路由器配置
!
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname nanjing
!
enable cisco
!
!
!------以下配置加密--------
crypto isakmp policy 1 生成iskamp policy number 1
encryption des 选择用DES encryption也可用3DES指定三倍DES加密
hash sha 指定使用的散列算法,也可以是md5(二端保持一致)
authentication pre-share
group 1 指定为Diffie-Hellman组,1表示768位,2表示1024位
lifetime 14400 指定安全关联的有效期,不设就为默认值
------以下配置密钥方法-----
crypto isakmp identity address 指定与远程路由器通信时使用isakmp标识
crypto isakmp key 654321 address 202.102.1.6 对远程路由器端口202.102.1.6使用密钥654321
crypto isakmp key 654321 address 192.168.1.2 对远程路由器隧道端口192.168.1.2使用密钥654321
!
------以下定义一个转换集-----
crypto ipsec transform-set tset1 ah-md5-hmac esp-des esp-md5-hmac 可以定义一个或多个集
!
!
-------以下建立加密图------
crypto map cmap1 local-address serial 0 定义加密图cmap1并指定s0为本地地址
crypto map cmap1 1 ipsec-isakmp 用序号1设置加密图
set peer 202.102.1.6 设定目标地址
set peer 192.168.1.2
set transform-set test1 指定转换集
match address 111 指定加密访问列表111中的地址
!
!
process-max-time 200
!
-------以下设置隧道端口------
interface Tunnel0
ip address 192.168.1.1 255.255.255.0
tunnel source 202.102.1.5
tunnel destination 202.102.1.6
crypto map cmap
!
-------以下设置内网口------
interface Ethernet0
ip address 10.1.1.1 255.255.255.0
!
-------以下设置口---
---
interface serial0
ip address 202.102.1.5 255.255.255.0
no ip mroute-cache
no fair-queue
crypto map cmap
!
ip classless
!
-------以下建立访问列表111------
access-list 111 permit ip host 202.102.1.5 host 202.102.1.6
access-list 111 permit ip host 202.102.1.6 host 202.102.1.5
access-list 111 permit ip 10.1.1.0 0.0.0.255 202.102.1.0 0.0.0.255
access-list 111 permit ip 10.1.2.0 0.0.0.255 202.102.1.0 0.0.0.255
access-list 111 permit ip 10.1.1.0 0.0.0.255 10.1.2.0 0.0.0.255
access-list 111 permit ip 10.1.2.0 0.0.0.255 10.1.1.0 0.0.0.255
!
line con 0
line aux 0
line vty 0 4
password cisco
login
!
end
!
上海路由器配置
!
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname shanghai
!
enable cisco
!
!
!------以下配置加密--------
crypto isakmp policy 1 生成iskamp policy number 1
encryption des 选择用DES encryption也可用3DES指定三倍DES加密
hash sha 指定使用的散列算法,也可以是md5(二端保持一致)
authentication pre-share
group 1 指定为Diffie-Hellman组,1表示768位,2表示1024位
lifetime 14400 指定安全关联的有效期,不设就为默认值
------以下配置密钥方法-----
crypto isakmp identity address 指定与远程路由器通信时使用isakmp标识
crypto isakmp key 654321 address 202.102.1.5 对远程路由器端口202.102.1.6使用密钥654321
crypto isakmp key 654321 address 202.102.1.6 对远程路由器端口202.102.1.6使用密钥654321
crypto isakmp key 654321 address 192.168.1.1 对远程路由器隧道端口192.168.1.2使用密钥654321
!
------以下定义一个转换集-----
crypto ipsec transform-set tset1 ah-md5-hmac esp-des esp-md5-hmac 可以定义一个或多个集
!
!
-------以下建立加密图------
crypto map cmap1 local-address serial 0 定义加密图cmap1并指定s0为本地地址
crypto map cmap1 1 ipsec-isakmp 用序号1设置加密图
set peer 202.102.1.5 设定目标地址
set peer 202.102.1.6
set peer 192.168.1.1
set transform-set test1 指定转换集
match address 111 指定加密访问列表111中的地址
!
!
process-max-time 200
!
-------以下设置隧道端口------
interface Tunnel0
ip address 192.168.1.2 255.255.255.0
tunnel source 202.102.1.6
tunnel destination 202.102.1.5
crypto map cmap
!
-------以下设置内网口------
interface Ethernet0
ip address 10.1.2.1 255.255.255.0
!
-------以下设置口------
interface serial0
ip address 202.102.1.6 255.255.255.0
no ip mroute-cache
no fair-queue
crypto map cmap
!
ip classless
!
-------以下建立访问列表111------
access-list 111 permit ip host 202.102.1.5 host 202.102.1.6
access-list 111 permit ip host 202.102.1.6 host 202.102.1.5
access-list 111 permit ip 10.1.1.0 0.0.0.255 202.102.1.0 0.0.0.255
access-list 111 permit ip 10.1.2.0 0.0.0.255 202.102.1.0 0.0.0.
255
access-list 111 permit ip 10.1.1.0 0.0.0.255 10.1.2.0 0.0.0.255
access-list 111 permit ip 10.1.2.0 0.0.0.255 10.1.1.0 0.0.0.255
!
line con 0
line aux 0
line vty 0 4
password cisco
login
!
end
!
vlan 配置思路
在交换机上创建vlan
1.建立一个vtp管理域
×为了在交换机上创建vlan,必须首先建立一个vtp管理域以使它能够核验网络
上当前的vlan
×Catalyst 4000 系列交换机模块只支持802.1q。
×判断硬件是否支持干道,及硬件所支持的干道封装使用:show port
capabilities
首先运行 clear config all
vtp command:
在基于IOS的交换机上配置VTP管理域或加入一个管理域:
switch# vlan database
switch(vlan)# vtp domain domain-name
在基于CLI的交换机上配置VTP管理域:
switch(enable) set vtp [domain domain-name] passwd password
在基于IOS的交换机上配置VTP 模式:
switch# vlan database
switch(vlan)# vtp domain domain-name
switch(vlan)# vtp {sever|cilent|transparent}
switch(vlan)# vtp password password
在基于CLI的交换机上配置VTP 模式:
switch(enable) set vtp [domain domain-name] [mode{
sever|cilent|transparent }][password password]
核验vtp的配置:
show vtp domain
show vtp statistics
在基于IOS的交换机上配置VTP版本:
×VTP版本1是缺省配置
switch# vlan database
switch(vlan)# vtp v2-mode
在基于CLI的交换机上配置VTP版本:
switch(enable) set vtp v2 enable
在基于IOS的交换机上启动VTP剪裁:
switch# vlan database
switch(vlan)# vtp pruning
在基于CLI 的交换机上启动VTP剪裁:
switch(enable) set vtp pruning enable
(set vtp pruneeligible vlan-range)
不起用vtp修剪:
clear vtp pruneeligible vlan-range
核验vtp修剪的配置:
show trunk
2.创建Vlan
在基于IOS的交换机上配置静态VLAN:
switch# vlan database
switch(vlan)# vlan vlan-num name vlan-name
switch(vlan)# exit
switch# configure teriminal
switch(config)# interface interface module/number
switch(config-if)# switchport mode access
switch(config-if)# switchport access vlan vlan-num
switch(config-if)# end
在基于CLI的交换机上配置静态VLAN:
switch(enable) set vlan vlan-num [name name]
switch(enable) set vlan vlan-num mod-num/port-list
核验配置:show vlan
3.配置干道链路
干道是在两台catalyst交换机端口或catalyst交换机与路由器间的一条点对点
链路。
干道链路可以承载多个vlan。
在基于IOS的交换机上配置干道链路
switch(config)# interface interface 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
在基于CLI的交换机上配置干道链路:
switch(enable) set trunk module/po
port
[on|off|desirable|auto|nonegotiate]
Vlan-range
[isl|dotlq|dotl0|lane|negotiate]
如何配置Cisco PIX防火墙 (转载自无限矩阵 作者:verve)
任何企业安全策略的一个主要部分都是实现和维护防火墙,因此防火墙在网络安全的实现当中扮演着重要的角色。防火墙通常位于企业网络的边缘,这使得内部网络与Internet之间或者与其他外部网络互相隔离,并网络互访从而保护企业内部网络。设置防火墙目的都是为了在内部网与外部网之间设立唯一的通道,简化网络的安全管理。
在众多的企业级主流防火墙中,Cisco PIX防火墙是所有同类产品性能最好的一种。Cisco PIX系列防火墙目前有5种型号PIX506,515,520,525,535。其中PIX535是PIX 500系列中最新,功能也是最强大的一款。它可以提供运营商级别的处理能力,适用于大型的ISP等服务提供商。但是PIX特有的OS操作系统,使得大多数管理是通过命令行来实现的,不象其他同类的防火墙通过Web管理界面来进行网络管理,这样会给初学者带来不便。本文将通过实例介绍如何配置Cisco PIX防火墙。
在配置PIX防火墙之前,先来介绍一下防火墙的物理特性。防火墙通常具有至少3个接口,但许多早期的防火墙只具有2个接口;当使用具有3个接口的防火墙时,就至少产生了3个网络,描述如下:
? 内部区域(内网)。 内部区域通常就是指企业内部网络或者是企业内部网络的一部分。它是互连网络的信任区域,即受到了防火墙的保护。
? 外部区域()。 外部区域通常指Internet或者非企业内部网络。它是互连网络中不被信任的区域,当外部区域想要访问内部区域的主机和服务,通过防火墙,就可以实现有的访问。
? 停火区(DMZ)。 停火区是一个隔离的网络,或几个网络。位于停火区中的主机或服务器被称为堡垒主机。一般在停火区内可以放置Web服务器,Mail服务器等。停火区对于外部用户通常是可以访问的,这种方式让外部用户可以访问企业的公开信息,但却不允许他们访问企业内部网络。注意:2个接口的防火墙是没有停火区的。
由于PIX535在企业级别不具有普遍性,因此下面主要说明PIX525在企业网络中的应用。
PIX防火墙提供4种管理访问模式:
2 非模式。 PIX防火墙开机自检后,就是处于这种模式。系统显示为pixfirewall>
2 模式。 输入enable进入模式,可以改变当前配置。显示为pixfirewall#
2 配置模式。 输入configure terminal进入此模式,绝大部分的系统配置都在这里进行。显示为pixfirewall(config)#
2 监视模式。 PIX防火墙在开机或重启过程中,按住Escape键或发送一个“Break”字符,进入监视模式。这
里可以更新操作系统映象和口令恢复。显示为monitor>
配置PIX防火墙有6个基本命令:nameif,interface,ip address,nat,global,route.
这些命令在配置PIX是必须的。以下是配置的基本步骤:
1. 配置防火墙接口的名字,并指定安全级别(nameif)。
Pix525(config)#nameif ethernet0 outside security0
Pix525(config)#nameif ethernet1 inside security100
Pix525(config)#nameif dmz security50
提示:在缺省配置中,以太网0被命名为外部接口(outside),安全级别是0;以太网1被命名为内部接口(inside),安全级别是100.安全级别取值范围为1~99,数字越大安全级别越高。若添加新的接口,语句可以这样写:
Pix525(config)#nameif pix/intf3 security40 (安全级别任取)
2. 配置以太口参数(interface)
Pix525(config)#interface ethernet0 auto(auto选项表明系统自适应网卡类型 )
Pix525(config)#interface ethernet1 100full(100full选项表示100Mbit/s以太网全双工通信 )
Pix525(config)#interface ethernet1 100full shutdown (shutdown选项表示关闭这个接口,若启用接口去掉shutdown )
3. 配置内卡的IP地址(ip address)
Pix525(config)#ip address outside 61.144.51.42 255.255.255.248
Pix525(config)#ip address inside 192.168.0.1 255.255.255.0
很明显,Pix525防火墙在的ip地址是61.144.51.42,内网ip地址是192.168.0.1
4. 指定要进行转换的内部地址(nat)
网络地址翻译(nat)作用是将内网的私有ip转换为的公有ip.Nat命令总是与global命令一起使用,这是因为nat命令可以指定一台主机或一段范围的主机访问,访问时需要利用global所指定的地址池进行对外访问。nat命令配置语法:nat (if_name) nat_id local_ip [netmark]
其中(if_name)表示内网接口名字,例如inside. Nat_id用来标识全局地址池,使它与其相应的global命令相匹配,local_ip表示内网被分配的ip地址。例如0.0.0.0表示内网所有主机可以对外访问。[netmark]表示内网ip地址的子网掩码。
例1.Pix525(config)#nat (inside) 1 0 0
表示启用nat,内网的所有主机都可以访问,用0可以代表0.0.0.0
例2.Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0
表示只有172.16.5.0这个网段内的主机可以访问。
5. 指定外部地址范围(global)
global命令把内网的ip地址翻译成的ip地址或一段地址范围。Global命令的配置语法:global (if_name) nat_id ip_address-ip_address [netmark global_mask]
其中(if_name)表示接口名字,例如outside.。Nat_id用来标识全局地址池,使它与其相应的nat命令相匹配,ip_address-ip_address表示翻译后的单个ip地址或一段ip地址范围。[netmark global_mask]表示全局ip地址的网络掩码。
例1. Pix525(config)#global (outside) 1 61.144.51.42-61.144.51
.48
表示内网的主机通过pix防火墙要访问时,pix防火墙将使用61.144.51.42-61.144.51.48这段ip地址池为要访问的主机分配一个全局ip地址。
例2. Pix525(config)#global (outside) 1 61.144.51.42
表示内网要访问时,pix防火墙将为访问的所有主机统一使用61.144.51.42这个单一ip地址。
例3. Pix525(config)#no global (outside) 1 61.144.51.42
表示删除这个全局表项。
6. 设置指向内网和的静态路由(route)
定义一条静态路由。route命令配置语法:route (if_name) 0 0 gateway_ip [metric]
其中(if_name)表示接口名字,例如inside,outside。Gateway_ip表示网关路由器的ip地址。[metric]表示到gateway_ip的跳数。通常缺省是1。
例1. Pix525(config)#route outside 0 0 61.144.51.168 1
表示一条指向边界路由器(ip地址61.144.51.168)的缺省路由。
例2. Pix525(config)#route inside 10.1.1.0 255.255.255.0 172.16.0.1 1
Pix525(config)#route inside 10.2.0.0 255.255.0.0 172.16.0.1 1
如果内部网络只有一个网段,按照例1那样设置一条缺省路由即可;如果内部存在多个网络,需要配置一条以上的静态路由。上面那条命令表示创建了一条到网络10.1.1.0的静态路由,静态路由的下一条路由器ip地址是172.16.0.1
OK,这6个基本命令若理解了,就可以进入到pix防火墙的一些高级配置了。
A. 配置静态IP地址翻译(static)
如果从发起一个会话,会话的目的地址是一个内网的ip地址,static就把内部地址翻译成一个指定的全局地址,允许这个会话建立。static命令配置语法:static (internal_if_name,external_if_name) outside_ip_address inside_ ip_address 其中internal_if_name表示内部网络接口,安全级别较高。如inside.
external_if_name为外部网络接口,安全级别较低。如outside等。outside_ip_address为正在访问的较低安全级别的接口上的ip地址。inside_ ip_address为内部网络的本地ip地址。
例1. Pix525(config)#static (inside, outside) 61.144.51.62 192.168.0.8
表示ip地址为192.168.0.8的主机,对于通过pix防火墙建立的每个会话,都被翻译成61.144.51.62这个全局地址,也可以理解成static命令创建了内部ip地址192.168.0.8和外部ip地址61.144.51.62之间的静态映射。
例2. Pix525(config)#static (inside, outside) 192.168.0.2 10.0.1.3
例3. Pix525(config)#static (dmz, outside) 211.48.16.2 172.16.10.8
注释同例1。通过以上几个例子说明使用static命令可以让我们为一个特定的内部ip地址设置一个永久的全局ip地址。这样就能够为具有较低安全级别的指定接口创建一个入口,使它们可以进入到具有较高安全级别的指定接口。
B. 管道命令(conduit)
前面讲过使用static命令可以在一个本地ip地址和一个全局ip地址之间创建了一
个静态映射,但从外部到内部接口的连接仍然会被pix防火墙的自适应安全算法(ASA)阻挡,conduit命令用来允许数据流从具有较低安全级别的接口流向具有较高安全级别的接口,例如允许从外部到DMZ或内部接口的入方向的会话。对于向内部接口的连接,static和conduit命令将一起使用,来指定会话的建立。
conduit命令配置语法:
conduit permit | deny global_ip port[-port] protocol foreign_ip [netmask]
permit | deny 允许 | 拒绝访问
global_ip 指的是先前由global或static命令定义的全局ip地址,如果global_ip为0,就用any代替0;如果global_ip是一台主机,就用host命令参数。
port 指的是服务所作用的端口,例如www使用80,smtp使用25等等,我们可以通过服务名称或端口数字来指定端口。
protocol 指的是连接协议,比如:TCP、UDP、ICMP等。
foreign_ip 表示可访问global_ip的外部ip。对于任意主机,可以用any表示。如果foreign_ip是一台主机,就用host命令参数。
例1. Pix525(config)#conduit permit tcp host 192.168.0.8 eq www any
这个例子表示允许任何外部主机对全局地址192.168.0.8的这台主机进行http访问。其中使用eq和一个端口来允许或拒绝对这个端口的访问。Eq ftp 就是指允许或拒绝只对ftp的访问。
例2. Pix525(config)#conduit deny tcp any eq ftp host 61.144.51.
表示不允许外部主机61.144.51.对任何全局地址进行ftp访问。
例3. Pix525(config)#conduit permit icmp any any
表示允许icmp消息向内部和外部通过。
例4. Pix525(config)#static (inside, outside) 61.144.51.62 192.168.0.3
Pix525(config)#conduit permit tcp host 61.144.51.62 eq www any
这个例子说明static和conduit的关系。192.168.0.3在内网是一台web服务器,现在希望的用户能够通过pix防火墙得到web服务。所以先做static静态映射:192.168.0.3->61.144.51.62(全局),然后利用conduit命令允许任何外部主机对全局地址61.144.51.62进行http访问。
C. 配置fixup协议
fixup命令作用是启用,禁止,改变一个服务或协议通过pix防火墙,由fixup命令指定的端口是pix防火墙要侦听的服务。见下面例子:
例1. Pix525(config)#fixup protocol ftp 21
启用ftp协议,并指定ftp的端口号为21
例2. Pix525(config)#fixup protocol http 80
Pix525(config)#fixup protocol http 1080
为http协议指定80和1080两个端口。
例3. Pix525(config)#no fixup protocol smtp 80
禁用smtp协议。
D. 设置telnet
telnet有一个版本的变化。在pix OS 5.0(pix操作系统的版本号)之前,只能从内部网络上的主机通过telnet访问pix。在pix OS 5.0及后续版本中,可以在所有的接口上启用telnet到pix的访问。当从外部接口要telnet到pix防火墙时,telnet数据流需要用ipsec提供保护,也就是说用户必须配置pix来建
立一条到另外一台pix,路由器或客户端的ipsec隧道。另外就是在PIX上配置SSH,然后用SSH client从外部telnet到PIX防火墙,PIX支持SSH1和SSH2,不过SSH1是免费软件,SSH2是商业软件。相比之下cisco路由器的telnet就作的不怎么样了。
telnet配置语法:telnet local_ip [netmask]
local_ip 表示被授权通过telnet访问到pix的ip地址。如果不设此项,pix的配置方式只能由console进行。
说了这么多,下面给出一个配置实例供大家参考。
Welcome to the PIX firewall
Type help or '?' for a list of available commands.
PIX525> en
Password:
PIX525#sh config
: Saved
:
PIX Version 6.0(1) ------ PIX当前的操作系统版本为6.0
Nameif ethernet0 outside security0
Nameif ethernet1 inside security100 ------ 显示目前pix只有2个接口
Enable password 7Y051HhCcoiRTSQZ encrypted
Passed 7Y051HhCcoiRTSQZ encrypted ------ pix防火墙密码在默认状态下已被加密,在配置文件中不会以明文显示,telnet 密码缺省为cisco
Hostname PIX525 ------ 主机名称为PIX525
Domain-name 123.com ------ 本地的一个域名服务器123.com,通常用作为外部访问
Fixup protocol ftp 21
Fixup protocol http 80
fixup protocol h323 1720
fixup protocol rsh 514
fixup protocol smtp 25
fixup protocol sqlnet 1521
fixup protocol sip 5060 ------ 当前启用的一些服务或协议,注意rsh服务是不能改变端口号
names ------ 解析本地主机名到ip地址,在配置中可以用名字代替ip地址,当前没有设置,所以列表为空
pager lines 24 ------ 每24行一分页
interface ethernet0 auto
interface ethernet1 auto ------ 设置两个网卡的类型为自适应
mtu outside 1500
mtu inside 1500 ------ 以太网标准的MTU长度为1500字节
ip address outside 61.144.51.42 255.255.255.248
ip address inside 192.168.0.1 255.255.255.0 ------ pix的ip地址61.144.51.42,内网的ip地址192.168.0.1
ip audit info action alarm
ip audit attack action alarm ------ pix入侵检测的2个命令。当有数据包具有攻击或报告型特征码时,pix将采取报警动作(缺省动作),向指定的日志记录主机产生系统日志消息;此外还可以作出丢弃数据包和发出tcp连接复位信号等动作,需另外配置。
pdm history enable ------ PIX设备管理器可以图形化的监视PIX
arp timeout 14400 ------ arp表的超时时间
global (outside) 1 61.144.51.46 ------ 如果你访问外部论坛或用QQ聊天等等,上面显示的ip就是这个
nat (inside) 1 0.0.0.0 0.0.0.0 0 0
static (inside, outside) 61.144.51.43 192.168.0.8 netmask 255.255.255.255 0 0
conduit permit icmp any any
conduit permit tcp host 61.144.51.43 eq www any
conduit permit udp host 61.144.51.43 eq domain any
------ 用61.144.51.43这个ip地址提供domain-name服务,而且只允许外部用户访问domain的udp端口
route outside 0.0.0
0.0.0.0 61.144.51.61 1 ------ 外部网关61.144.51.61
timeout xlate 3:00:00 ------ 某个内部设备向外部发出的ip包经过翻译(global)后,在缺省3个小时之后此数据包若没有活动,此前创建的表项将从翻译表中删除,释放该设备占用的全局地址
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 rpc 0:10:00 h323 0:05:00 sip 0:30:00 sip_media 0:02:00
timeout uauth 0:05:00 absolute ------ AAA认证的超时时间,absolute表示连续运行uauth定时器,用户超时后,将强制重新认证
aaa-server TACACS+ protocol tacacs+
aaa-server RADIUS protocol radius ------ AAA服务器的两种协议。AAA是指认证,授权,审计。Pix防火墙可以通过AAA服务器增加内部网络的安全
no snmp-server location
no snmp-server contact
snmp-server community public ------ 由于没有设置snmp工作站,也就没有snmp工作站的位置和联系人
no snmp-server enable traps ------ 发送snmp陷阱
floodguard enable ------ 防止有人伪造大量认证请求,将pix的AAA资源用完
no sysopt route dnat
telnet timeout 5
ssh timeout 5 ------ 使用ssh访问pix的超时时间
terminal width 80
Cryptochecksum:a9f03ba4ddb72e1ae6a543292dd4f5e7
PIX525#
PIX525#write memory ------ 将配置保存
上面这个配置实例需要说明一下,pix防火墙直接摆在了与internet接口处,此处网络环境有十几个公有ip,可能会有朋友问如果我的公有ip很有限怎么办?你可以添加router放在pix的前面,或者global使用单一ip地址,和外部接口的ip地址相同即可。另外有几个维护命令也很有用,show interface查看端口状态,show static查看静态地址映射,show ip查看接口ip地址,ping outside | inside ip_address确定连通性。
本文只是对pix防火墙的基本配置做了相关描述,pix其他的一些功能例如AAA服务器,等等限于篇幅,不再一一介绍。