Hướng dẫn cấu hình Firewall Cisco ASA cơ bản

hocomoihinhthuc

W-------
06/07/2015
11
22 bài viết
Hướng dẫn cấu hình Firewall Cisco ASA cơ bản
PHẦN 1: CÀI ĐẶT ASA GIẢ LẬP TRÊN GNS3
Cisco Firewall ASA chạy hệ điều hành 8.4.2 trở lên có hỗ trợ tính năng Identity Firewall . Đây là tính năng mà các dòng next-generation firewalls hỗ trợ, đặc biệt là hãng Palo Alto.
1. Download bản cài đặt GNS3 (tại thời điểm viết bài này, version là 1.3.7)
http://www.gns3.net

Note: các bạn phải đăng ký tài khoản sử dụng
2. Download IOS dùng để giả lập ASA 8.4.2 trên GNS3
http://www.mediafire.com/download.php?ssadit26tl3llms

Các bạn unzip và được 2 file asa842-initrdasa842-vmlinuz
Note: không được giải nén file asa842-initrd
3. Cài đặt ASA trên GNS3
Edit/Preferrences/QEMU/QEMU VMs

Chọn New và khai báo như ví dụ ở dưới
14899399441.jpg


14899399442.png

14899399443.png


Cài đặt 2 file asa842-initrd
14899399444.png


Chọn Finish
14899399445.jpg


Chọn Apply để kết thúc cài đặt ASA trên GNS3.
4. Chạy ASA và active the license
Kéo & thả ASA vào màn hình làm việc, click phải chuột và chọn Start, sau đó là Console
14899399446.jpg

Kết quả cuối cùng:
14899399447.jpg

Nhập lệnh ciscoasa>enable, bấm Enter khi có lời nhắc nhập password, nhập tiếp lệnh ciscoasa> show version, các bạn sẽ thấy rất nhiều tính năng bị disable.
14899399448.jpg

