title: cisco配置
date: 2022-08-01 09:19:00
tags:
- cisco
- 路由器
路由器
設定console密碼
Router>enable //特權模式
Router#configure terminal //全域模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#line console 0 //進入0號控制臺
Router(config-line)#password 111 //設定密碼111
Router(config-line)#login //開啟密碼

設定特權模式密碼
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#enable password 111 //設定明文密碼
Router(config)#enable secret 222 //設定加密密碼,會導致password失效
Router(config)#login //開啟密碼

設定遠程登錄telnet密碼
Router>enable
Router#configure terminal
Router(config)#line vty 0 4 //設定0-4(共5個)用戶可以進行Telnet登錄
Router(config-line)#password 111 //設定密碼111
Router(config-line)#login local //開啟密碼

設定遠程登錄telnet用戶名和密碼
- 登錄權限為普通
Router>enable
Router#configure terminal
Router(config)#username aaa password cisco //非加密
Router(config)#username aaa secret cisco //加密
Router(config)#line vty 0 4
Router(config-line)#login local

設定遠程登錄telnet用戶名和密碼(特權模式)
- 登錄后為特權模式
Router>enable
Router#configure terminal
Router(config)#username ddd privilege 15 secret ddd
Router(config)#line vty 0 4
Router(config-line)#login local
Router(config-line)#no password //取消telnet遠程登錄
Router(config-line)#no login //不進行密碼檢查

登錄超時自動斷開
Router>enable
Router#configure terminal
Router(config)#line vty 0 4
Router(config-line)#exec-timeout 20 0 //20分鐘0秒自動斷開
登錄次數限制與時間鎖定
Router>enable
Router#configure terminal
Router(config)#login block-for 1800 attempts 10 within 600 //600秒內登錄錯誤10次,鎖定1800秒
配置ssh登錄
Router>enable
Router#configure terminal
Router(config)#hostname router1
router1(config)#ip domain-name neoshi.net //必須要先設定hostname和domain才能進行下一步
router1(config)#crypto key generate rsa
The name for the keys will be: router1.neoshi.net
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 1024 //生成1024rsa秘鑰,支持360-2048
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
Router(config)#username aaa secret aaa
Router(config)#ip ssh authentication-retries 4 //設定ssh認證次數為4,可以為0-5之間
router1(config)#line vty 0 4
*3? 1 0:14:8.8: %SSH-5-ENABLED: SSH 1.99 has been enabled
router1(config-line)#login local
router1(config-line)#transport input ssh //設定登錄模式為ssh,默認為all
privilege等級介紹
privilege等級切換
- privilege一共有15個等級,沒有enable密碼的情況下,不能從低等級切換到高等級,否則會報錯
router1>en 2
% Error in authentication.
- 加入需要從en 0切換到en 3 ,需要回到en 15 為en 3 設定一個密碼,然后進行切換
router1>en 15
Router1#configure terminal
router1(config)#enable secret level 3 a //為en 3 設定密碼為a
router1>en 3
Password:
router1# //不同的級別使用的命令會不一樣
配置日志服務器
Router>enable
Router#configure terminal
router1(config)#logging on //打開日志服務
router1(config)#logging trap debugging //設定等級為debugging
router1(config)#logging x.x.x.x //設定日志服務器地址
router1(config)#service timestamps log datetime //設定時間戳
路由器配置
Router>enable
Router#configure terminal
Router(config)#interface FastEthernet0/0
Router(config-if)#ip address 10.1.1.254 255.255.255.0 //系結地址
Router(config-if)#no shutdown //啟動介面
Router(config-if)#ip route 目的地址 子網掩碼 路由器下一跳 //設定靜態路由
ACL配置
標準ACL
- 順序匹配原則
- 標準訪問控制串列因為只能限制源IP地址,因此應該把ACL放到離目標最近的埠出方向上,
Router>enable
Router#configure terminal
Router(config)#access-list 1 deny 192.168.1.1 //拒絕192.168.1.1流量
Router(config)#access-list 1 permit any //允許任何流量通過
Router(config)#interface fastEthernet 0/1 //進入介面0/1
Router(config-if)#ip access-group 1 out //設定ACL為出方向
擴展ACL
- 擴展ACL可以對資料包中的源、目標IP地址以及埠號進行檢查,所以可以將該ACL放置在通信路徑中的任一位置,但是,如果放到離目標近的地方,每臺路由器都要對資料進行處理,會更多的消耗路由器和帶寬資源,放到離源最近的路由器埠入方向直接就將拒絕資料丟棄,可以減少其他路由器的資源占用以及帶寬占用,
Router>enable
Router#configure terminal
Router(config)#access-list 100 deny tcp host 192.168.1.1 host 172.20.1.1 eq www //拒絕從192.168.1.1發到172.20.1.1的tcp協議,埠為80
Router(config)#access-list 100 permit ip any any //允許任何流量
Router(config)#interface fastEthernet 0/0 //設定介面為0/0
Router(config-if)#ip access-group 100 in //設定ACL為入方向
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/500762.html
標籤:其他
