查看完整版本: PC ,交換機,路由器組態的指令集合

fend631 2008-1-29 15:03

PC ,交換機,路由器組態的指令集合

1. 電腦指令:
je^@Bhb PCA login: root ;使用root使用者 [KN.n.hLN0|7E
password: linux ;口令是linuxI}(e+[v7S-j
# shutdown -h now ;同init 0 關機
+s{i%B~bx # logout
S,Z A U+W # login"n,g;f([_&wt] ^-K
# ifconfig ;顯示IP位址;VF0a&[QI+ZU
# ifconfig eth0 netmask ;設定IP位址6p%su^_;K
# ifconfig eht0 netmask down ; 移除IP位址/?~[k'T/D|_M
# route add 0.0.0.0 gw
J E-kf1^;J8Y$yW9uC # route del 0.0.0.0 gw
(D9AmyJFiD # route add default gw ;設定通訊閘
-fl$L,LW # route del default gw ;移除通訊閘
*I+`+F ^ Kq2N]r6\ # route ;顯示通訊閘V'U/p)d%Xrm'U ]U
# ping Bf5s7m Y$Et5FtOO
# telnet
Ov9c h1NW3i
-s(e#IL1t+m.E'V8P 2. 交換機支援的指令:
d;Q| TN#m 交換機基本狀態:
i JUgMOBG switch: ;交換機的ROM狀態m'@e? VaVd
rommon> ;路由器的ROM狀態H)vPk9L/K.h1X
hostname> ;使用者樣式|yF{-G*br'Z
hostname# ;特權樣式dyi&Z(m5\[
hostname(config)# ;全局組態樣式7l5G*x%k?5x
hostname(config-if)# ;接口狀態
zT0] wo0I/m)b
K!vJS4o9Lzg ei 交換機口令設定:
L;n|EI switch>enable ;進入特權樣式
I0LQt%e.Kaa switch#config terminal ;進入全局組態樣式 Nrg%g l/^X
switch(config)#hostname ;設定交換機的主電腦名稱#drqy(d+ky j
switch(config)#enable secret xxx ;設定特權加密口令
)ywFq"Fi5~$f6U switch(config)#enable password xxa ;設定特權非密口令$uz$e8L pYfe
switch(config)#line console 0 ;進入控制台口*uZiy)nfe C-\m:O
switch(config-line)#line vty 0 4 ;進入虛擬終端機`,?ZN5Q4@2\
switch(config-line)#login ;允許登入 r0Gcr&g
switch(config-line)#password xx ;設定登入口令xx.RlHG^j{m
switch#exit ;傳回指令3x W N C Ggo

)IR+`pzL,Bk(Y1R 交換機VLAN設定:A _;t]-\-\
switch#vlan database ;進入VLAN設定 H\ y2y/Pe
switch(vlan)#vlan 2 ;建VLAN 2
pH{xBy switch(vlan)#no vlan 2 ;刪vlan 2
F2s5wB5C switch(config)#int f0/1 ;進入連接埠1
'CZi1{Pzq$d0A%~ switch(config-if)#switchport access vlan 2 ;目前連接埠加入vlan 2
3TQ8V d'@]cE switch(config-if)#switchport mode trunk ;設定為乾線
C'N&DL:WJ switch(config-if)#switchport trunk allowed vlan 1,2 ;設定允許的vlan2|(_3y_N
switch(config-if)#switchport trunk encap dot1q ;設定vlan 中繼G1?0_D$n-C_
switch(config)#vtp domain ;設定發vtp域名)RHj4q.S
switch(config)#vtp password ;設定發vtp密碼(T-^e W'e)LXR5M4k
switch(config)#vtp mode server ;設定發vtp樣式
*Cz5Pc[+oo switch(config)#vtp mode client ;設定發vtp樣式
&?H7D7UQ_Q QYv5n T#ihA V
交換機設定IP位址:
^'D_S9A`xxu@ switch(config)#interface vlan 1 ;進入vlan 1
.f5@ y*oNRGJ switch(config-if)#ip address ;設定IP位址;_Tp'fgxc];f
switch(config)#ip default-gateway ;設定預設通訊閘i;G*P5I)P])?Z8M~@
switch#dir flash: ;檢視閃存
VOt/cQsf 4o__ {X;Z5f
交換機顯示指令: iz8o3k$f ?4L
switch#write ;儲存組態資訊
+pxngfP6uTu switch#show vtp ;檢視vtp組態資訊mt(x/p/QRK
switch#show run ;檢視目前組態資訊
SN5IT%sT)? switch#show vlan ;檢視vlan組態資訊
{$y&F!ur^@ switch#show interface ;檢視連接埠訊息
GBJ!C@-Y OE1j(w switch#show int f0/0 ;檢視指定連接埠訊息DH `)RE v#a&a
e'F%}_]*uuu
&Ad0E$q-K8U
3. 路由器支援的指令:
7_u|7t"s 路由器顯示指令:
H-SOT9@H router#show run ;顯示組態資訊
K"~c9tSf;[X router#show interface ;顯示接口訊息
#Y*`w |!y/mY2_5y X router#show ip route ;顯示路由訊息i*mj Z6IO I;E
router#show cdp nei ;顯示鄰居訊息|'K*_ mVIr
router#reload     ;重新起動
xd,iN/{ O'Eh
g8w9[?0y MMa 路由器口令設定:*U%r8}u j4M
router>enable ;進入特權樣式
s O.C0^8y0`3Gj1s router#config terminal ;進入全局組態樣式
`,n~)m!J3aw router(config)#hostname ;設定交換機的主電腦名稱
jM a(`5C(_D;D%}M7V0Az router(config)#enable secret xxx ;設定特權加密口令;m$O*@-ELR?
router(config)#enable password xxb ;設定特權非密口令
%Gp w&w s;L,Tyu router(config)#line console 0 ;進入控制台口
W Z T[C y@ router(config-line)#line vty 0 4 ;進入虛擬終端機 q]v;Sm1PY
router(config-line)#login ;要求口令驗證1y#oGKEi7e|A~
router(config-line)#password xx ;設定登入口令xx nQ\IG#Ux9j
router(config)#(Ctrl+z) ; 傳回特權樣式fK-\9N1Q4}1TFsU
router#exit ;傳回指令
9?.U#j6Z R f\]4DU 7m Z D7o4qIE
路由器組態:_4c0ED;j(uP
router(config)#int s0/0 ;進入Serail接口}4rK!g!@)Ve2@5@&r
router(config-if)#no shutdown ;活化目前接口u p$j{#t
router(config-if)#clock rate 64000 ;設定同步時鐘
6}&t)z}b I router(config-if)#ip address ;設定IP位址
1Y,L9jtM hfL router(config-if)#ip address second ;設定第二個IP@Q_+j)Xa%w3k.m
router(config-if)#int f0/0.1 ;進入子接口
_+JZNe+c:h router(config-subif.1)#ip address ;設定子接口IP
W2CI| B4~ n router(config-subif.1)#encapsulation dot1q ;系結vlan中繼協定G.u!a dg!Ke)xv
router(config)#config-register 0x2142 ;略過組態檔案
1k;x#q!U]c@T&j!v router(config)#config-register 0x2102 ;正常使用組態檔案M5fb9C,x
router#reload ;重新引導
,o v V-t5D+] oN{T
{id9hol(U(J 路由器檔案動作: O&IlZ^
router#copy running-config startup-config ;儲存組態
~@ Ks Gui router#copy running-config tftp ;儲存組態到tftp
e.mu!|L router#copy startup-config tftp ;開機組態存到tftp:m?8QN0q~!rm^"r
router#copy tftp flash: ;下傳檔案到flashy%O0FEaE
router#copy tftp startup-config ;下載組態檔案
0n.l@,{G ]4mZh d?B
ROM狀態:
Q$];h%p0@ uY,P[&D*L Ctrl+Break ;進入ROM監控狀態
.^qC9V TB4n _/U rommon>confreg 0x2142 ;略過組態檔案
h?4Qy-z}{p rommon>confreg 0x2102 ;恢復組態檔案]0`^(\6D/]3Dh
rommon>reset ;重新引導
,A+JhLU7DJ$c$XM rommon>copy xmodem: flash: ;從console傳輸檔案
&i*j,y H/c@
M/Os C}9by3\1` rommon>IP_ADDRESS=10.65.1.2 ;設定路由器IP-W%KX ]j7Z(r^/\fE
rommon>IP_SUBNET_MASK=255.255.0.0 ;設定路由器遮罩
j+bA[T$d| rommon>TFTP_SERVER=10.65.1.1 ;指定TFTP伺服器IP
:]]X&Ik'Q*lY rommon>TFTP_FILE=c2600.bin ;指定下載的檔案VJ%Do\
rommon>tftpdnld ;從tftp下載a[|4Y({~AC
rommon>dir flash: ;檢視閃存內容
#G/r-lij k8}[ rommon>boot ;引導IOS
Uw n%GY;ILp \b Rd9I j
靜態路由:
+rLR%f6E{.t8O ip route ;指令格式
ll:F4bZ {'U*`&s8b router(config)#ip route 2.0.0.0 255.0.0.0 1.1.1.2 ;靜態路由舉例$J^'x,qX+ar
router(config)#ip route 0.0.0.0 0.0.0.0 1.1.1.2 ;預設路由舉例$O8P?FI!L;E)w2@

"P5l:v-i+M @(A'l 動態路由:
"q D j)kk*m router(config)#ip routing ;啟動路由轉發
BxX;iw router(config)#router rip ;啟動RIP路由協定。
Po+tc#t;p router(config-router)#network ;設定發布路由[5g.ph1To+c
router(config-router)#negihbor ;點對點幀中繼用。5M*H\ Zr \ d
\K#[LPvH Q
幀中繼指令:FIK _:h/F
router(config)#frame-relay switching ;使能幀中繼交換R4D|YLp#Sl
router(config-s0)#encapsulation frame-relay ;使能幀中繼*pQ#_'jOjy6P;?7j
router(config-s0)#fram-relay lmi-type cisco ;設定管理類型
SB2jy b:|[H router(config-s0)#frame-relay intf-type DCE ;設定為DCEKK#f1WX GW?
router(config-s0)#frame-relay dlci 16 ;
g&R l$S,gb7j{ router(config-s0)#frame-relay local-dlci 20 ;設定虛電路號5{w&UcO8D]1~
router(config-s0)#frame-relay interface-dlci 16 ;[P'|FQ.~4vE)U;f
router(config)#log-adjacency-changes ;記錄鄰接變化
;p{8B5M-O2]C'|8j2E router(config)#int s0/0.1 point-to-point ;設定子接口點對點2ZP$r0Nr4yB i
router#show frame pvc ;顯示永久虛電路%\yE6r#|!^_Lp uTp
router#show frame map ;顯示對映9?1Eowm

V4sK%rflY7y"_8f 基本存取控制清單: kd4qmQb0DP+J1V
router(config)#access-list permit|deny
c5h+JEo`A T router(config)#interface ;default:deny any
tMp'OXi3n router(config-if)#ip access-group in|out ;default:out
Q'^!S4Z#f`C/U` ^&d5FLV
例1:| T/qtw)Ex2i/Bt
router(config)#access-list 1 deny host 10.65.1.1
N\s3N+}VV#W router(config)#access-list 1 permit any1t(T@"ho9v
router(config)#int f0/0
;Hy,i%mMz'k router(config-if)#ip access-group 4 inuo7l @5t/^L
5E-ja1z:h?:\}
例2:
`#y9HYm/`A router(config)#access-list 4 permit 10.8.1.1&^;W2K7N4^4x{f-a
router(config)#access-list 4 deny 10.8.1.0 0.0.0.255
.ah"Q|VE-`.L router(config)#access-list 4 permit 10.8.0.0 0.0.255.255
3baWWv+l!@O5y-hj router(config)#access-list 4 deny 10.0.0.0 0.255.255.255] D5G1Y l-q4^6q
router(config)#access-list 4 permit any
e+H@[D:C~ router(config)#int f0/1$i |mr!|TQ"g"M,]$k
router(config-if)#ip access-group 4 in
%a b"}![3^2}
0@u8H.}Bb 延伸存取控制清單:;i!D5q!lIl{9Y\$q3K%u
access-list permit|deny icmp [type]B)b0vC F%c?Ma,s
access-list permit|deny tcp [port]MY5sU ^ @7e-C(K|&^5a
:FFI(cOO
例1:2W FZ5z$z p
router(config)#access-list 101 deny icmp any 10.64.0.2 0.0.0.0 echoI,h/w1po0|c.G _&d
router(config)#access-list 101 permit ip any any
"TW`zQ%ePU'D#{2Wp router(config)#int s0/0+@6tC0{.]
router(config-if)#ip access-group 101 in mhzYl#u|

/Y+~ [.b_]4[ [ 例2:k}6hi-blT;z,D
router(config)#access-list 102 deny tcp any 10.65.0.2 0.0.0.0 eq 80CW${Y;z'F{
router(config)#access-list 102 permit ip any any Asn-NX4]P:[e
router(config)#interface s0/1
!|,C,JVL3a'o/Hj@3L-M router(config-if)#ip access-group 102 out&M k?o(?^m
q5G.~un Te
移除存取控制例表:
tr7MQSW router(config)#no access-list 1022A6Atw9P)_![s
router(config-if)#no ip access-group 101 in7T&a ^ H&x&@9uxp
$](R^K#LIi fH
路由器的nat組態YI&c X5YNz
Router(config-if)#ip nat inside ;目前接口指定為內部接口J t'@S(A3i$f
Router(config-if)#ip nat outside ;目前接口指定為外部接口
;U[ f,t1i$^T*w5M*v Router(config)#ip nat inside source static [p] <私有IP><公網IP> [port]Q6D*OD1oZc
Router(config)#ip nat inside source static 10.65.1.2 60.1.1.1
2U7u n3Y H Router(config)#ip nat inside source static tcp 10.65.1.3 80 60.1.1.1 80tt4t#b2CW
Router(config)#ip nat pool p1 60.1.1.1 60.1.1.20 255.255.255.0
GRhK0N"Y)Q0^ l Router(config)#ip nat inside source list 1 pool p1
W{X!h7P?Xb:M)C Router(config)#ip nat inside destination list 2 pool p2
p1t-R3a1S.Q FQ c.U Router(config)#ip nat inside source list 2 interface s0/0 overload&O7x.\W}~f4H
Router(config)#ip nat pool p2 10.65.1.2 10.65.1.4 255.255.255.0 type rotary }vg0ww'|!m f
Router#show ip nat translation Vv!K v4X_-Fm!H5|
rotary 參數是輪流的意思,位址池中的IP輪流與NAT分配的位址匹配。y1G ] c@ixC{cu
overload參數用於PAT 將內部IP對映到一個公網IP不同的連接埠上。"AM/m~:hK3S+C
U V D/e/YA7L5U
外部通訊閘協定組態
Lc,am? routerA(config)#router bgp 100
%u2Ij!p,Kv'I y N routerA(config-router)#network 19.0.0.0 A@4w B:q@.G9V S
routerA(config-router)#neighbor 8.1.1.2 remote-as 200#w'B lbgs^
zQF-R.Tx QR8t
組態PPP驗證:n ^ae'p @?
RouterA(config)#username password
;U7F7G4v6v RouterA(config)#int s0-u x E Zb|B
RouterA(config-if)#ppp authentication {chap|pap}
Pqc [O'g^J[
_:U@#K&ry"\
C.V_do g+vB;y 4·PIX防火牆指令
x%_iq J%? Pix525(config)#nameif ethernet0 outside security0 ;命名接口和層級
W2m RGz1a p tm Pix525(config)#interface ethernet0 auto ;設定接口方式iZ8c/^,S6Ve t)SGg
Pix525(config)#interface ethernet1 100full ;設定接口方式\l(BMm!|/m7m
Pix525(config)#interface ethernet1 100full shutdownd8|)M0p8n,hY E
Pix525(config)#ip address inside 192.168.0.1 255.255.255.0
&p:O.tw?#n,Y5H Pix525(config)#ip address outside 133.0.0.1 255.255.255.252
3_DU3x&u3?D p.Q g
\A Azd;W6\ Pix525(config)#global (if_name) natid ip-ip ;定義公網IP區間
e!l CY1]zh Pix525(config)#global (outside) 1 7.0.0.1-7.0.0.15 ;例句 DI/vF-DcuD1xL
Pix525(config)#global (outside) 1 133.0.0.1 ;例句v-e1e!A.Y"nL
Pix525(config)#no global (outside) 1 133.0.0.1 ;去掉設定
LVqoR!m .g1[-s9W/L&W
Pix525(config)#nat (if_name) nat_id local_ip [netmark]
q fLy;}:@8| Pix525(config)#nat (inside) 1 0 0
g\K'^wU*w 內網所有主電腦(0代表0.0.0.0)可以存取global 1指定的外網。
F'B-yQWW h$y Pix525(config)#nat (inside) 1 172.16.5.0 255.255.0.0FsAxfUu
內網172.16.5.0/16網段的主電腦可以存取global 1指定的外網。
XK zUYG+FBU 5T$U4q&{D{#Uk
Pix525(config)#route if_name 0 0 gateway_ip [metric] ;指令格式X&~cb*E}5Zu#l!c
Pix525(config)#route outside 0 0 133.0.0.1 1 ;例句1|]0t"cVefam
Pix525(config)#route inside 10.1.0.0 255.255.0.0 10.8.0.1 1 ;例句
RnG%Qu0Zh
]7c1Z~&V9t kGRW Pix525(config)#static (inside, outside) 133.0.0.1 192.168.0.8 H Zf4B#r P.O)J l
表示內部ip位址192.168.0.8,存取外部時被翻譯成133.0.0.1全局位址。
7A `"E(\8kkhe y,r;{1v4Q
Pix525(config)#static (dmz, outside) 133.0.0.1 172.16.0.8
_G'II%EmZ(f @t 中間欄位ip位址172.16.0.8,存取外部時被翻譯成133.0.0.1全局位址。
頁: [1]
查看完整版本: PC ,交換機,路由器組態的指令集合