Skip to content

Commit 56097b3

Browse files
committed
feat: support Lima VMs iptables rules
1 parent 0374c3d commit 56097b3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

client/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM golang:1.17 as build
22

33
WORKDIR /build
44

5-
COPY go.* .
5+
COPY go.* ./
66

77
RUN go mod download
88

@@ -12,8 +12,9 @@ RUN go build -o app main.go
1212

1313
FROM debian:11-slim
1414

15-
RUN apt-get update && apt-get install -y \
16-
iptables
15+
RUN apt-get update && \
16+
apt-get install -y iptables && \
17+
update-alternatives --set iptables /usr/sbin/iptables-legacy
1718

1819
COPY --from=build /build/app .
1920

client/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,18 @@ func main() {
186186
fmt.Printf("Failed to add iptables nat rule: %v\n", err)
187187
os.Exit(ExitSetupFailed)
188188
}
189+
190+
fmt.Println("Adding iptables FORWARD rule for host WireGuard IP")
191+
192+
// Add iptables rule to allow incoming traffic from hostPeerIp
193+
// This is needed by LIMA-based Docker VM hosts
194+
err = ipt.AppendUnique(
195+
"filter", "FORWARD",
196+
"-s", hostPeerIp,
197+
"-p", "tcp", "-j", "ACCEPT",
198+
)
199+
if err != nil {
200+
fmt.Printf("Failed to add iptables forward rule: %v\n", err)
201+
os.Exit(ExitSetupFailed)
202+
}
189203
}

0 commit comments

Comments
 (0)