发新话题
打印

交换机的配置命令




交换机的配置命令

<P> 1. 计算机命令:<BR>PCA login: root                                     ;使用root用户<BR> password: linux                                    ;口令是linux<BR># shutdown -h now                                   ;同init 0 关机<BR># logout<BR># login<BR># ifconfig                                          ;显示IP地址<BR># ifconfig eth0 &lt;ip address&gt; netmask &lt;netmask&gt;      ;设置IP地址<BR># ifconfig eht0 &lt;ip address&gt; netmask &lt;netmask&gt; down ; 删除IP地址<BR># route add 0.0.0.0 gw &lt;ip&gt;<BR># route del 0.0.0.0 gw &lt;ip&gt;<BR># route add default gw &lt;ip&gt;                         ;设置网关<BR># route del default gw &lt;ip&gt;                         ;删除网关<BR># route                                             ;显示网关<BR># ping &lt;ip&gt;<BR># telnet &lt;ip&gt;</P>
0 A# H6 R; r8 ?# E; H5 u8 b9 [( H! Q* R% N" I" n
<P>    2. 交换机支持的命令:<BR>交换机基本状态:<BR>switch:                                             ;交换机的ROM状态<BR>rommon&gt;                                             ;路由器的ROM状态<BR>hostname&gt;                                           ;用户模式<BR>hostname#                                           ;特权模式<BR>hostname(config)#                                   ;全局配置模式<BR>hostname(config-if)#                                ;接口状态</P>
) [. p2 {* w% ?( i/ n+ `) A: }& R) M7 X( @
<P>交换机口令设置:<BR>switch&gt;enable                                       ;进入特权模式<BR>switch#config terminal                              ;进入全局配置模式<BR>switch(config)#hostname &lt;hostname&gt;                  ;设置交换机的主机名<BR>switch(config)#enable secret xxx                    ;设置特权加密口令<BR>switch(config)#enable password xxa                  ;设置特权非密口令<BR>switch(config)#line console 0                       ;进入控制台口<BR>switch(config-line)#line vty 0 4                    ;进入虚拟终端<BR>switch(config-line)#login                           ;答应登录<BR>switch(config-line)#password xx                     ;设置登录口令xx<BR>switch#exit                                         ;返回命令</P>
* k: c) q7 p* l3 s; ]1 F0 H
& g/ k" Q( |* Y9 _  {+ e- l; ?: y<P>交换机VLAN设置:<BR>switch#vlan database                                ;进入VLAN设置<BR>switch(vlan)#vlan 2                                 ;建VLAN 2<BR>switch(vlan)#no vlan 2                              ;删vlan 2<BR>switch(vlan)#vtp domain &lt;name&gt;                      ;设置发vtp域名<BR>switch(vlan)#vtp password &lt;word&gt;                    ;设置发vtp密码<BR>switch(vlan)#vtp server                             ;设置发vtp模式<BR>switch(vlan)#vtp client                             ;设置发vtp模式<BR>switch(vlan)#vtp pruning                            ;设置vtp 答应<BR>switch(config)#int f0/1                             ;进入端口1<BR>switch(config-if)#switchport access vlan 2          ;当前端口加入vlan 2<BR>switch(config-if)#switchport mode trunk             ;设置为干线<BR>switch(config-if)#switchport trunk allowed vlan 1,2 ;设置答应的vlan<BR>switch(config-if)#switchport trunk encap dot1q      ;设置vlan 中继<BR>switch(config-if)#speed                             ;设置接口速度<BR>switch(config-if)#duplex                            ;设置接口作方式</P>6 H$ G/ }' F9 f% o' ]
/ ^# f0 u! S7 W% b. H. ~$ v0 a
<P>交换机设置IP地址:<BR>switch(config)#interface vlan 1                     ;进入vlan 1<BR>switch(config-if)#ip address &lt;IP&gt; &lt;mask&gt;            ;设置IP地址<BR>switch(config)#ip default-gateway &lt;IP&gt;              ;设置默认网关<BR>switch#dir flash:                                   ;查看闪存</P>' J& w1 k% s$ \

) L; n( ?/ F, e4 t6 A% ^5 ]<P>交换机显示命令:<BR>switch#write                                        ;保存配置信息<BR>switch#show vtp                                     ;查看vtp配置信息<BR>switch#show run                                     ;查看当前配置信息<BR>switch#show vlan                                    ;查看vlan配置信息<BR>switch#show interface                               ;查看端口信息<BR>switch#show int f0/0                                ;查看指定端口信息</P>2 g2 r' a' U* j+ n9 I; k$ E) f5 j
1 K$ c* J6 c5 H" m
<P><BR>    3. 路由器支持的命令:<BR>路由器显示命令:<BR>router#show run                                     ;显示配置信息<BR>router#show interface                               ;显示接口信息<BR>router#show ip route                                ;显示路由信息<BR>router#show cdp nei                                 ;显示邻居信息<BR>router#reload                                     ;重新起动</P>" ?8 r  h" X# Z. ~# `# g

! ]: h0 A. j) P2 L1 \0 ]<P>路由器口令设置:<BR>router&gt;enable                                       ;进入特权模式<BR>router#config terminal                              ;进入全局配置模式<BR>router(config)#hostname &lt;hostname&gt;                  ;设置交换机的主机名<BR>router(config)#enable secret xxx                    ;设置特权加密口令<BR>router(config)#enable password xxb                  ;设置特权非密口令<BR>router(config)#line console 0                       ;进入控制台口<BR>router(config-line)#line vty 0 4                    ;进入虚拟终端<BR>router(config-line)#login                           ;要求口令验证<BR>router(config-line)#password xx                     ;设置登录口令xx<BR>router(config)#(Ctrl z)                             ; 返回特权模式<BR>router#exit                                         ;返回命令</P>
6 R7 n9 i' m& g0 Y( `# s! [) {6 \2 ?& x5 a- \+ L& A
<P>路由器配置:<BR>router(config)#int s0/0                             ;进入Serail接口<BR>router(config-if)#no shutdown                       ;激活当前接口<BR>router(config-if)#clock rate 64000                  ;设置同步时钟<BR>router(config-if)#ip address &lt;ip&gt; &lt;netmask&gt;         ;设置IP地址<BR>router(config-if)#ip address &lt;ip&gt; &lt;netmask&gt; second  ;设置第二个IP<BR>router(config-if)#int f0/0.1                        ;进入子接口<BR>router(config-subif.1)#ip address &lt;ip&gt; &lt;netmask&gt;    ;设置子接口IP<BR>router(config-subif.1)#encapsulation dot1q &lt;n&gt;      ;绑定vlan中继协议<BR>router(config)#config-register 0x2142               ;跳过配置文件<BR>router(config)#config-register 0x2102               ;正常使用配置文件<BR>router#reload                                       ;重新引导</P>
0 v6 C) i  a- Q0 m% H4 u- h$ X
) n: o+ v0 r' x4 B2 `<P>路由器文件操作:<BR>router#copy running-config startup-config           ;保存配置<BR>router#copy running-config tftp                     ;保存配置到tftp<BR>router#copy startup-config tftp                     ;开机配置存到tftp<BR>router#copy tftp flash:                             ;下传文件到flash<BR>router#copy tftp startup-config                     ;下载配置文件</P>
2 p: w  i/ z$ X9 E; `0 Y9 s2 a
/ I' \( M' K( u$ S4 x( O+ Q<P>ROM状态:<BR>Ctrl Break                                          ;进入ROM监控状态<BR>rommon&gt;confreg 0x2142                               ;跳过配置文件<BR>rommon&gt;confreg 0x2102                               ;恢复配置文件<BR>rommon&gt;reset                                        ;重新引导<BR>rommon&gt;copy xmodem:&lt;sname&gt; flash:&lt;dname&gt;            ;从console传输文件</P>1 [: H% z5 @1 W

8 V% C2 r8 Q$ c3 C5 g6 ^" [<P>rommon&gt;IP_ADDRESS=10.65.1.2                         ;设置路由器IP<BR>rommon&gt;IP_SUBNET_MASK=255.255.0.0                   ;设置路由器掩码<BR>rommon&gt;TFTP_SERVER=10.65.1.1                        ;指定TFTP服务器IP<BR>rommon&gt;TFTP_FILE=c2600.bin                          ;指定下载的文件<BR>rommon&gt;tftpdnld                                     ;从tftp下载<BR>rommon&gt;dir flash:                                   ;查看闪存内容<BR>rommon&gt;boot                                         ;引导IOS</P>- T( V- k; Z9 T. z

6 _6 u9 h7 Y' N- h8 h( i<P>静态路由:<BR>ip route &lt;ip-address&gt; &lt;subnet-mask&gt; &lt;gateway&gt;       ;命令格式<BR>router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2   ;静态路由举例<BR>router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2     ;默认路由举例</P>
- \1 R/ P  ], u4 c- E
3 ~; l1 b' W. I9 k) p3 F: }0 X0 \- k<P>动态路由:<BR>router(config)#ip routing                           ;启动路由转发<BR>router(config)#router rip                           ;启动RIP路由协议。<BR>router(config-router)#network &lt;netid&gt;               ;设置发布路由<BR>router(config-router)#negihbor &lt;ip&gt;                 ;点对点帧中继用。</P>
: L8 U' J' c1 D4 }# e
; ~! ^7 c. S& S<P>帧中继命令:<BR>router(config)#frame-relay switching                ;使能帧中继交换<BR>router(config-s0)#encapsulation frame-relay         ;使能帧中继<BR>router(config-s0)#fram-relay lmi-type cisco         ;设置治理类型<BR>router(config-s0)#frame-relay intf-type DCE         ;设置为DCE<BR>router(config-s0)#frame-relay dlci 16               ;<BR>router(config-s0)#frame-relay local-dlci 20         ;设置虚电路号<BR>router(config-s0)#frame-relay interface-dlci 16     ;<BR>router(config)#log-adjacency-changes                ;记录邻接变化<BR>router(config)#int s0/0.1 point-to-point            ;设置子接口点对点<BR>router#show frame pvc                               ;显示永久虚电路<BR>router#show frame map                               ;显示映射</P>+ R! w+ M* f+ z, q% V3 S# k& v- g% X

1 Y6 |4 y" R: Q0 n7 X<P>基本访问控制列表:<BR>router(config)#access-list &lt;number&gt; permit|deny &lt;source_ip&gt; &lt;wild|any&gt;<BR>router(config)#interface &lt;interface&gt;                ;default:deny any<BR>router(config-if)#ip access-group &lt;number&gt; in|out   ;defaultut</P>
/ }  k: ^3 S1 \4 l2 Q1 K9 W# c# W' p0 w+ r# R9 e0 H+ a0 S) h9 j1 A
<P>例1:<BR>router(config)#access-list 1 deny host 10.65.1.1<BR>router(config)#access-list 1 permit any<BR>router(config)#int f0/0<BR>router(config-if)#ip access-group 4 in</P>
, Y% R3 |+ ^$ k. E3 E  {: E5 a" P. q
<P>例2:<BR>router(config)#access-list 4 permit 10.8.1.1<BR>router(config)#access-list 4 deny 10.8.1.0 0.0.0.255<BR>router(config)#access-list 4 permit 10.8.0.0 0.0.255.255<BR>router(config)#access-list 4 deny 10.0.0.0 0.255.255.255<BR>router(config)#access-list 4 permit any<BR>router(config)#int f0/1<BR>router(config-if)#ip access-group 4 in</P>
( d8 U9 T8 D) c9 U6 G% @' ^" r
3 i3 E9 L9 |2 [: q# K/ J& R<P>扩展访问控制列表:<BR>access-list &lt;number&gt; permit|deny icmp &lt;S_IP wild&gt; &lt;D_IP wild&gt;[type]<BR>access-list &lt;number&gt; permit|deny tcp &lt;S_IP wild&gt; &lt;D_IP wild&gt;[port]</P>
$ ?5 z- {' u( o
# a& w' v5 q; [0 A" v, D+ L<P>例1:<BR>router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echo<BR>router(config)#access-list 101 permit ip any any<BR>router(config)#int s0/0<BR>router(config-if)#ip access-group 101 in</P>
8 e1 C* A( |; L8 V: Z! f& _  h, j0 @
1 S/ g9 C1 ^0 p( ^6 E& F/ g<P>例2:<BR>router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80<BR>router(config)#access-list 102 permit ip any any<BR>router(config)#interface s0/1<BR>router(config-if)#ip access-group 102 out</P>5 s' V9 J0 n4 Y% q2 [. ]' J

$ B9 p% k" I- r) i6 i8 V! L! z; Y<P>删除访问控制例表:<BR>router(config)#no access-list 102<BR>router(config-if)#no ip access-group 101 in</P>
6 ?: E. W" ]4 ]+ g+ `  z  T' y5 l0 Z+ j1 V* E% }$ F: m+ r4 @
<P>路由器的nat配置<BR>Router(config-if)#ip nat inside               ;当前接口指定为内部接口<BR>Router(config-if)#ip nat outside              ;当前接口指定为外部接口<BR>Router(config)#ip nat inside source static [p] &lt;私有IP&gt;&lt;公网IP&gt; [port]<BR>Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1<BR>Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80<BR>Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0<BR>Router(config)#ip nat inside source list 1 pool p1<BR>Router(config)#ip nat inside destination list 2 pool p2<BR>Router(config)#ip nat inside source list 2 interface s0/0 overload<BR>Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary<BR>Router#show ip nat translation<BR>rotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。<BR>overload参数用于PAT 将内部IP映射到一个公网IP不同的端口上。</P>
4 H; R2 P8 c( W: r2 L* F1 I) g" d6 T
3 |6 s* I2 C+ C9 ~<P>外部网关协议配置<BR>routerA(config)#router bgp 100<BR>routerA(config-router)#network 19.0.0.0<BR>routerA(config-router)#neighbor 8.1.1.2 remote-as 200</P>7 J2 _# C3 Z- P

