路由器是網絡邊界的「守門人」,一旦失守,整個內網將暴露在攻擊面前。調查顯示,超 80% 的安全事件源於弱口令或默認配置。本文提煉十大必須落地的路由器安全加固措施,覆蓋作業系統、認證、協議、服務、審計、邊界防護六大維度,附帶配置示例與驗證方法,讓安全不再是一句口號。
風險:未修補的 CVE 漏洞(緩衝區溢出、權限提升、DoS)是攻擊者的「現成鑰匙」。
行動:
風險:字典撞庫、默認賬號密碼列表(admin/admin、cisco/cisco、root/root)公開可得。
行動:
service password-encryption(舊設備)/ enable algorithm-type scrypt secret <pwd>(新 IOS-XE/XR,SCRYPT/BCRYPT/PBKDF2)。aaa new-model + TACACS+/RADIUS 對接 ISE/AD/LDAP,落實最小權限、命令授權、審計記賬。no username admin、username netadmin privilege 15 ...。風險:明文協議洩露憑證、SNMP 寫操作被劫持、HTTP 管理界面暴力破解、小服務放大攻擊。
行動:
no ip http server no ip http secure-server。必須用 Web 時:僅允許 HTTPS、綁定 ACL 限制來源 IP、啟用 ip http authentication aaa。snmp-server community <str> RO <acl>。snmp-server group <grp> v3 auth、snmp-server user <user> <grp> v3 auth sha <pwd> priv aes 128 <pwd>。no snmp-server community <str> RW。no service tcp-small-servers no service udp-small-servers(Echo/Chargen/Discard/Daytime,易被用於反射放大 DDoS)。no cdp enable、no lldp transmit/receive,防止設備信息洩露(IOS 版本、IP、能力集)。crypto key generate rsa modulus 2048
ip ssh version 2
ip ssh time-out 60
ip ssh authentication-retries 3
line vty 0 4
transport input ssh
access-class MGMT_ACL in
ip icmp rate-limit unreachable 100
! 僅允許必要 ICMP 入站
access-list 110 permit icmp any any echo-reply
access-list 110 permit icmp any any time-exceeded
access-list 110 permit icmp any any unreachable
access-list 110 deny icmp any any
interface GigabitEthernet0/0
ip access-group 110 in
no ip directed-broadcast(防 Smurf 攻擊)。no ip source-route、no ip redirects(防路徑操控、偵察)。class-map match-any CONTROL_PLANE
match access-group name CPP_ACL
policy-map type control-plane CPP_POLICY
class CONTROL_PLANE
police rate 1000 pps conform-action transmit exceed-action drop
control-plane
service-policy input CPP_POLICY
ip tcp synwait-time 10、ip tcp path-mtu-discovery、調整 tcp max-incomplete 防 SYN Flood。in 方向。
deny ip 10.0.0.0/8 any、deny ip 172.16.0.0/12 any、deny ip 192.168.0.0/16 any、deny ip 127.0.0.0/8 any、deny ip 224.0.0.0/4 any(組播源)、deny ip host 0.0.0.0 any、deny ip host 255.255.255.255 any。out 方向。
permit ip 192.168.10.0/24 any(內網合法段),deny ip any any log(阻斷 IP 欺騙外發、僵尸網絡 C2 連接)。ip verify unicast source reachable-via rx(嚴格,邊界適用)或 any(鬆散,非對稱路徑場景)。key chain RIP_KEY + ip rip authentication mode md5 + ip rip authentication key-chain RIP_KEY。area 0 authentication message-digest,接口 ip ospf message-digest-key 1 md5 <pwd>。neighbor x.x.x.x password <pwd>(MD5)、bgp maxas-limit、neighbor x.x.x.x prefix-list IN/OUT、bgp rpki server(ROA 驗證)。no auto-summary、精細控制 redistribute、distribute-list、route-map。logging host 10.1.1.100 transport tcp port 6514(TLS 加密傳輸),logging trap informational、logging source-interface Loopback0。ntp server 10.1.1.10 prefer、ntp authenticate、clock timezone CST 8,確保日誌時間戳準確可關聯。logging config)、登錄失敗(login on-failure log)、ACL 命中(log 關鍵字)、鄰居狀態變化、接口翻動、CPU/內存閾值告警。line console 0 exec-timeout 5 0 login authentication CONSOLE_AAA no password(強制 AAA)。no service usb(視平台支持)。archive + path scp://user:pass@server/configs/$h、write-memory、time-period 1440。configure replace 一鍵回滾,archive timer 定時存檔。路由器安全不是「配一次終身免疫」,而是持續的生命週期管理。將上述十大鐵律落地為:標準化模板(Golden Config)+ 自動化合規巡檢(Ansible/NetBox/Nornir)+ 事件驅動的應急響應(PSIRT 訂閱→48h 修補)+ 定期紅藍對抗,才能構建經得起實戰考驗的網絡邊界防線。從今天開始,執行一次全網路由器安全基線掃描,補齊每一個缺口。