|
8 | 8 | set -o pipefail
|
9 | 9 | set -o errexit
|
10 | 10 |
|
11 |
| - # Install ca-certificates packages for Azure Linux |
12 |
| - tdnf install -y ca-certificates ca-certificates-legacy |
13 |
| - update-ca-trust |
14 |
| -
|
15 | 11 | # Allow Azure service IP addresses (required for Azure resources)
|
16 | 12 | iptables -A INPUT -s 168.63.129.16 -j ACCEPT
|
17 | 13 | iptables -A OUTPUT -d 168.63.129.16 -j ACCEPT
|
18 | 14 |
|
19 |
| - # Kubernetes API Server (port 6443) - bound to all IPv6 interfaces, needs external access |
20 |
| - iptables -A INPUT -p tcp --dport 6443 -j ACCEPT |
| 15 | + # Allow localhost traffic (required for many localhost-bound services) |
| 16 | + iptables -A INPUT -i lo -j ACCEPT |
| 17 | + iptables -A OUTPUT -o lo -j ACCEPT |
| 18 | +
|
| 19 | + # Allow established and related connections |
| 20 | + iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
| 21 | + iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
| 22 | +
|
| 23 | + # SSH (port 22) - bound to all interfaces, needs external access |
| 24 | + # iptables -A INPUT -p tcp --dport 22 -j ACCEPT |
| 25 | +
|
| 26 | + # Kubelet API (port 10250) - bound to all IPv6 interfaces, needs cluster access |
| 27 | + iptables -A INPUT -p tcp --dport 10250 -j ACCEPT |
| 28 | +
|
| 29 | + # kube-proxy (port 10256) - bound to all IPv6 interfaces, needs cluster access |
| 30 | + # iptables -A INPUT -p tcp --dport 10256 -j ACCEPT |
| 31 | +
|
| 32 | + # Calico networking requirements |
| 33 | + # Calico Typha (port 5473) - bound to all IPv6 interfaces, needs cluster access |
| 34 | + iptables -A INPUT -p tcp --dport 5473 -j ACCEPT |
| 35 | + |
| 36 | + # VXLAN for overlay networking (port 4789 UDP) - bound to all interfaces |
| 37 | + iptables -A INPUT -p udp --dport 4789 -j ACCEPT |
21 | 38 |
|
22 |
| - # etcd server communication - external access needed for cluster communication |
23 |
| - # Port 2379 is bound to node IP (10.0.0.5), needs cluster access |
24 |
| - iptables -A INPUT -p tcp --dport 2379 -j ACCEPT |
25 |
| - # Port 2380 is bound to node IP (10.0.0.5), needs cluster access |
26 |
| - iptables -A INPUT -p tcp --dport 2380 -j ACCEPT |
27 |
| - # Port 2381 is localhost only, no external rule needed |
| 39 | + # Calico metrics ports (29603, 29605) - bound to all IPv6 interfaces |
| 40 | + # iptables -A INPUT -p tcp --dport 29603 -j ACCEPT |
| 41 | + # iptables -A INPUT -p tcp --dport 29605 -j ACCEPT |
| 42 | + |
| 43 | + # BGP for node-to-node communication (port 179) - not in netstat but needed for Calico |
| 44 | + iptables -A INPUT -p tcp --dport 179 -j ACCEPT |
| 45 | + |
| 46 | + # IP-in-IP protocol for Calico |
| 47 | + # iptables -A INPUT -p 4 -j ACCEPT |
28 | 48 |
|
29 |
| - # Allow traffic to Kubernetes service network (10.96.0.0/12) - CRITICAL: required for pod-to-service communication |
| 49 | + # DHCP client (port 68 UDP) - for IP assignment |
| 50 | + # iptables -A INPUT -p udp --dport 68 -j ACCEPT |
| 51 | +
|
| 52 | + # NTP (port 323 UDP) - for time synchronization |
| 53 | + # iptables -A INPUT -p udp --dport 323 -j ACCEPT |
| 54 | +
|
| 55 | + # Allow ICMP for connectivity checks |
| 56 | + # iptables -A INPUT -p icmp -j ACCEPT |
| 57 | +
|
| 58 | + # Allow traffic to Kubernetes service network (10.96.0.0/12) - required for pod-to-service communication |
30 | 59 | iptables -A OUTPUT -d 10.96.0.0/12 -j ACCEPT
|
31 | 60 | iptables -A INPUT -s 10.96.0.0/12 -j ACCEPT
|
32 | 61 |
|
| 62 | + # Allow traffic to/from Calico pod network (192.168.0.0/16) - required for pod-to-pod communication |
| 63 | + iptables -A OUTPUT -d 192.168.0.0/16 -j ACCEPT |
| 64 | + iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT |
| 65 | +
|
33 | 66 | # Allow traffic to/from node network (10.1.0.0/24) - required for node-to-node communication
|
34 | 67 | iptables -A OUTPUT -d 10.1.0.0/24 -j ACCEPT
|
35 | 68 | iptables -A INPUT -s 10.1.0.0/24 -j ACCEPT
|
36 | 69 |
|
37 |
| - # Allow traffic to/from Calico pod network - more restrictive than full 192.168.0.0/16 |
38 |
| - # Only allow the specific pod CIDR ranges that Calico actually uses |
39 |
| - iptables -A OUTPUT -d 192.168.0.0/24 -j ACCEPT |
40 |
| - iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT |
41 |
| -
|
42 | 70 | # Save the rules following Azure Linux 3 approach
|
43 | 71 | iptables-save > /etc/systemd/scripts/ip4save
|
44 | 72 | path: /tmp/azl3-setup.sh
|
|
0 commit comments