Skip to content

Commit 6718f21

Browse files
committed
Make ipv6 work to the outside
1 parent d7403b0 commit 6718f21

File tree

7 files changed

+63
-8
lines changed

7 files changed

+63
-8
lines changed

Makefile

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ external_network:
9797
--driver=bridge \
9898
--gateway=203.0.113.1 \
9999
--subnet=203.0.113.0/24 \
100+
--ipv6 \
101+
--gateway=2001:db8:1::1 \
102+
--subnet=2001:db8:1::/64 \
100103
--opt "com.docker.network.driver.mtu=9000" \
101104
--opt "com.docker.network.bridge.name=mini_lab_ext" \
102105
--opt "com.docker.network.bridge.enable_ip_masquerade=true" && \
@@ -134,11 +137,11 @@ _public_ips: env
134137

135138
.PHONY: machine
136139
machine: _privatenet _public_ips
137-
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine create --description test --name test --hostname test --project 00000000-0000-0000-0000-000000000001 --partition mini-lab --image $(MACHINE_OS) --size v1-small-x86 --userdata "@/tmp/ignition.json" --ips 203.0.113.130 --networks internet-mini-lab,$(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
140+
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl machine create --description test --name test --hostname test --project 00000000-0000-0000-0000-000000000001 --partition mini-lab --image $(MACHINE_OS) --size v1-small-x86 --userdata "@/tmp/ignition.json" --networks $(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
138141

139142
.PHONY: firewall
140143
firewall: _privatenet _public_ips
141-
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl firewall create --description fw --name fw --hostname fw --project 00000000-0000-0000-0000-000000000001 --partition mini-lab --image firewall-ubuntu-3.0 --size v1-small-x86 --userdata "@/tmp/ignition.json" --ips 203.0.113.129 --firewall-rules-file=/tmp/rules.yaml --networks internet-mini-lab,$(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
144+
docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl firewall create --description fw --name fw --hostname fw --project 00000000-0000-0000-0000-000000000001 --partition mini-lab --image firewall-ubuntu-3.0 --size v1-small-x86 --userdata "@/tmp/ignition.json" --firewall-rules-file=/tmp/rules.yaml --networks internet-mini-lab,$(shell docker compose run $(DOCKER_COMPOSE_TTY_ARG) metalctl network list --name user-private-network -o template --template '{{ .id }}')
142145

143146
# IPv6
144147
.PHONY: _privatenet6
@@ -273,6 +276,47 @@ connect-to-www:
273276
fi; \
274277
done
275278

279+
.PHONY: connect-to-www-ipv6
280+
connect-to-www-ipv6:
281+
@echo "Attempting to connect to container www..."
282+
@for i in $$(seq 1 $(MAX_RETRIES)); do \
283+
if $(MAKE) ssh-machine COMMAND="sudo curl --connect-timeout 1 --fail --silent http://[2001:db8:1::3]" > /dev/null 2>&1; then \
284+
echo "Connected successfully"; \
285+
exit 0; \
286+
else \
287+
echo "Connection failed"; \
288+
if [ $$i -lt $(MAX_RETRIES) ]; then \
289+
echo "Retrying in 2 seconds..."; \
290+
sleep 2; \
291+
else \
292+
echo "Max retries reached"; \
293+
exit 1; \
294+
fi; \
295+
fi; \
296+
done
297+
298+
FWIP := $(shell metalctl network ip list --name fw --network $(shell metalctl network list --name user-private-network -o template --template '{{ .id }}') -o template --template "{{ .ipaddress }}" --addressfamily IPv6 )
299+
300+
.PHONY: connect-to-node-exporter-on-firewall
301+
connect-to-node-exporter-on-firewall:
302+
@echo "Attempting to connect to node exporter on the firewall"
303+
echo "Firewall IP: $(FWIP)"
304+
@for i in $$(seq 1 $(MAX_RETRIES)); do \
305+
if $(MAKE) ssh-machine COMMAND="sudo curl --connect-timeout 1 --fail --silent http://[$(FWIP)]:9100/metrics" > /dev/null 2>&1; then \
306+
echo "Connected successfully"; \
307+
exit 0; \
308+
else \
309+
echo "Connection failed"; \
310+
if [ $$i -lt $(MAX_RETRIES) ]; then \
311+
echo "Retrying in 2 seconds..."; \
312+
sleep 2; \
313+
else \
314+
echo "Max retries reached"; \
315+
exit 1; \
316+
fi; \
317+
fi; \
318+
done
319+
276320
## DEV TARGETS ##
277321

278322
.PHONY: dev-env

files/inet/frr.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ipv6 forwarding
66
vrf vrfInternet
77
vni 104009
88
ip route 0.0.0.0/0 203.0.113.1
9-
ipv6 route ::/0 2001:db8:1::42
9+
ipv6 route ::/0 2001:db8:1::1
1010
exit-vrf
1111
!
1212
interface eth1
@@ -19,6 +19,7 @@ interface eth2
1919
!
2020
interface ext
2121
ip address 203.0.113.2/24
22+
ipv6 address 2001:db8:1::2/64
2223
!
2324
interface lo
2425
ip address 10.0.0.21/32

files/inet/network.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ bridge vlan del vid 1 untagged pvid dev vniInternet
2626
bridge vlan add vid 1000 dev vniInternet
2727
bridge vlan add vid 1000 untagged pvid dev vniInternet
2828
ip link set up dev vniInternet
29-
30-
# Does not have a ipv6 address on eth0 on startup, fix this
31-
ip ad add 2001:db8:1::42/64 dev eth0

files/rules.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ egress:
66
protocol: TCP
77
to:
88
- 0.0.0.0/0
9+
- comment: allow outgoing http
10+
ports:
11+
- 80
12+
protocol: TCP
13+
to:
14+
- ::/0
915
- comment: allow outgoing https
1016
ports:
1117
- 443

inventories/group_vars/control-plane/metal.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ metal_api_images:
1818
name: Firewall 3 Ubuntu
1919
description: Firewall 3 Ubuntu Latest Release
2020
# url: https://images.metal-stack.io/metal-os/{{ metal_api_latest_os_image_release_name }}/firewall/3.0-ubuntu/img.tar.lz4
21-
url: https://images.metal-stack.io/metal-os/pull_requests/247-ipv6-support/firewall/3.0-ubuntu/img.tar.lz4
21+
url: https://images.metal-stack.io/metal-os/pull_requests/252-allow-ipv6-firewall-rules/firewall/3.0-ubuntu/img.tar.lz4
22+
# url: https://images.metal-stack.io/metal-os/stable/firewall/3.0-ubuntu/img.tar.lz4
2223
features:
2324
- firewall
2425
- id: ubuntu-24.04
@@ -82,7 +83,7 @@ metal_api_networks:
8283
vrf: 104009
8384
prefixes:
8485
- 203.0.113.128/25
85-
- 2001:db8:3::/48
86+
- 2001:db8:1:1::/80
8687
labels:
8788
network.metal-stack.io/default: ""
8889
network.metal-stack.io/default-external: ""

mini-lab.sonic.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ topology:
4848
exec:
4949
- ip addr add 203.0.113.3/24 dev ext
5050
- ip route add 203.0.113.128/25 via 203.0.113.2 dev ext
51+
- ip -6 addr add 2001:db8:1::3/64 dev ext
52+
- ip -6 route add 2001:db8:2::/64 via 2001:db8:1::2 dev ext
53+
- ip -6 route add 2001:db8:1:1::/64 via 2001:db8:1::2 dev ext
5154
links:
5255
- endpoints: ["inet:ext", "mini_lab_ext:inet"]
5356
mtu: 9000

test/integration.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ echo "$phoned/$minPhoned machines have phoned home"
4545
echo "Test connectivity to outside"
4646
make connect-to-www
4747

48+
echo "Test connectivity to outside ipv6"
49+
make connect-to-www-ipv6
50+
4851
echo "Test connectivity from outside"
4952
ssh -o StrictHostKeyChecking=no -o "PubkeyAcceptedKeyTypes +ssh-rsa" -i files/ssh/id_rsa [email protected] -C exit
5053

0 commit comments

Comments
 (0)