iT邦幫忙

2025 iThome 鐵人賽

DAY 13
0
Cloud Native

我在 CKS 考完只拿 47% 後痛定思痛決定好好準備內容系列 第 13

[Day13] 3-3. Minimize external access to the network

  • 分享至 

  • xImage
  •  

今天主要是討論到對於 OS 而言我們可以如何限制外部的訪問,除了前面提到的密碼以及 sudoer 以外,
在網路層面也可以做限制

Limit Node access

  1. 限制可以訪問的來源
    (1) 可以透過 VPN 限制公網連線
    (2) 透過限制特定 IP

iptable

最常用的是透過 linux 中的 iptable 對 user 進行限制

# 查看所有規則
iptables -L

# 查看規則並顯示行號
iptables -L --line-numbers

# 查看 NAT 表
iptables -t nat -L

# 查看詳細資訊
iptables -L -v -n

# 情境:只允許特定 Pod CIDR 存取
iptables -A INPUT -s 10.244.0.0/16 -j ACCEPT
iptables -A INPUT -j DROP

# 情境:限制對外連線
iptables -A OUTPUT -d 169.254.169.254 -j DROP  # 阻擋 metadata service

[軟體]UFW - Uncomplicated Firewall

UFW (Uncomplicated Firewall) 實際上是 iptables 的前端工具,底層還是使用 iptables,不同的點是提供更簡化的語法。

  • 安裝
apt-get update
apt-get install ufw
systemctl start ufw
  • 常用指令
ufw status
ufw default allow outgoing
ufw default deny incoming
ufw allow from 1.2.3.4 to any port 22 proto tcp
ufw allow from 1.2.3.4 to any port 80 proto tcp
ufw enable

ufw deny 8080
ufw deny 5

參考資料
https://linux.vbird.org/linux_server/centos6/0250simple_firewall.php


上一篇
[Day12] 3-2. Using least-privilege identity and access management
下一篇
[Day14] 3-4. Appropriately use kernel hardening tools such as AppArmor, seccomp
系列文
我在 CKS 考完只拿 47% 後痛定思痛決定好好準備內容17
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言