Thứ Tư, 10 tháng 9, 2025

Bài 3: Network & Security trong Linux

1. Vì sao DevOps cần nắm Network & Security?

  • DevOps phải hiểu cơ bản về mạng TCP/IP, DNS, HTTP/HTTPS để cấu hình server, load balancer, API gateway.

  • DevOps cũng phải quản lý firewall, SSH, chứng chỉ SSL/TLS để đảm bảo an toàn khi deploy hệ thống.


2. Kiểm tra thông tin mạng

Xem địa chỉ IP

ip addr show

👉 Kết quả mẫu:

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 inet 192.168.1.20/24 brd 192.168.1.255 scope global ens33

📌 inet 192.168.1.20/24 → IP của server.


Ping kiểm tra kết nối

ping -c 4 google.com

👉 Kết quả mẫu:

64 bytes from hkg07s63-in-f14.1e100.net (142.250.199.78): icmp_seq=1 ttl=118 time=25.3 ms

Kiểm tra port đang mở

ss -tulnp | head -5

👉 Kết quả mẫu:

Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=895,fd=3)) tcp LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1234,fd=6))

📌 Port 22 (SSH) và 80 (HTTP) đang mở.


3. Firewall cơ bản

Ubuntu/Debian (dùng UFW)

# Mở port 22 (SSH) sudo ufw allow 22/tcp # Mở port 80 (HTTP) sudo ufw allow 80/tcp # Kiểm tra sudo ufw status

👉 Kết quả:

22/tcp ALLOW Anywhere 80/tcp ALLOW Anywhere

RHEL/CentOS/Fedora/Oracle Linux (dùng firewalld)

# Mở port 22 (SSH) sudo firewall-cmd --permanent --add-port=22/tcp # Mở port 80 (HTTP) sudo firewall-cmd --permanent --add-port=80/tcp # Reload sudo firewall-cmd --reload # Kiểm tra sudo firewall-cmd --list-all

👉 Kết quả:

ports: 22/tcp 80/tcp

4. Quản lý SSH (Secure Shell)

Kết nối SSH từ client

ssh devops@192.168.1.20

👉 Kết quả mẫu:

devops@192.168.1.20's password: Welcome to Ubuntu 22.04 LTS

Cấu hình SSH bằng Key (an toàn hơn password)

ssh-keygen -t rsa -b 4096 ssh-copy-id devops@192.168.1.20

👉 Giờ có thể SSH mà không cần gõ mật khẩu.


5. HTTP/HTTPS và SSL/TLS

Cài đặt Nginx

# Ubuntu/Debian sudo apt install -y nginx # RHEL/CentOS/Fedora/Oracle Linux sudo dnf install -y nginx

Truy cập HTTP

curl -I http://localhost

👉 Kết quả mẫu:

HTTP/1.1 200 OK Server: nginx/1.18.0

Cài chứng chỉ SSL miễn phí với Let’s Encrypt (Certbot)

sudo apt install -y certbot python3-certbot-nginx # Ubuntu/Debian sudo dnf install -y certbot python3-certbot-nginx # RHEL/CentOS/Fedora/Oracle Linux sudo certbot --nginx -d example.com -d www.example.com

👉 Kết quả:

Successfully received certificate. Your certificate and chain have been saved at: /etc/letsencrypt/live/example.com/fullchain.pem

6. Bài tập thực hành + Lời giải


🔹 Bài tập 1: Kiểm tra IP và ping

Yêu cầu: Hiển thị IP server, sau đó ping Google.

Lời giải:

ip addr show | grep inet ping -c 2 google.com

👉 Kết quả:

inet 192.168.1.20/24 ... 64 bytes from 142.250.199.78: icmp_seq=1 ttl=118 time=25.3 ms

🔹 Bài tập 2: Mở port 8080

Yêu cầu: Mở port 8080 trên Ubuntu hoặc CentOS.

Lời giải (Ubuntu/Debian):

sudo ufw allow 8080/tcp sudo ufw status

Lời giải (CentOS/RHEL/Fedora/Oracle Linux):

sudo firewall-cmd --permanent --add-port=8080/tcp sudo firewall-cmd --reload sudo firewall-cmd --list-ports

👉 Kết quả:

8080/tcp

🔹 Bài tập 3: SSH không mật khẩu

Yêu cầu: Tạo key SSH và cấu hình để login không cần password.

Lời giải:

ssh-keygen -t rsa -b 4096 ssh-copy-id devops@192.168.1.20 ssh devops@192.168.1.20

👉 Kết quả:

Welcome to Ubuntu 22.04 LTS

(không yêu cầu nhập password)


✅ Sau Bài 3, bạn đã biết:

  • Kiểm tra IP, port, ping.

  • Quản lý firewall (UFW, firewalld).

  • SSH với password và SSH key.

  • Cấu hình HTTPS với Let’s Encrypt.

=============================
Website không chứa bất kỳ quảng cáo nào, mọi đóng góp để duy trì phát triển cho website (donation) xin vui lòng gửi về STK 90.2142.8888 - Ngân hàng Vietcombank Thăng Long - TRAN VAN BINH
=============================
Nếu bạn không muốn bị AI thay thế và tiết kiệm 3-5 NĂM trên con đường trở thành DBA chuyên nghiệp hay làm chủ Database thì hãy đăng ký ngay KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE, được Coaching trực tiếp từ tôi với toàn bộ bí kíp thực chiến, thủ tục, quy trình của gần 20 năm kinh nghiệm (mà bạn sẽ KHÔNG THỂ tìm kiếm trên Internet/Google) từ đó giúp bạn dễ dàng quản trị mọi hệ thống Core tại Việt Nam và trên thế giới, đỗ OCP.
- CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
- Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
2 khóa học online qua video giúp bạn nhanh chóng có những kiến thức nền tảng về Linux, Oracle, học mọi nơi, chỉ cần có Internet/4G:
- Oracle cơ bản: https://bit.ly/admin_1200
- Linux: https://bit.ly/linux_1200
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: https://www.youtube.com/@binhguru
👨 Tiktok: https://www.tiktok.com/@binhguru
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhguru
👨 Podcast: https://www.podbean.com/pu/pbblog-eskre-5f82d6
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
cơ sở dữ liệu, cơ sở dữ liệu quốc gia, database, AI, trí tuệ nhân tạo, artificial intelligence, machine learning, deep learning, LLM, ChatGPT, DeepSeek, Grok, oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c/21c/23c/23ai, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, ms sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, docker, k8s, micro service, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master