Skip to content

vm: support UDP port forwarding #1343

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

Merged
merged 1 commit into from
Jul 17, 2025
Merged

Conversation

stek29
Copy link
Contributor

@stek29 stek29 commented Jul 13, 2025

Should fix #1292 and fix #1300, and maybe others

gRPC port forwarder is considered stable in lima, no need to force older SSH forwarder by default

@abiosoft
Copy link
Owner

Thanks a lot for this :)
Have you tested this and verified the behaviour?

abiosoft
abiosoft previously approved these changes Jul 13, 2025
Copy link
Owner

@abiosoft abiosoft left a comment

Choose a reason for hiding this comment

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

Build failing, it looks like you didn't commit all files.

@abiosoft abiosoft self-requested a review July 13, 2025 15:17
@abiosoft abiosoft dismissed their stale review July 13, 2025 17:18

Build failing.

Should fix abiosoft#1292 and abiosoft#1300, and maybe others

gRPC port forwarder is considered stable in lima, no need to force older SSH forwarder by default
@stek29 stek29 force-pushed the udp-port-forward branch from bd1c5e3 to 2937825 Compare July 13, 2025 21:36
@stek29
Copy link
Contributor Author

stek29 commented Jul 13, 2025

@abiosoft I have indeed forgotten to push the latest commit, sorry for that

@stek29
Copy link
Contributor Author

stek29 commented Jul 13, 2025

Here's how I've tested it originally:

docker run --rm --name socat9k \
  --entrypoint sh \
  -p 9999:9999/tcp \
  -p 9999:9999/udp \
  alpine/socat \
  -c 'socat -u -v TCP-LISTEN:9999,fork STDOUT & socat -u -v UDP-RECV:9999 STDOUT & wait'

and in another terminal tab:

$ echo hi | nc -u localhost 9999
^C
$ echo hi | nc localhost 9999

@stek29
Copy link
Contributor Author

stek29 commented Jul 13, 2025

I've also tested it with an actual UDP server, and looks like there are issues with udp forwarding, unfortunately.

docker run --rm \
  -p 5053:53/udp -p 5053:53/tcp \
  coredns/coredns:latest

and then:

dig @127.0.0.1 -p 5053 example.com
dig +tcp @127.0.0.1 -p 5053 example.com

udp only works exactly once, after that responses aren't delivered correctly.

I can still see the requests:

[INFO] 172.17.0.1:49232 - 33323 "A IN example.com. udp 40 false 4096" NOERROR qr,aa,rd 91 0.000146837s

but the responses never arrive (I can see the response packets on colima vm with tcpdump though, up to response from docker-proxy to the lima guestagent)

I guess lima udp forwarding isn't really working yet, I'll look further into this and report to lima upstream.

@stek29
Copy link
Contributor Author

stek29 commented Jul 14, 2025

I've submitted a fix to upstream for lima udp forwarding being broken, I guess merging this doesn't make sense before lima issue is fixed: lima-vm/lima#3724

@abiosoft
Copy link
Owner

Thanks for your efforts.
I will wait for the upstream PR to get merged.

@stek29
Copy link
Contributor Author

stek29 commented Jul 17, 2025

@abiosoft upstream PR has been merged, and is selected for cherry-picking into 1.2.1 release of lima

lima-vm/lima#3743

Copy link
Owner

@abiosoft abiosoft left a comment

Choose a reason for hiding this comment

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

Thanks :)

