5.2.1 Giới thiệu mô hình
Tiếp theo sau đây chúng ta sẽ đi vào triển khai một giải pháp an ninh cụ thể với mô hình mạng gồm có 3 vùng cần được hệ thống Vyatta Core bảo vệ. Đó là vùng public, private và server. Trong đó cùng private cùng bao gồm 2 subnet.
Hình 14 – Mô hình triển khai giải pháp
Ghi chú: Để thực hiện bài lab này trên môi trường thực hành. Bạn sử dụng một máy ảo VMWare để cài đặt Vyatt Core. Trên máy ảo này bạn gắn 4 card mạng. Card eth0 kiểu Bridge, kết nối ra internet. Card eth1 kiểu Vnet1 kết nối với máy thật, tạo thành mạng LAN qua Vnet1. Card eth3 kiểu Vnet8, kết nối với máy thật, tạo thành mạng LAN qua Vnet8. Card eth2 kiểu Vnet0 kết nối với một máy ảo khác cũng có kiểu Vnet0, máy ảo mới này đóng vai trò làm server điển hình.
5.2.2 Cấu hình cơ bản
Các công việc cấu hình cơ bản bao gồm đặt hostname, ip cho các interface, default gateway nếu có.
Thực hành 16. Cấu hình hostname và interface
set interfaces ethernet eth0 address 192.168.17.6/24 set interfaces ethernet eth1 address 192.168.229.10/24 set interfaces ethernet eth2 address 192.168.204.10/24 set interfaces ethernet eth3 address 192.168.244.10/24 set system gateway-address 192.168.17.1
set system name-server 8.8.8.8 commit
28 8
5.2.3 Cấu hình NAT
Vyatta bây giờ đóng vai trò như một router đơn giãn. Nó chịu trách nhiệm định tuyến gói tin để hai vùng Server và Private có thể giao tiếp với bên ngoài. Điều đó có nghĩa là bạn cần cấu hình NAT trên Vyatta.
NAT Rule được thực hiện từ trên xuống, điều này rất quan trọng, vì nó có thể ảnh hưởng đến mục đích thiết lập của hệ thống. Đầu tiên bạn phải thêm một vài ip nữa vào eth0 để sử dụng NAT.
Thực hành 17. Thêm ip cho interface eth0
set interfaces ethernet eth0 address 192.168.17.11/24 set interfaces ethernet eth0 address 192.168.17.12/24 set interfaces ethernet eth0 address 192.168.17.13/24 commit
Thực hành 18. Cấu hình SNAT cho Server
set service nat rule 10 type source
set service nat rule 10 outside-address address 192.168.17.11 set service nat rule 10 source address 192.168.204.1
set service nat rule 10 outbound-interface eth0 commit
Thực hành 19. Cấu hình DNAT cho bên ngoài truy cập server
set service nat rule 20 type destination
set service nat rule 20 destination address 192.168.17.11 set service nat rule 20 inbound-interface eth0
set service nat rule 20 inside-address address 192.168.204.1 commit
Thực hành 20. Cấu hình SNAT cho private
set service nat rule 1000 type source
set service nat rule 1000 outbound-interface eth0
set service nat rule 1000 outside-address address 192.168.17.12
set service nat rule 1000 source address 192.168.244.2-192.168.244.254 set service nat rule 1001 type source
set service nat rule 1001 outbound-interface eth0
set service nat rule 1001 source address 192.168.204.0.2-192.168.204.254 commit
Kiểm tra lại cấu hình trên bằng hai lệnh: show nat rules
show nat translations
5.2.4 Cấu hình firewall
Thực hành 21. Tạo firewall zone
set zone-policy zone private description "Private zone (inside firewall)” set zone-policy zone public description "Public zone (outside firewall)" set zone-policy zone serverfarm description "Server Farm zone"
Thực hành 22. Thiết lập interface cho mỗi zone
set zone-policy zone public interface eth0 set zone-policy zone private interface eth1 set zone-policy zone serverfarm interface eth2 set zone-policy zone private interface eth3 commit
Mặc định tất cả các traffic đi qua firewall đều bị deny. Công việc tiếp theo bạn cần allow những traffic an toàn mà bạn mong muốn. Ví dụ ở đây chúng ta sẽ cho phép gói tin TCP port 80 và 433 và gói UDP port 53 đi ra (cho phép duyệt web).
Thực hành 23. Cấu hình rule
set firewall name to-public description "Allow authorized traffic to Public Zone"
set firewall name to-public rule 1 action accept
set firewall name to-public rule 1 state established enable set firewall name to-public rule 1 state related enable set firewall name to-public rule 10 action accept
set firewall name to-public rule 10 destination port 80,443 set firewall name to-public rule 10 protocol tcp
set firewall name to-public rule 20 action accept
set firewall name to-public rule 20 destination address 8.8.8.8
30 0
set firewall name to-public rule 20 destination port 53 set firewall name to-public rule 20 protocol udp
commit
Tiếp theo chúng ta tạo rule cho zone private. Trong ví dụ này chỉ cho phép lắng nghe kết nối.
Thực hành 24. Tạo rule cho zone private
set firewall name to-private description "Allow established to Private zone" set firewall name to-private rule 1 action accept
set firewall name to-private rule 1 state established enable set firewall name to-private rule 1 state related enable commit
Tiếp theo bạn cần tạo rule cho phép vùng public truy cập đến vùng server. Ví dụ ở đây chúng ta cho phép traffic TCP port 80,443 đi vào server zone.
Thực hành 25. Tạo rule cho phép đi vào server zone
set firewall name public-to-server description "Public to Server Zone" set firewall name public-to-server rule 10 action accept
set firewall name public-to-server rule 10 destination port 80,443 set firewall name public-to-server rule 10 protocol tcp
set firewall name public-to-server rule 10 destination address 192.168.204.1 commit
Một ý tưởng tốt khi giới hạn kết nối của client vào server, để phòng bị tấn công DOS hoặc brute force.
Thực hành 26. Rule giới hạn kết nối
set firewall name public-to-server rule 5 action drop set firewall name public-to-server rule 5 protocol tcp
set firewall name public-to-server rule 5 destination port 80,443 set firewall name public-to-server rule 5 recent count 20
set firewall name public-to-server rule 5 recent time 5 commit
Rule cuối cùng, bạn cần cho phép client từ vùng private có thể truy cập vào vùng server. Cụ thể port 80, 443 TCP phải được allow, đồng thời port 22 sử dụng cho giao thức SSH cũng nên allow để tiện quản lý.
Thực hành 27. Rule cho phép vùng private vào vùng server
set firewall name private-to-server description "Private to Server” set firewall name private-to-server rule 1 action accept
set firewall name private-to-server rule 1 state established enable set firewall name private-to-server rule 1 state related enable set firewall name private-to-server rule 10 action accept
set firewall name private-to-server rule 10 destination port 80,443 set firewall name private-to-server rule 10 protocol tcp
set firewall name private-to-server rule 20 action accept set firewall name private-to-server rule 20 destination port 22 set firewall name private-to-server rule 20 protocol tcp
set firewall name private-to-server rule 20 destination address 192.168.204.1 set firewall name private-to-server rule 20 source address 192.168.244.100 commit
Bước cuối cùng trong cấu hình firewall là bạn phải áp dụng những rule đã cấu hình ở trên vào cho zone nào. Cấu trúc lệnh cuối cùng trả lời câu hỏi: Áp dụng rule nào nào, vào zone nào, đối với traffice di chuyển từ đâu. Ví dụ, bạn phải áp dụng rule private-to-server vào zone là serverfarm đối với traffic từ zone private.
set zone-policy zone serverfarm from private firewall name private-to-server set zone-policy zone serverfarm from public firewall name public-to-server set zone-policy zone private from public firewall name to-private
set zone-policy zone private from serverfarm firewall name to-private set zone-policy zone public from private firewall name-to-public set zone-policy zone public from serverfarm firewall name to-public commit
Kiểm tra lại các cấu hình trên bằng hai lệnh show firewall
show zone-policy
32 2
5.2.5 Cấu hình IPS
Hệ thống Vyatta chạy Snort để phát hiện xâm nhập. Điều này tạo thêm một lợi thế đáng kể cho lọc gói tin của tưởng lửa. Tưởng lửa lọc gói tin sẽ ngăn chặn tất cả các gói tin bất hợp pháp đã định trước, ví dụ chặn gói tin TCP port 21 đi vào mail server.
Tuy nhiên, firewall lọc gói tin cũng không tốt cho lắm, với các gói tin có ý đồ xấu. Packet filtering firewall không có tác dụng khi gói tin có chứa mã đọc hại. Một cải tiến đáng kể cho những bộ lọc gói tin là phòng chống xâm nhập, có nghĩa là sẽ chạy một công cụ phù hợp để phân tích nội dung gói tin. Từ đó có thể cấu hình drop, alert, pass, hoặc âm thầm bỏ qua, trên bất kỳ gói tin phù hợp với một quy tắc của Snort. Vyatta làm cho cấu hình IPS rất dễ dàng hơn.
Kể từ khi tích hợp IPS là Snort, điều đó thì cần thiết để cấu một hành động cho tường lửa dựa trên các gói tin phù hợp với ưu tiên Snort. Cũng giống như các module khác trong Vyatta, IPS đơn giản là kích hoạt và cấu hình. Điều đầu tiên phải làm là thiết lập các hành động cho mỗi một mức độ ưu tiên thông qua ba cấp độ khác nhau.
Thực hành 28. Cấu hình mức ưu tiên cho IPS
set content-inspection ips actions priority-1 drop set content-inspection ips actions priority-2 alert set content-inspection ips actions priority-3 alert set content-inspection ips actions other pass
Tiếp theo bạn sẽ cấu hình update rule tự động, việc cập nhật này có thể thực hiện tự động từ trang web snort.com khi bạn đăng ký sử dụng dịch vụ và được cung cấp “oink code”.
Thực hành 29. Cập nhật rule trực tuyến từ snort.org
set content-inspection ips auto-update oink-code <your oink code>
Ghi chú: để lấy oink Code bạn vào trang web www.snort.org, đăng ký tài khoản, đăng nhập. Sau đó vào phần Account, tab Subscriptions and Oinkcodes, lúc này sẽ lấy được Oink Code, hoàn toàn miễn phí.
Tiếp theo, traffic được xử lý bởi các IPS đã định nghĩa. Điều đó có thể chỉ áp dụng các bộ lọc nội dung cho rule của tường lửa tùy chỉnh hoặc chỉ đơn giản là xử lý tất cả lưu lượng truy cập thông qua các IPS:
Thực hành 30. Cấu hình xử lý của IPS
set content-inspection traffic-filter preset all
Một thời gian khi sử dụng Snort engine cho hệ thống IPS, bạn cần phải restart lại dịch vụ khi nó tiến hành download rule thành công. Snort tự động restart, và mất khoản 5 đến 10 giây cho việc này, trong thời gian này các gói tin sẽ không được xử lý.
show ips log
5.2.6 Cấu hình Web Filter
Hệ thống Vyatta có thể được cấu hình để quản lý hoạt động của người dùng nội bộ, hoạt động như một proxy web server. Các bộ lọc web có thể làm giảm nguy cơ tiếp xúc với các mối đe dọa từ web, chặn nội dung không mong muốn, tăng năng suất và giảm việc sử dụng băng thông. Các mối đe dọa bị chặn bởi bộ lọc URL bằng cách dựa vào danh sách đen của cộng đồng được cập nhật liên tục.
Việc ngăn chặn có thể dựa trên URL, từ khóa có trong URL, loại website hoặc định dạng đa phương tiện. Điều này có thể khắc phục được nhược điểm của lọc theo IP khi mà web đó thay đổi ip liên tục hoặc có nhiều ip. Các rule có thể được áp dụng cho một người dùng cá nhân hoặc một nhóm người, dựa trên ip hoặc subnet.
Sau đây là cấu hình lọc web đối với hai danh mục web “spyware” và “filehosting”. Rule được áp dụng cho toàn bộ user trong mạng private, ngoại trừ admin có địa chỉ ip tĩnh cụ thể.
Thực hành 31. Cấu hình webproxy
set service webproxy listen address 192.168.80.254
set service webproxy url-filtering squidguard source-group SecAdmin address 192.168.80.42
set service webproxy url-filtering squidguard source-group Users address 192.168.80.0/24
set service webproxy url-filtering squidguard rule 10 source group SecAdmin set service webproxy url-filtering squidguard rule 20 source group Users set service webproxy url-filtering squidguard rule 20 block-category spyware set service webproxy url-filtering squidguard rule 20 block-category filehosting
commit
Ngoài việc lọc theo danh mục, bạn có thể lọc theo url chỉ định hoặc từ khóa có trong url đó. Ví dụ sau đây chặn không cho user truy cập facebook.com và những website có từ khóa “sex” trong url.
Thực hành 32. Lọc url chỉ định và từ khóa
set service webproxy url-filtering squidguard rule 20 local-block-url facebook.com
set service webproxy url-filtering squidguard rule 20 local-block-keyword “sex” Khi user truy cập bị cấm trên các trang web chỉ định, bạn có chuyển tiếp user đến một trang web khác.
34 4
Thực hành 33. Chuyển tiếp user
set service webproxy url-filtering squidguard rule 20 redirect‐ url “http://www.google.com”
Để kiểm tra lại cấu hình đã thực hiện bạn dùng lệnh show show service webproxy