|
12 | 12 | tdnf install -y ca-certificates ca-certificates-legacy |
13 | 13 | update-ca-trust |
14 | 14 |
|
15 | | - # Azure Linux 3 firewall configuration for worker nodes |
16 | | - # Keep the default DROP policy for security, only add specific ACCEPT rules |
17 | | -
|
18 | 15 | # Allow Azure service IP addresses (required for Azure resources) |
19 | 16 | iptables -A INPUT -s 168.63.129.16 -j ACCEPT |
20 | 17 | iptables -A OUTPUT -d 168.63.129.16 -j ACCEPT |
21 | | - ip6tables -A INPUT -s fe80::1234:5678:9abc -j ACCEPT |
22 | | - ip6tables -A OUTPUT -d fe80::1234:5678:9abc -j ACCEPT |
23 | | -
|
24 | | - # Allow localhost traffic (required for many localhost-bound services) |
25 | | - iptables -A INPUT -i lo -j ACCEPT |
26 | | - iptables -A OUTPUT -o lo -j ACCEPT |
27 | | - ip6tables -A INPUT -i lo -j ACCEPT |
28 | | - ip6tables -A OUTPUT -o lo -j ACCEPT |
29 | | -
|
30 | | - # Allow established and related connections |
31 | | - iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
32 | | - iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
33 | | - ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
34 | | - ip6tables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT |
35 | | -
|
36 | | - # SSH (port 22) - bound to all interfaces, needs external access |
37 | | - iptables -A INPUT -p tcp --dport 22 -j ACCEPT |
38 | | - ip6tables -A INPUT -p tcp --dport 22 -j ACCEPT |
39 | | -
|
40 | | - # Kubelet API (port 10250) - bound to all IPv6 interfaces, needs cluster access |
41 | | - iptables -A INPUT -p tcp --dport 10250 -j ACCEPT |
42 | | - ip6tables -A INPUT -p tcp --dport 10250 -j ACCEPT |
43 | | -
|
44 | | - # kube-proxy (port 10256) - bound to all IPv6 interfaces, needs cluster access |
45 | | - iptables -A INPUT -p tcp --dport 10256 -j ACCEPT |
46 | | - ip6tables -A INPUT -p tcp --dport 10256 -j ACCEPT |
47 | 18 |
|
48 | | - # Calico networking requirements |
49 | | - # Calico Typha (port 5473) - bound to all IPv6 interfaces, needs cluster access |
50 | | - iptables -A INPUT -p tcp --dport 5473 -j ACCEPT |
51 | | - ip6tables -A INPUT -p tcp --dport 5473 -j ACCEPT |
52 | | - |
53 | | - # VXLAN for overlay networking (port 4789 UDP) - bound to all interfaces |
54 | | - iptables -A INPUT -p udp --dport 4789 -j ACCEPT |
55 | | - ip6tables -A INPUT -p udp --dport 4789 -j ACCEPT |
| 19 | + # Kubernetes API Server (port 6443) - bound to all IPv6 interfaces, needs external access |
| 20 | + iptables -A INPUT -p tcp --dport 6443 -j ACCEPT |
56 | 21 |
|
57 | | - # Calico metrics ports (29603, 29605) - bound to all IPv6 interfaces |
58 | | - iptables -A INPUT -p tcp --dport 29603 -j ACCEPT |
59 | | - iptables -A INPUT -p tcp --dport 29605 -j ACCEPT |
60 | | - ip6tables -A INPUT -p tcp --dport 29603 -j ACCEPT |
61 | | - ip6tables -A INPUT -p tcp --dport 29605 -j ACCEPT |
62 | | - |
63 | | - # BGP for node-to-node communication (port 179) - not in netstat but needed for Calico |
64 | | - iptables -A INPUT -p tcp --dport 179 -j ACCEPT |
65 | | - ip6tables -A INPUT -p tcp --dport 179 -j ACCEPT |
66 | | - |
67 | | - # IP-in-IP protocol for Calico |
68 | | - iptables -A INPUT -p 4 -j ACCEPT |
69 | | - ip6tables -A INPUT -p 41 -j ACCEPT |
| 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 |
70 | 28 |
|
71 | | - # DHCP client (port 68 UDP) - for IP assignment |
72 | | - iptables -A INPUT -p udp --dport 68 -j ACCEPT |
73 | | - ip6tables -A INPUT -p udp --dport 68 -j ACCEPT |
74 | | -
|
75 | | - # NTP (port 323 UDP) - for time synchronization |
76 | | - iptables -A INPUT -p udp --dport 323 -j ACCEPT |
77 | | - ip6tables -A INPUT -p udp --dport 323 -j ACCEPT |
78 | | -
|
79 | | - # Allow ICMP for connectivity checks |
80 | | - iptables -A INPUT -p icmp -j ACCEPT |
81 | | - ip6tables -A INPUT -p ipv6-icmp -j ACCEPT |
82 | | -
|
83 | | - # Allow traffic to Kubernetes service network (10.96.0.0/12) - required for pod-to-service communication |
| 29 | + # Allow traffic to Kubernetes service network (10.96.0.0/12) - CRITICAL: required for pod-to-service communication |
84 | 30 | iptables -A OUTPUT -d 10.96.0.0/12 -j ACCEPT |
85 | 31 | iptables -A INPUT -s 10.96.0.0/12 -j ACCEPT |
86 | 32 |
|
87 | | - # Allow traffic to/from Calico pod network (192.168.0.0/16) - required for pod-to-pod communication |
88 | | - iptables -A OUTPUT -d 192.168.0.0/16 -j ACCEPT |
89 | | - iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT |
90 | | -
|
91 | 33 | # Allow traffic to/from node network (10.1.0.0/24) - required for node-to-node communication |
92 | 34 | iptables -A OUTPUT -d 10.1.0.0/24 -j ACCEPT |
93 | 35 | iptables -A INPUT -s 10.1.0.0/24 -j ACCEPT |
94 | 36 |
|
| 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 | +
|
95 | 42 | # Save the rules following Azure Linux 3 approach |
96 | 43 | iptables-save > /etc/systemd/scripts/ip4save |
97 | | - ip6tables-save > /etc/systemd/scripts/ip6save |
98 | 44 | path: /tmp/azl3-setup.sh |
99 | 45 | owner: "root:root" |
100 | 46 | permissions: "0744" |
|
0 commit comments