Để active thêm tính năng, các bạn cần nhập license (tham khảo key ở đây: http://www.vnpro.org/forum/forum/cc...f-snaa/32677-cisco-asa-firewall-8-4-2-on-gns3 )
ciscoasa# activation-key 0x4a3ec071 0x0d86fbf6 0x7cb1bc48 0x8b48b8b0 0xf317c0b5
và khởi động lại ASA bằng lệnh ciscoasa# reload
14899399449.jpg


Note: This platform has an ASA 5520 VPN Plus license. :)
(Blog "Học Ở Mọi Hình Thức":
https://duchm72.wordpress.com/2015/07/09/updated-201507-cisco-asa-1-cai-dat-gia-lap-tren-gns3/ )
 
Chỉnh sửa lần cuối bởi người điều hành:
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Re: Hướng dẫn cấu hình Firewall Cisco ASA cơ bản

PHẦN 2: CẤU HÌNH INTERFACE
Các bạn dựng topology sau trên GNS3:
20150710.topology.png

Note: đám mây C1 kết ni vào NIC Vmware1 hoc Vmware8 để dùng ASDM (cho các bài lab khác)
1. Start ASA
Click phải chuột vào ASA1, chọn Start và cửa sổ QEMU sẽ được mở (Note: không đóng ca s này). Sau đó chọn Console. Tại dấu nhắc ciscoasa> nhập lệnh enable (Note: enable password=null)
ciscoasa> enable
Password:
ciscoasa#
2.Nhập lệnh configure terminal để chuyển vào Global Configure Mode
ciscoasa# configure terminal
ciscoasa(config)#
***************************** NOTICE *****************************
Help to improve the ASA platform by enabling anonymous reporting,
which allows Cisco to securely receive minimal error and health
information from the device. To learn more about this feature,
please visit: http://www.cisco.com/go/smartcall
Would you like to enable anonymous error reporting to help improve
the product? [Y]es, [N]o, [A]sk later: N
In the future, if you would like to enable this feature,
issue the command "call-home reporting anonymous".
Please remember to save your configuration.
ciscoasa(config)#
3.Cấu hình cổng inside
ciscoasa(config)# interface gigabitEthernet 1
ciscoasa(config-if)# ip address 172.16.1.254 255.255.255.0
ciscoasa(config-if)# nameif inside
INFO: Security level for "inside" set to 100 by default. //mc bo mt "100" được gán t đng cho port có tên là "inside", đây là cng ni vào min TRUST
ciscoasa(config-if)# no shutdown
4.Cấu hình cổng outside
ciscoasa(config)# interface gigabitEthernet 3
ciscoasa(config-if)# ip address 1.1.1.4 255.255.255.248
ciscoasa(config-if)# nameif ouside
INFO: Security level for "ouside" set to 0 by default. //mc bo mt "0" được gán t đng cho các port có tên không phi là "inside", đây là cng ni vào min UNTRUST
ciscoasa(config-if)# no shutdown
5.Cấu hình cổng dmz
ciscoasa(config)# interface gigabitEthernet 2
ciscoasa(config-if)# ip address 192.168.1.254 255.255.255.0
ciscoasa(config-if)# nameif dmz
INFO: Security level for "dmz" set to 0 by default.
ciscoasa(config-if)# security-level 50 //khai báo li mc bo mt 0< x
 
Chỉnh sửa lần cuối bởi người điều hành:
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Comment
Re: Hướng dẫn cấu hình Firewall Cisco ASA cơ bản

PHẦN 3: ĐIỀU HƯỚNG TRAFFIC
Khi cấu hình ASA, các port phải được gán với 1 mức bảo mật (security level) từ 0 - 100, và hình thành các miền (zone) Tin cậy (trustworthy) hoặc Không tin cậy (untrustworthy). Mặc định, traffic khởi tạo từ các miền khác nhau sẽ được điều hướng như sau:
- Permit đối với outbound traffic (khởi tạo từ miền có mức bảo mật cao, vd: inside, ra miền có mức bảo mật thấp,vd: outside)
- Deny đối với inbound traffic (khởi tạo từ miền có mức bảo mật thấp, vd: outside, vào miền có mức bảo mật cao,vd: inside)
- Inspect đối với outbound traffic (trừ ICMP, tính năng này sẽ phân tích rõ hơn ở bài khác) và permit đối với return traffic
Các bạn xem Hình 1: Denied Traffic
fetch

Hình 2: Permitted Traffic
fetch

Note: trong hình s 2, traffic khi to t Outside vào DMZ phi được permit bi ACL hoc chính sách Inspection
Các bạn có thể kiểm thử theo topology bài Cisco ASA - 2.Cu hình Interface, như sau:
fetch

Trên R1, R2, R3: bật các dịch vụ Telnet, HTTP; cấu hình default-gateway hoặc default-route về phía ASA.
- Kiểm thử outbound traffic
R1#ping 1.1.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R3#debug ip icmp
ICMP packet debugging is on
R3#
*Oct 7 17:03:35.707: ICMP: echo reply sent, src 1.1.1.3, dst 172.16.1.1, topology BASE, dscp 0 topoid 0
R3#
*Oct 7 17:03:37.723: ICMP: echo reply sent, src 1.1.1.3, dst 172.16.1.1, topology BASE, dscp 0 topoid 0
R3#
*Oct 7 17:03:39.683: ICMP: echo reply sent, src 1.1.1.3, dst 172.16.1.1, topology BASE, dscp 0 topoid 0
R3#
*Oct 7 17:03:41.679: ICMP: echo reply sent, src 1.1.1.3, dst 172.16.1.1, topology BASE, dscp 0 topoid 0
R3#
*Oct 7 17:03:43.723: ICMP: echo reply sent, src 1.1.1.3, dst 172.16.1.1, topology BASE, dscp 0 topoid 0
Note: Do ICMP không được inspect nên ASA chn ICMP reply do R3 tr v.
R1#telnet 1.1.1.3
Trying 1.1.1.3 ... Open
User Access Verification
Password:
R3>
ciscoasa# show conn
1 in use, 1 most used
TCP outside 1.1.1.3:23 inside 172.16.1.1:17657, idle 0:00:27, bytes 148, flags UIO
Note: traffic Telnet (do R1 gi ti R3) được inspect và ASA permit đi vi return traffic (do R3 tr v)
- Kiểm thử Inbound traffic
R1#debug ip icmp
ICMP packet debugging is on
R3#ping 172.16.1.1 repeat 100
Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
...............................................
ciscoasa# show conn
0 in use, 1 most used
R1#debug telnet
Incoming Telnet debugging is on
R3#telnet 172.16.1.1
Trying 172.16.1.1 ...
% Connection timed out; remote host not responding
ciscoasa# show conn
0 in use, 1 most used
Note: ASA deny các traffic khi to t R3 đến R1

Tham kh
o:
- CCNA Security Curriculum
- Cisco.Press.CCNP.Security.FIREWALL.642-618.Official.Cert.Guide.May.2012
- Cisco ASA All-in-One Next-Generation Firewall, IPS, and VPN Services, Third Edition

(Blog "Học Ở Mọi Hình Thức":http://wp.me/p3rknI-7v)
 
Chỉnh sửa lần cuối bởi người điều hành:
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Comment
Re: Hướng dẫn cấu hình Firewall Cisco ASA cơ bản

PHẦN 4: TẬP LỆNH CƠ BẢN

1.Cấu hình mặc định: ASA dòng 5510 và cao hơn đã được cấu hình trước management interface, DHCP và ASDM
20150710.asa_confg_1.jpg

Cấu hình mặc định của ASA 5505:
20150710.asa5505.jpg

20150710.asa5505-b.jpg

2. So sánh 1 số lệnh cơ bản trên ASA với IOS Router/Switch
20150710.asa_confg_2.jpg

3. Một số thao tác lệnh khác với IOS Router/Switch
3.1.Thực hiện lệnh ở các mode khác nhau.
Ví dụ: thực hiện lệnh showconfig mode, config-if mode, config-router mode ...
ciscoasa(config)# show run
: Saved
:
ASA Version 8.4(2)
!
ciscoasa(config-if)# show run
: Saved
:
ASA Version 8.4(2)
!
ciscoasa(config-router)# show run
: Saved
:
ASA Version 8.4(2)
3.2. Dùng lệnh help để xem mô tả ngắn gọn và cú pháp
Ví dụ:
ciscoasa# help reload
USAGE:
reload [quick] [noconfirm] [save-config] [max-hold-time [hhh:]mm]
[{in [hhh:]mm | at hh:mm [{Mon dd | dd Mon}] }] [reason ]
reload cancel
DESCRIPTION:
reload Halt and reload system
SYNTAX:
quick Reload without properly shutting down each subsystem
noconfirm Reload immediately without asking for confirmation
save-config Save configuration before reload
max-hold-time Maximum hold time for orderly reload
at Reload at a specific time/date
in Reload after a time interval
reason Reason for reload
3.3. Để ngắt lệnh show, sử dụng phím Q
Ví dụ:
ciscoasa# show run
: Saved
:
ASA Version 8.4(2)
!
hostname ciscoasa
enable password 8Ry2YjIyt7RRXU24 encrypted
passwd 2KFQnbNIdI.2KYOU encrypted
names
!
interface GigabitEthernet0
shutdown
no nameif
no security-level
no ip address
!
interface GigabitEthernet1
nameif inside
security-level 100
ip address 172.16.1.4 255.255.255.0
!
interface GigabitEthernet2
nameif dmz
security-level 50
ip address 192.168.1.4 255.255.255.0
!
// Gõ phím Q đ ngt lnh
4.Lệnh write
ciscoasa# write ?
erase Clear flash memory configuration // thay thế erase startup-config
memory Save active configuration to the flash // tương đương copy running-config startup-config
net Save the active configuration to the tftp server // tương đương copy running-config tftp:
standby Save the active configuration on the active unit to the flash on
the standby unit
terminal Display the current active configuration // tương đương show running-config

5. Cấu hình default route
route interface-name 0.0.0.0 0.0.0.0 next-hop-ip-address

20150710.asa_confg_3.jpg

6. Cấu hình TelnetSSH
20150710.asa_confg_4.jpg

Kiểm tra và hủy kết nối Telnet:
ciscoasa(config)# who ?
exec mode commands/options:
Hostname or A.B.C.D IP address
Hostname or X:X:X:X::X IPv6 address

ciscoasa(config)# who
0: 10.0.11.17
ciscoasa(config)# kill ?
exec mode commands/options:
Session ID as displayed by the who command
ciscoasa(config)# kill 0
7. Cấu hình dịch vụ DHCP
20150710.asa_confg_5.jpg

20150710.asa_confg_6.jpg

Note: Trong ví d này, ASA là DHCP client min outside và là DHCP server đi vi inside. Với lệnh dhcpd auto_config outside, ASA sẽ gửi thông tin WINS/DNS/Domain (nhận được từ outside) cho client cổng inside
8. Quản lý cấu hình
8.1 Xóa 1 phần của cấu hình hiện tại :
ciscoasa(config)# clear configure ?
configure mode commands/options:
aaa Clear user authentication, authorization and
accounting configuration
aaa-server Clear aaa-server configuration
access-group Clear access-group configuration
access-list Clear configured access control elements
all Clear all configuration
arp Clear arp configuration
asdm Clear Device Manager configuration
auth-prompt Clear configured authentication challenge,
reject and acceptance prompts
auto-update Clear Auto Update configuration
banner Clear login/session banners
boot Clear all boot configuration
call-home Reset Smart Call-Home configuration to default
checkheaps Clear configured checkheaps
class-map Clear class-map configuration
client-update Clear the entire client-update configuration
clock Clear clock configuration
command-alias Clear configured command aliases
compression Clear global compression configuration
console Reset console settings to defaults
coredump Clear coredump configuration, removes coredump
filesystem and its contents

Vd:
ciscoasa(config)# clear configure interface // xóa tất cả cấu hình interface
ciscoasa(config)# clear configure access-list // xóa tất cả cấu hình access-list
8.2. Xóa tất cả cấu hình hiện tại và không cần khởi động lại ASA
ciscoasa(config)# clear configure all
8.3. Khôi phục cấu hình mặc định
ciscoasa(config)# configure factory-default

Tham kho:
- CCNA Security Curriculum
- Cisco.Press.CCNP.Security.FIREWALL.642-618.Official.Cert.Guide.May.2012
- Cisco ASA All-in-One Next-Generation Firewall, IPS, and VPN Services, Third Edition

(Blog "Học Ở Mọi Hình Thức": https://duchm72.wordpress.com/2014/10/18/cisco-asa-4-tap-lenh-co-ban/)
 
Chỉnh sửa lần cuối bởi người điều hành:
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Comment
Re: Hướng dẫn cấu hình Firewall Cisco ASA cơ bản

PHẦN 5: CẤU HÌNH SỬ DỤNG ASDM (GUI OVER HTTPS)

1.Topology
20150710.asa_confg_7.jpg

2. Download image file vào flash:
Trên thiết bị thật, file asdm-x.bin đã có sẵn. Khi dùng GNS3, bạn phải copy file này từ TFTP server. Trong ví dụ trên, ASA kết nối với TFTP server qua NIC Vmware1.
Cấu hình Interfacecopy file cụ thể như sau:
ciscoasa(config)# show running-config interface gigabitEthernet 4
!
interface GigabitEthernet4
nameif management // có th là cng vi nameif khác
security-level 100
ip address dhcp // có th gán đa ch tĩnh
Note: Không dùng lnh management-only đi vi cng G4 nên có th truyn data bình thường
Copy file asdm-x.bin (vd: asdm-713.bin) vào thư mục C:TFTP-Root và bật TFTP server
20150710.tftp.jpg

Thực hiện lệnh copy sau:
ciscoasa# copy tftp: flash:
Address or name of remote host []? 192.168.59.1
Source filename []? asdm-713.bin
Destination filename [asdm-713.bin]?
Accessing tftp://192.168.59.1/asdm-713.bin...!!!!!!!!!!!!!!!!!!!!!
3. Cấu hình cho phép sử dụng ASDM:
ciscoasa# show running-config username
username admin password eY/fQXw7Ure8Qrz7 encrypted
!
ciscoasa# show running-config http
http server enable
http 0.0.0.0 0.0.0.0 management
!
ciscoasa# show running-config aaa
aaa authentication http console LOCAL
4. Kết nối từ PC
4.1. Dùng web browser
20150710.asdm1.jpg

click chọn mục I Understand the Risks
20150710.asdm2.jpg

Chọn Confirm Security Exception
20150710.asdm3.jpg

Chọn Run ASDM hoặc Run Startup Wizard
Note: Nếu mun copy bn ASDM chy trên PC thì click Install ASDM Launcher and Run ASDM
4.2. Dùng ASDM Launcher
Các bạn thường gặp lỗi như sau:
20150710.asdm4.jpg

Để khắc phục, các bạn tham khảo http://duchm72.wordpress.com/2014/06/30/cisco-asdm-is-blocked-by-java/
hoặc theo hướng dẫn sau:
20150710.asdm5.jpg

Chọn View, tab Details, Export
20150710.asdm6.jpg

Lưu file với kiểu (PEM)
Mở Java Control Panel
20150710.asdm7.jpg

Chọn Manager Certificates...
20150710.asdm8.jpg

Mở Certificate type, chọn Trusted Certificates, Secure Site Signer CA. Sau đó Import certificate (*.PEM) đã export ở trên.
20150710.asdm9.jpg

Mở lại ASDM Launcher
20150710.asdm10.jpg

Tham kho:
- CCNA Security Curriculum

(Blog "Học Ở Mọi Hình Thức": https://duchm72.wordpress.com/2014/10/22/cisco-asa-5-cau-hinh-asdm-gui-over-https/)
 
Chỉnh sửa lần cuối bởi người điều hành:
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Comment
ảnh bài này bị lỗi nhiều quá bác ơi, có mấy chỗ toàn thấy ảnh Olly :D
 
Mời các bạn tham gia Group WhiteHat để thảo luận và cập nhật tin tức an ninh mạng hàng ngày.
Lưu ý từ WhiteHat: Kiến thức an ninh mạng để phòng chống, không làm điều xấu. Luật pháp liên quan
Comment
Bên trên