天天看點

路由器交換機配置

1. 交換機支援的指令:

    交換機基本狀态:

    switch: ;ROM狀态, 路由器是rommon>

    hostname> ;使用者模式

    hostname# ;特權模式

    hostname(config)# ;全局配置模式

    hostname(config-if)# ;接口狀态

    交換機密碼設定:

    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 ;設定登入密碼xx

    switch#exit ;傳回指令

    交換機VLAN設定:

    switch#vlan database ;進入VLAN設定

    switch(vlan)#vlan 2 ;建VLAN 2

    switch(vlan)#no vlan 2 ;删vlan 2

    switch(config)#int f0/1 ;進入端口1

    switch(config-if)#switchport access vlan 2 ;目前端口加入vlan 2

    switch(config-if)#switchport mode trunk ;設定為幹線

    switch(config-if)#switchport trunk allowed vlan 1,2 ;設定允許的vlan

    switch(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位址:

    switch(config)#interface vlan 1 ;進入vlan 1

    switch(config-if)#ip address ;設定IP位址

    switch(config)#ip default-gateway ;設定預設網關

    switch#dir flash: ;檢視閃存

    交換機顯示指令:

    switch#write ;儲存配置資訊

    switch#show vtp ;檢視vtp配置資訊

    switch#show run ;檢視目前配置資訊

    switch#show vlan ;檢視vlan配置資訊

    switch#show interface ;檢視端口資訊

    switch#show int f0/0 ;檢視指定端口資訊

    2. 路由器支援的指令:

    路由器顯示指令:

    router#show run ;顯示配置資訊

    router#show interface ;顯示接口資訊

    router#show ip route ;顯示路由資訊

    router#show cdp nei ;顯示鄰居資訊

    router#reload ;重新起動

    路由器密碼設定:

    router>enable ;進入特權模式

    router#config terminal ;進入全局配置模式

    router(config)#hostname ;設定交換機的主機名

    router(config)#enable secret xxx ;設定特權加密密碼

    router(config)#enable password xxb ;設定特權非密密碼

    router(config)#line console 0 ;進入控制台口

    router(config-line)#line vty 0 4 ;進入虛拟終端

    router(config-line)#login ;要求密碼驗證

    router(config-line)#password xx ;設定登入密碼xx

    router(config)#(Ctrl+z) ; 傳回特權模式

    router#exit ;傳回指令

    路由器配置:

    router(config)#int s0/0 ;進入Serail接口

    router(config-if)#no shutdown ;激活目前接口

    router(config-if)#clock rate 64000 ;設定同步時鐘

    router(config-if)#ip address ;設定IP位址

    router(config-if)#ip address second ;設定第二個IP

    router(config-if)#int f0/0.1 ;進入子接口

    router(config-subif.1)#ip address ;設定子接口IP

    router(config-subif.1)#encapsulation dot1q ;綁定vlan中繼協定

    router(config)#config-register 0x2142 ;跳過配置檔案

    router(config)#config-register 0x2102 ;正常使用配置檔案

    router#reload ;重新開機

    路由器檔案操作:

    router#copy running-config startup-config ;儲存配置

    router#copy running-config tftp ;儲存配置到tftp

    router#copy startup-config tftp ;開機配置存到tftp

    router#copy tftp flash: ;下傳檔案到flash

    router#copy tftp startup-config ;下載下傳配置檔案

    ROM狀态:

    Ctrl+Break ;進入ROM監控狀态

    rommon>confreg 0x2142 ;跳過配置檔案

    rommon>confreg 0x2102 ;恢複配置檔案

    rommon>reset ;重新開機

    rommon>copy xmodem: flash: ;從console傳輸檔案

    rommon>IP_ADDRESS=10.65.1.2 ;設定路由器IP

    rommon>IP_SUBNET_MASK=255.255.0.0 ;設定路由器掩碼

    rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP伺服器IP

    rommon>TFTP_FILE=c2600.bin ;指定下載下傳的檔案

    rommon>tftpdnld ;從tftp下載下傳

    rommon>dir flash: ;檢視閃存内容

    rommon>boot ;引導IOS

    靜态路由:

    ip route ;指令格式

    router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;靜态路由舉例

    router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;預設路由舉例

    動态路由:

    router(config)#ip routing ;啟動路由轉發

    router(config)#router rip ;啟動RIP路由協定。

    router(config-router)#network ;設定釋出路由

    router(config-router)#negihbor ;點對點幀中繼用。

    幀中繼指令:

    router(config)#frame-relay switching ;使能幀中繼交換

    router(config-s0)#encapsulation frame-relay ;使能幀中繼

    router(config-s0)#fram-relay lmi-type cisco ;設定管理類型

    router(config-s0)#frame-relay intf-type DCE ;設定為DCE

    router(config-s0)#frame-relay dlci 16 ;

    router(config-s0)#frame-relay local-dlci 20 ;設定虛電路号

    router(config-s0)#frame-relay interface-dlci 16 ;

    router(config)#log-adjacency-changes ;記錄鄰接變化

    router(config)#int s0/0.1 point-to-point ;設定子接口點對點

    router#show frame pvc ;顯示永久虛電路

    router#show frame map ;顯示映射

    基本通路控制清單:

    router(config)#access-list permit|deny

    router(config)#interface ;default:deny any

    router(config-if)#ip access-group in|out ;defaultut

    例1:

    router(config)#access-list 4 permit 10.8.1.1

    router(config)#access-list 4 deny 10.8.1.0 0.0.0.255

    router(config)#access-list 4 permit 10.8.0.0 0.0.255.255

    router(config)#access-list 4 deny 10.0.0.0 0.255.255.255

    router(config)#access-list 4 permit any

    router(config)#int f0/0

    router(config-if)#ip access-group 4 in

    擴充通路控制清單:

    access-list permit|deny icmp [type]

    access-list permit|deny tcp [port]

    例3:

    router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo

    router(config)#access-list 101 permit ip any any

    router(config)#int s0/0

    router(config-if)#ip access-group 101 in

    router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80

    router(config)#access-list 102 permit ip any any

    router(config)#interface s0/1

    router(config-if)#ip access-group 102 out

    删除通路控制例表:

    router(config)#no access-list 102

    router(config-if)#no ip access-group 101 in

    路由器的nat配置

    Router(config-if)#ip nat inside ;目前接口指定為内部接口

    Router(config-if)#ip nat outside ;目前接口指定為外部接口

    Router(config)#ip nat inside source static [p] [port]

    Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1

    Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80

    Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0

    Router(config)#ip nat inside source list 1 pool p1

    Router(config)#ip nat inside destination list 2 pool p2

    Router(config)#ip nat inside source list 2 interface s0/0 overload

    Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary

    Router#show ip nat translation

    rotary 參數是輪流的意思,位址池中的IP輪流與NAT配置設定的位址比對。

    overload參數用于PAT 将内部IP映射到一個公網IP不同的端口上。

    外部網關協定配置

    routerA(config)#router bgp 100

    routerA(config-router)#network 19.0.0.0

    routerA(config-router)#neighbor 8.1.1.2 remote-as 200

    配置PPP驗證:

    RouterA(config)#username password

    RouterA(config)#int s0

    RouterA(config-if)#ppp authentication {chap|pap}

    3.PIX防火牆指令

    Pix525(config)#nameif ethernet0 outside security0 ;命名接口和級别

    Pix525(config)#interface ethernet0 auto ;設定接口方式

    Pix525(config)#interface ethernet1 100full ;設定接口方式

    Pix525(config)#interface ethernet1 100full shutdown

    Pix525(config)#ip address inside 192.168.0.1 255.255.255.0

    Pix525(config)#ip address outside 133.0.0.1 255.255.255.252

    Pix525(config)#global (if_name) natid ip-ip ;定義公網IP區間

    Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 ;例句

    Pix525(config)#global (outside) 1 133.0.0.1 ;例句

    Pix525(config)#no global (outside) 1 133.0.0.1 ;去掉設定

    Pix525(config)#nat (if_name) nat_id local_ip [netmark]

    Pix525(config)#nat (inside) 1 0 0

    内網所有主機(0代表0.0.0.0)可以通路global 1指定的外網。

    Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0

    内網172.16.5.0/16網段的主機可以通路global 1指定的外網。

    Pix525(config)#route if_name 0 0 gateway_ip [metric] ;指令格式

    Pix525(config)#route outside 0 0 133.0.0.1 1 ;例句

    Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句

    Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8

    表示内部ip位址192.168.0.8,通路外部時被翻譯成133.0.0.1全局位址。

    Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8

    中間區域ip位址172.16.0.8,通路外部時被翻譯成133.0.0.1全局位址。

上一篇: 克隆虛拟機
下一篇: ESXI虛拟機