Cisco AutoSecure - Thiết lập bảo mật trên Router Cisco 1 cách tự động
Hôm nay chúng ta sẽ cùng tìm hiểu về việc bảo mật các thiết bị router của Cisco khi triển khai.
Bảo mật luôn là các vấn đề quan trọng mà mọi doanh nghiệp cần phải quan tâm khi thiết kế hệ thống mạng, từ switch, router, firewall hay wifi. Có rất nhiều các tài liệu của hãng khuyến nghị cho chúng ta các tính năng nên tắt hoặc bật trên hệ thống để tăng tính bảo mật cho từng thiết bị. Tuy nhiên thì khi cấu hình chúng ta thường bỏ qua các vấn đề này, do nó có khá nhiều và mất nhiều thời gian để tìm hiểu, chúng ta cần rất nhiều lệnh và các tham số khác nhau tùy từng dịch vụ.
Do vậy, trong bài viết này, mình sẽ hướng dẫn các bạn sử dụng 1 tính năng cực kỳ đơn giản, cấu hình nhanh trên các thiết bị Router của Cisco để tăng tính bảo mật cho thiết bị, đó chính là AutoSecure.
Cisco AutoSecure là gì?
AutoSecure là 1 tính năng trên Router Cisco, được sử dụng để bảo vệ các thiết bị Router của Cisco chỉ bằng 1 lệnh duy nhất. Khi được enable trên router, nó sẽ vô hiệu hóa các dịch vụ IP phổ biến nhưng ít được sử dụng, có thể bị khai thác cho các cuộc tấn công mạng, và kích hoạt các dịch vụ IP và tính năng có thể hỗ trợ bảo vệ mạng khi bị tấn công. Đồng thời nó cũng đơn giản hóa, và triển khai nhanh 1 số cấu hình cơ bản ban đầu như SSH, tạo các tài khoản đăng nhập ban đầu.
Để bật AutoSecure lên thì rất đơn giản, các bạn có thể triển khai khi cấu hình mới, hoặc trên router đang hoạt động rồi cũng được. Tuy nhiên trước khi bật tính năng này lên, các bạn cần nắm được các thay đổi của Router khi lệnh được thực thi để xem các thay đổi này có ảnh hưởng gì đến dịch vụ của các bạn không.
Cisco AutoSecure bảo vệ được những gì?
Tính năng AutoSecure khi được bật lên thì nó sẽ tự động kích hoạt bảo vệ toàn diện Router, bao gồm bảo vệ Management Plane, Forwarding Plane, và cả 1 số tính năng security hoặc logging. Nếu các bạn không sử dụng AutoSecure thì cũng có thể gõ từng câu lệnh theo từng dịch vụ cũng được.
Có khá nhiều sự thay đổi với các tính năng trên Router, và AutoSecure cũng có thể khác nhau giữa các phiên bản OS nên mình sẽ chỉ nói về 1 số tính năng cơ bản thôi nhé.
Các Features ảnh hưởng bởi Cisco AutoSecure
Dưới đây là các features mà Cisco Auto Secure sẽ tác động vào để giảm thiểu rủi ro cho thiết bị. Chỉ thông qua 1 câu lệnh đơn giản, các bạn có thể tác động lên rất nhiều tính năng có thể sẽ gây ra các nguy cơ bảo mật. Các bạn có thể tìm hiểu nếu cần hiểu rõ về tác động của nó với hệ thống mạng hiện tại của mình.
Disables the following Global Services |
|
Enables the following Global Services |
|
Disables the following services per interface |
|
Provides logging for security |
|
Secures access to the router |
|
Secures the Forwarding Plane |
|
Disable các dịch vụ Global
Đầu tiên chúng ta sẽ tìm hiểu 1 số tính năng mà AutoSecure sẽ vô hiệu hóa 1 số dịch vụ ở mode Global:
- Finger: Tính năng Finger sẽ thu thập các thông tin về hệ thống trước khi bị tấn công. Nếu được bật, thông tin có thể khiến thiết bị của bạn dễ bị tấn công, và tính năng này chúng ta cũng không sử dụng.
- PAD là trình biên dịch và giải mã gói giữa thiết bị PAD và các máy chủ, tính năng này được bật lên có thể khiến thiết bị của các bạn dễ bị tấn công dựa vào các thông tin mà PAD xử lý.
- Small Servers có thể gây ra các cuộc tấn công TCP và UDP, hậu quả là tiêu tốn tài nguyên của CPU.
- Bootp và HTTP cũng là các giao thức không an toàn. Nếu các bạn sử dụng HTTP thì nên có access-list đi kèm, hoặc chúng ta có thể tắt đi và sử dụng HTTPS.
- Identification Service là 1 giao thức không an toàn, cho phép 1 người truy vấn TCP để nhận dạng. Hacker có thể truy cập thông tin cá nhân về người dùng.
- CDP thì rất phổ biến trong hệ thống mạng để chúng ta có thể dễ dàng xây dựng topo. Tuy nhiên nếu 1 số lượng lớn các gói CDP được gửi ra có thể khiến Router tiêu tốn nhiều bộ nhớ hơn. Các bạn có thể bật lại nếu cần.
- NTP là giao thức cực kỳ quan trọng, mà các bạn nên cấu hình khi triển khai hệ thống. Tuy nhiên nó lại là giao thức không an toàn và cũng dễ bị tấn công. Nên nếu cấu hình NTP các bạn nên cấu hình xác thực với MD5 và access-group, và sau đó tắt NTP trên các interface không cần thiết. AutoSecure sẽ disable NTP đi, tuy nhiên 1 số phiên bản OS thì mình thấy Cisco đã bỏ NTP trong AutoSecure.
- Source Routing chỉ được sử dụng khi các bạn debug hoặc xử lý sự cố liên quan đến packet thôi. Nên tính năng này nên tắt đi khi hệ thống hoạt động bình thường.
Disable các dịch vụ trên Interface
Tiếp theo là các dịch vụ mà AutoSecure sẽ disable trên từng Interface.
- ICMP: Trên từng Interface thì ICMP cũng rất dễ bị tấn công bằng cách khai thác các lỗ hổng bảo mật.
- ICMP unreachables là nguyên nhân của nhiều cuộc tấn công DoS dựa trên ICMP mà rất nhiều hệ thống đã gặp phải.
- ICMP mask reply messages có thể cung cấp cho hacker biết subnet mask của các mạng LAN.
- Proxy-Arp cũng là nguyên nhân của nhiều cuộc tấn công DoS.
- Directed Broadcast là nguyên nhân tiềm ẩn của các cuộc tấn công SMURF cho DoS.
- MOP (Maintenance Operations Protocol) thì mình thấy chả ai dùng. Tất cả các tính năng này sẽ được AutoSecure disable trên toàn bộ các cổng.
Các dịch vụ sẽ được enable ở global
Có 1 số tính năng sẽ được AutoSecure enable ở mode Global để bảo mật cho Router, các bạn có thể tham khảo ý nghĩa của 1 số option:
- Password-encryption service: các dịch vụ mã hóa mật khẩu thì tất nhiên chúng ta nên bật. Mặc dù các password bị mã hóa này khá dễ dàng để crack, tuy nhiên chúng ta sẽ tránh được nhiều trường hợp có thể lộ password.
- Các option liên quan đến TCP như tcp-keepalives-in và tcp-keepalives-out sẽ đảm bảo các phiên TCP bị kết thúc bất thường sẽ bị xóa.
Các tính năng Login, Logging, Security
Đối với các option liên quan đến việc truy cập vào Router, nếu thiết bị của các bạn đang được quản lý bởi các ứng dụng Network Management, thì khi bật AutoSecure có thể gây gián đoạn kết nối với các phần mềm này.
AutoSecure sẽ cho chúng ta cấu hình các thông số ban đầu như bannner, password, Telnet, SSH, AAA. Đây là các thông số mà chúng ta cũng phải thiết lập ban đầu, nên các bạn có thể sử dụng AutoSecure để cấu hình nhanh được.
Phần log thì AutoSecure sẽ bật 1 số tính năng liên quan đến log như số thứ tự, thời gian, sao chép log vào bộ nhớ đệm… Nói chung là Log thì rất quan trọng trong tất cả hệ thống, các bạn nên bật log trên tất cả các thiết bị.
Bảo vệ Forwarding Plane
Đối với Forwarding Plane, thì Auto Secure sẽ bật CEF lên. Đối với bản OS cũ từ rất lâu rồi thì có thể chưa dùng CEF, còn hiện tại thì CEF đã được enable mặc định rồi.
Ngoài ra nếu router của các bạn có license SEC và sử dụng firewall trên router, thì AutoSecure sẽ cấu hình thêm các thông số liên quan đến bảo mật, kiểu như các ngưỡng an toàn để tránh chúng ta bị tấn công gây cạn kiệt hệ thống.
Cấu hình AutoSecure trên Router Cisco
Về lý thuyết và hiểu được ý nghĩa của các tính năng thì rất dài, nhưng phần cấu hình thì cực kỳ đơn giản.
Trong mode EXEC các bạn gõ lệnh auto secure là được. Nó sẽ có 1 vài option phía sau, các option này cũng khác nhau giữa các phiên bản OS. Các bạn có thể bật Full, bật trên từng phần như management plane, forwarding plane đều được. Tùy chọn no-interact thì mọi thứ sẽ được tự động, còn full thì các bạn sẽ cần nhập 1 số thông số để cấu hình.
Router#auto secure ? firewall AutoSecure Firewall forwarding Secure Forwarding Plane full Interactive full session of AutoSecure login AutoSecure Login management Secure Management Plane no-interact Non-interactive session of AutoSecure ntp AutoSecure NTP ssh AutoSecure SSH tcp-intercept AutoSecure TCP Intercept Router#auto secure
Tùy nhu cầu thôi, mình sẽ bật full luôn. Full thì các bạn có thể chọn option full hoặc chỉ cần gõ auto secure đều được. Chúng ta sẽ cần nhập 1 số thông số trên Router.
Router#auto secure --- AutoSecure Configuration --- *** AutoSecure configuration enhances the security of the router, but it will not make it absolutely resistant to all security attacks *** AutoSecure will modify the configuration of your device. All configuration changes will be shown. For a detailed explanation of how the configuration changes enhance security and any possible side effects, please refer to Cisco.com for Autosecure documentation. At any prompt you may enter '?' for help. Use ctrl-c to abort this session at any prompt. Gathering information about the router for AutoSecure Is this router connected to internet? [no]: yes #Chọn Yes nếu Router có kết nối Internet Enter the number of interfaces facing the internet [1]: 1 #Nhập số lượng cổng WAN Interface IP-Address OK? Method Status Protocol Ethernet0/0 unassigned YES unset administratively down down Ethernet0/1 unassigned YES unset administratively down down Ethernet0/2 unassigned YES unset administratively down down Ethernet0/3 unassigned YES unset administratively down down Enter the interface name that is facing the internet: Ethernet0/0 #Nhập tên Interface kết nối ra Internet Securing Management plane services... Disabling service finger Disabling service pad Disabling udp & tcp small servers Enabling service password encryption Enabling service tcp-keepalives-in Enabling service tcp-keepalives-out Disabling the cdp protocol Disabling the bootp server Disabling the http server Disabling the finger service Disabling source routing Disabling gratuitous arp #Phía trên là các dịch vụ sẽ bị Enable hoặc Disable trên Router Here is a sample Security Banner to be shown at every access to device. Modify it to suit your enterprise requirements. Authorized Access only This system is the property of So-&-So-Enterprise. UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED. You must have explicit permission to access this device. All activities performed on this device are logged. Any violations of access policy will result in disciplinary action. Enter the security banner {Put the banner between k and k, where k is any character}: k Day la Router cua CNTTShop, nghiem cam truy cap bat hop phap k #Nhập Banner, banner sẽ nằm phía trong 2 ký tự k, các bạn có thể xem ví dụ mà Cisco đưa ra ở trên Enable secret is either not configured or is the same as the enable password Enter the new enable secret: #Nhập Enable Secret Password Confirm the enable secret : #Nhập lại Enable Secret Password Enter the new enable password: #Nhập Enable Password, password này nên khác với pass ở trên Confirm the enable password: #Nhập lại Enable Password Configuration of local user database Enter the username: admin #Tạo 1 tài khoản local Enter the password: #Nhập password cho tài khoản admin Confirm the password: #Nhập lại password cho tài khoản admin Configuring AAA local authentication Configuring console, Aux and vty lines for local authentication, exec-timeout, transport Securing device against Login Attacks Configure the following parameters Blocking Period when Login Attack detected: 15 Maximum Login failures with the device: 3 Maximum time period for crossing the failed login attempts: 20 Configure SSH server? [yes]: yes #Chọn Yes nếu các bạn muốn cấu hình SSH Enter the hostname: R-Core #Nhập hostname cho Router Enter the domain-name: cnttshop.vn #Nhập domain name cho SSH Configuring interface specific AutoSecure services Disabling the following ip services on all interfaces: no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply Disabling mop on Ethernet interfaces Securing Forwarding plane services... #Phía trên là các dịch vụ sẽ bị disable trên toàn bộ interface Enabling unicast rpf on all interfaces connected to internet #Cổng kết nối Internet sẽ được enable unicast rpf Configure CBAC Firewall feature? [yes/no]: yes #Nếu Router của các bạn có license SEC, thì các bạn có thể chọn Yes, còn nếu không có license thì nếu chọn Yes sẽ báo lỗi do các câu lệnh security không hỗ trợ trên bản thường. This is the configuration generated: #Router sẽ hiển thị các câu lệnh mà AutoSecure sẽ cấu hình no service finger no service pad no service udp-small-servers no service tcp-small-servers service password-encryption service tcp-keepalives-in service tcp-keepalives-out no cdp run no ip bootp server no ip http server no ip finger no ip source-route no ip gratuitous-arps no ip identd banner motd ^C Day la Router cua CNTTShop, nghiem cam truy cap bat hop phap ^C security passwords min-length 6 security authentication failure rate 10 log enable secret 5 $1$Kkr3$X7GJEHfZ.o07vXD6LetDP1 enable password 7 0817454B1D0A1019325A5E57 username admin password 7 03255F060F01011D1C5A aaa new-model aaa authentication login local_auth local line console 0 login authentication local_auth exec-timeout 5 0 transport output telnet line aux 0 login authentication local_auth exec-timeout 10 0 transport output telnet line vty 0 4 login authentication local_auth transport input telnet login block-for 15 attempts 3 within 20 hostname R-Core ip domain-name cnttshop.vn crypto key generate rsa general-keys modulus 1024 ip ssh time-out 60 ip ssh authentication-retries 2 line vty 0 4 transport input ssh telnet service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone logging facility local2 logging trap debugging service sequence-numbers logging console critical logging buffered interface Ethernet0/0 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled interface Ethernet0/1 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled interface Ethernet0/2 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled interface Ethernet0/3 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled access-list 100 permit udp any any eq bootpc interface Ethernet0/0 ip verify unicast source reachable-via rx allow-default 100 ip inspect audit-trail ip inspect dns-timeout 7 ip inspect tcp idle-time 14400 ip inspect udp idle-time 1800 ip inspect name autosec_inspect ftp timeout 3600 ip inspect name autosec_inspect http timeout 3600 ip inspect name autosec_inspect rcmd timeout 3600 ip inspect name autosec_inspect realaudio timeout 3600 ip inspect name autosec_inspect smtp timeout 3600 ip inspect name autosec_inspect tftp timeout 30 ip inspect name autosec_inspect udp timeout 15 ip inspect name autosec_inspect tcp timeout 3600 ip access-list extended autosec_firewall_acl permit udp any any eq bootpc deny ip any any interface Ethernet0/0 ip inspect autosec_inspect out ip access-group autosec_firewall_acl in ! end Apply this configuration to running-config? [yes]: yes #Chọn Yes để áp dụng cấu hình vào router Applying the config generated to running-config The name for the keys will be: R-Core.cnttshop.vn % The key modulus size is 1024 bits % Generating 1024 bit RSA keys, keys will be non-exportable... [OK] (elapsed time was 0 seconds) R-Core# 000027: *Feb 17 01:29:00.454 UTC: %AUTOSEC-1-MODIFIED: AutoSecure configuration has been Modified on this device R-Core#
Như vậy là xong.
Kiểm tra cấu hình AutoSecure
Các bạn có thể show running config để kiểm tra, sẽ có rất nhiều cấu hình đã được áp dụng trên router.
Các bạn cũng có thể xem lại các câu lệnh mà AutoSecure áp dụng trên thiết bị bằng lệnh show auto secure config. Router sẽ hiển thị toàn bộ câu lệnh đã tác động lên thiết bị.
R-Core#show auto secure config no service finger no service pad no service udp-small-servers no service tcp-small-servers service password-encryption service tcp-keepalives-in service tcp-keepalives-out no cdp run no ip bootp server no ip http server no ip finger no ip source-route no ip gratuitous-arps no ip identd banner ^C Day la Router cua CNTTShop, nghiem cam truy cap bat hop phap ^C security passwords min-length 6 security authentication failure rate 10 log enable secret 5 $1$Kkr3$X7GJEHfZ.o07vXD6LetDP1 enable password 7 0817454B1D0A1019325A5E57 user admin password 7 03255F060F01011D1C5A aaa new-model aaa authentication login local_auth local line console 0 login authentication local_auth exec-timeout 5 0 transport output telnet line aux 0 login authentication local_auth exec-timeout 10 0 transport output telnet line vty 0 4 login authentication local_auth transport input telnet login block-for 15 attempts 3 within 20 hostanme R-Core ip domain-name cnttshop.vn crypto key generate rsa general-keys modulus 1024 ip ssh time-out 60 ip ssh authentication-retries 2 line vty 0 4 transport input ssh telnet service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone logging facility local2 logging trap debugging service sequence-numbers logging console critical logging buffered interface Ethernet0/0 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled ! interface Ethernet0/1 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled ! interface Ethernet0/2 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled ! interface Ethernet0/3 no ip redirects no ip proxy-arp no ip unreachables no ip directed-broadcast no ip mask-reply no mop enabled ! access-list 100 permit udp any any eq bootpc interface Ethernet0/0 ip verify unicast source reachable-via rx allow-default 100 ip inspect audit-trail ip inspect dns-timeout 7 ip inspect tcp idle-time 14400 ip inspect udp idle-time 1800 ip inspect name autosec_inspect ftp timeout 3600 ip inspect name autosec_inspect http timeout 3600 ip inspect name autosec_inspect rcmd timeout 3600 ip inspect name autosec_inspect realaudio timeout 3600 ip inspect name autosec_inspect smtp timeout 3600 ip inspect name autosec_inspect tftp timeout 30 ip inspect name autosec_inspect udp timeout 15 ip inspect name autosec_inspect tcp timeout 3600 ip access-list extended autosec_firewall_acl permit udp any any eq bootpc deny ip any any interface Ethernet0/0 ip inspect autosec_inspect out ip access-group autosec_firewall_acl in R-Core#
Như vậy chỉ qua 1 câu lệnh đơn giản, chúng ta đã có thể giảm thiểu rủi ro cho router và ngăn chặn được 1 số phương thức tấn công mạng vào router rồi. Trong trường hợp các bạn không muốn cấu hình toàn bộ, thì các bạn vẫn có thể lựa chọn 1 số option trong AutoSecure để cấu hình như login, hệ thống log và management plane. Đây đều là các tính năng mà các bạn nên cấu hình trong mọi hệ thống
Ok như vậy chắc hẳn các bạn đã có thể sử dụng AutoSecure để bảo vệ các thiết bị Router khỏi các cuộc tấn công mạng rồi. Nếu các bạn có bất kỳ góp ý hay thắc mắc nào, hãy để lại comment để mọi người cùng trao đổi nhé.
Chúc các bạn thành công!
Bình luận bài viết!