Skip to content

feat: support Lima VMs iptables rules #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.17 as build

WORKDIR /build

COPY go.* .
COPY go.* ./

RUN go mod download

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

FROM debian:11-slim

RUN apt-get update && apt-get install -y \
iptables
RUN apt-get update && \
apt-get install -y iptables && \
update-alternatives --set iptables /usr/sbin/iptables-legacy

COPY --from=build /build/app .

Expand Down
14 changes: 14 additions & 0 deletions client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,18 @@ func main() {
fmt.Printf("Failed to add iptables nat rule: %v\n", err)
os.Exit(ExitSetupFailed)
}

fmt.Println("Adding iptables FORWARD rule for host WireGuard IP")

// Add iptables rule to allow incoming traffic from hostPeerIp
// This is needed by LIMA-based Docker VM hosts
err = ipt.AppendUnique(
"filter", "FORWARD",
"-s", hostPeerIp,
"-p", "tcp", "-j", "ACCEPT",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be any reason to restrict forwarding for just TCP right?

)
if err != nil {
fmt.Printf("Failed to add iptables forward rule: %v\n", err)
os.Exit(ExitSetupFailed)
}
}