# `3 E+ R4 m3 N<P>配置PPP验证:<BR>RouterA(config)#username &lt;RouterB&gt; password &lt;word&gt;<BR>RouterA(config)#int s0<BR>RouterA(config-if)#ppp authentication {chap|pap}</P>" s6 G. h3 c. f8 f7 r
% @) J  c: C3 {, `; E+ G9 {
<P><BR>    4.PIX防火墙命令<BR>Pix525(config)#nameif ethernet0 outside security0       ;命名接口和级别<BR>Pix525(config)#interface ethernet0 auto                 ;设置接口方式<BR>Pix525(config)#interface ethernet1 100full              ;设置接口方式<BR>Pix525(config)#interface ethernet1 100full shutdown<BR>Pix525(config)#ip address inside 192.168.0.1 255.255.255.0<BR>Pix525(config)#ip address outside 133.0.0.1 255.255.255.252</P>
( A; a; w* c8 ~$ w/ z" a! P* k: V: X2 G2 h
<P>Pix525(config)#global (if_name) natid ip-ip             ;定义公网IP区间<BR>Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15      ;例句<BR>Pix525(config)#global (outside) 1 133.0.0.1             ;例句<BR>Pix525(config)#no global (outside) 1 133.0.0.1          ;去掉设置</P>
, K, k7 ?" d% N
- t' H, J0 a% P<P>Pix525(config)#nat (if_name) nat_id local_ip [netmark]<BR>Pix525(config)#nat (inside) 1 0 0<BR>内网所有主机(0代表0.0.0.0)可以访问global 1指定的外网。<BR>Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0<BR>内网172.16.5.0/16网段的主机可以访问global 1指定的外网。</P>( F( x  q7 c1 H9 b% A( p1 B

0 i% g% Q. x- T( m2 ^% h. O; G. h<P>Pix525(config)#route if_name 0 0 gateway_ip [metric]        ;命令格式<BR>Pix525(config)#route outside 0 0 133.0.0.1 1                ;例句<BR>Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句</P>
, D# U5 r1 j" D# c* l3 O" s+ F2 [. q: Z7 F
<P>Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8<BR>表示内部ip地址192.168.0.8,访问外部时被翻译成133.0.0.1全局地址。</P>
1 z. p1 r2 ]# Q/ C
- K! ]9 x: j: _' e; F# u<P>Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8<BR>中间区域ip地址172.16.0.8,访问外部时被翻译成133.0.0.1全局地址<BR></P>

搜索 百度 查看更多关于   交换机的配置命令   的相关信息

搜索 狗狗 查看更多关于   交换机的配置命令   的相关信息





TOP

发新话题