@abiosoft abiosoft changed the title Basic support for UDP port forwarding vm: support UDP port forwarding Jul 17, 2025
@abiosoft abiosoft merged commit fdc7f18 into abiosoft:main Jul 17, 2025
11 checks passed
@stek29 stek29 deleted the udp-port-forward branch July 19, 2025 09:36
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 1, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [abiosoft/colima](https://github.com/abiosoft/colima) | patch | `v0.8.1` -> `v0.8.2` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>abiosoft/colima (abiosoft/colima)</summary>

### [`v0.8.2`](https://github.com/abiosoft/colima/releases/tag/v0.8.2)

[Compare Source](abiosoft/colima@v0.8.1...v0.8.2)

#### Highlights

This is an incremental release with bug fixes.

#### Fixes

- Report errors that occur while reading configuration file. Fixes [#&#8203;1239](abiosoft/colima#1239).
- Use native shasum binary for download assets verification. Fixes [#&#8203;1163](abiosoft/colima#1163).
- Fix download errors when K3s version when empty in config.
- Reset formatting after questions prompts in the terminal. Fixes [#&#8203;1319](abiosoft/colima#1319).

#### Other Updates

- UDP port forwarding is now supported. Resolves [#&#8203;1292](abiosoft/colima#1292), [#&#8203;1300](abiosoft/colima#1300).
- Binfmt emulation is configurable via the `--binfmt` flag and `binfmt` config. Defaults to `true` when Rosetta is disabled.
- Rename `--cpu` flag to `--cpus` for `colima start`, to align with Lima. `--cpu` still works but deprecated.
- Current profile can now be set with `COLIMA_PROFILE` environment variable. Resolves [#&#8203;1308](abiosoft/colima#1308).

##### Runtime version bumps

**NOTE:** container runtime versions can be updated manually by running the `colima update` command.

- Docker version updated to `v28.3.3`
- Nerdctl version updated to `v2.1.3`
- Incus version updated to `v6.14`
- K3s version defaults to `v1.33.3+k3s1 `

#### Commits

- ci: enable gocritic in golangci by [@&#8203;PascalBourdier](https://github.com/PascalBourdier) in abiosoft/colima#1223
- faq: update to address potential need for Docker client configuration by [@&#8203;carljmosca](https://github.com/carljmosca) in abiosoft/colima#1231
- cli: add quotes to k3s-arg example for colima start by [@&#8203;olamilekan000](https://github.com/olamilekan000) in abiosoft/colima#1230
- chore: update LICENSE, fix copyright license year by [@&#8203;JasonnnW3000](https://github.com/JasonnnW3000) in abiosoft/colima#1235
- chore: fix copyright license year (Revert [#&#8203;1235](abiosoft/colima#1235)) by [@&#8203;windyakin](https://github.com/windyakin) in abiosoft/colima#1237
- chore: log possible error while reading config file by [@&#8203;olamilekan000](https://github.com/olamilekan000) in abiosoft/colima#1240
- build(deps): bump golang.org/x/term from 0.27.0 to 0.28.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in abiosoft/colima#1242
- core: use native shasum binary on macOS for download verification by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1245
- core: config initial value for kubernetes version if empty in yaml by [@&#8203;jason19970210](https://github.com/jason19970210) in abiosoft/colima#1255
- k8s: update latest version for default kubernetes release by [@&#8203;jason19970210](https://github.com/jason19970210) in abiosoft/colima#1259
- core: respect LIMA\_SSH\_PORT\_FORWARDER env var by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1263
- build(deps): bump golang.org/x/term from 0.28.0 to 0.29.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in abiosoft/colima#1268
- incus: remove core.https\_address from default config by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1273
- build(deps): bump github.com/spf13/cobra from 1.8.1 to 1.9.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in abiosoft/colima#1274
- docker: fix cgroupdriver by [@&#8203;win-t](https://github.com/win-t) in abiosoft/colima#1312
- revert: "docker: fix cgroupdriver" by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1314
- Properly reset formatting at the end of question prompts by [@&#8203;SukritBhatt](https://github.com/SukritBhatt) in abiosoft/colima#1324
- chore: reorganize dependencies in go.mod by [@&#8203;alexandear](https://github.com/alexandear) in abiosoft/colima#1325
- github workflows: pin dependencies by [@&#8203;thypon](https://github.com/thypon) in abiosoft/colima#1326
- vm: support UDP port forwarding by [@&#8203;stek29](https://github.com/stek29) in abiosoft/colima#1343
- core: update disk images by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1351
- k3s: fix config defaults for Kubernetes values by [@&#8203;kaisq](https://github.com/kaisq) in abiosoft/colima#1322
- vm: make binfmt emulation configurable by [@&#8203;winterqt](https://github.com/winterqt) in abiosoft/colima#1315
- docker: replace also localhost with host gateway ip in docker daemon.json by [@&#8203;fralken](https://github.com/fralken) in abiosoft/colima#1298
- k3s: write kubeconfig to KUBECONFIG defined file by [@&#8203;Sumoa](https://github.com/Sumoa) in abiosoft/colima#978
- Multiple minor updates by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1352
- build(deps): bump golang.org/x/term from 0.29.0 to 0.30.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in abiosoft/colima#1281
- chore: expend the path information about current profile being used by [@&#8203;jason19970210](https://github.com/jason19970210) in abiosoft/colima#1270
- core: add support for COLIMA\_PROFILE environment variable. by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1353
- ci: bump Go version by [@&#8203;abiosoft](https://github.com/abiosoft) in abiosoft/colima#1354

#### New Contributors

- [@&#8203;PascalBourdier](https://github.com/PascalBourdier) made their first contribution in abiosoft/colima#1223
- [@&#8203;carljmosca](https://github.com/carljmosca) made their first contribution in abiosoft/colima#1231
- [@&#8203;olamilekan000](https://github.com/olamilekan000) made their first contribution in abiosoft/colima#1230
- [@&#8203;JasonnnW3000](https://github.com/JasonnnW3000) made their first contribution in abiosoft/colima#1235
- [@&#8203;windyakin](https://github.com/windyakin) made their first contribution in abiosoft/colima#1237
- [@&#8203;jason19970210](https://github.com/jason19970210) made their first contribution in abiosoft/colima#1255
- [@&#8203;win-t](https://github.com/win-t) made their first contribution in abiosoft/colima#1312
- [@&#8203;SukritBhatt](https://github.com/SukritBhatt) made their first contribution in abiosoft/colima#1324
- [@&#8203;alexandear](https://github.com/alexandear) made their first contribution in abiosoft/colima#1325
- [@&#8203;thypon](https://github.com/thypon) made their first contribution in abiosoft/colima#1326
- [@&#8203;stek29](https://github.com/stek29) made their first contribution in abiosoft/colima#1343
- [@&#8203;kaisq](https://github.com/kaisq) made their first contribution in abiosoft/colima#1322
- [@&#8203;winterqt](https://github.com/winterqt) made their first contribution in abiosoft/colima#1315
- [@&#8203;fralken](https://github.com/fralken) made their first contribution in abiosoft/colima#1298
- [@&#8203;Sumoa](https://github.com/Sumoa) made their first contribution in abiosoft/colima#978

**Full Changelog**: abiosoft/colima@v0.8.1...v0.8.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40Ni4zIiwidXBkYXRlZEluVmVyIjoiNDEuNDYuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

udp binding not working UDP packets on port 5060 not reaching container with LIMA_SSH_PORT_FORWARDER=false
2 participants