Skip to content

feat(network): add support for forward guest localhost DNS for unikraft - #966

Open
alimx07 wants to merge 1 commit into
urunc-dev:mainfrom
alimx07:feat/unikraft-dns
Open

feat(network): add support for forward guest localhost DNS for unikraft#966
alimx07 wants to merge 1 commit into
urunc-dev:mainfrom
alimx07:feat/unikraft-dns

Conversation

@alimx07

@alimx07 alimx07 commented Aug 13, 2026

Copy link
Copy Markdown

Description

This PR will add support for localhost semantics added in #793 for unikraft unikernels. This will be done by modifying the CMD line defined here:

u.configureUnikraftArgs(data.Rootfs.Type, data.Net.IP, data.Net.Gateway, data.Net.Mask, data.Net.DNSServer)

as the new DNSServer will be either:

  • the Default 8.8.8.8
  • The Custom one defined in internal/constants/network_constants (e.g. 192.168.100.100)

The exact of this happens is defined in #793 but as breif, we detect if we have localhost resolvers ,then rewrite them to point to our Custom resolver, where we apply TC rules to intercept traffic and redirect it according to our rules

Related issues

How was this tested?

LLM usage

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 73ae987
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a991efe71b55f0008171499

@alimx07 alimx07 changed the title Feat/unikraft dns feat(network): add support for forward guest localhost DNS for unikraft Aug 13, 2026

@cmainas cmainas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @alimx07 , this looks good, We can merge it directly.

@cmainas

cmainas commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

However, please complete the PR description correctly.

@cmainas

cmainas commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Hello @alimx07 ,

let;s make this as a standalone PR and fix the hardcoded value of unikraft's DNS configuration. What we need is to simply read the /etc/resolv/conf file find the dns server and set DNSServer respectively. See #979 (comment) for more context.

@alimx07

alimx07 commented Sep 1, 2026

Copy link
Copy Markdown
Author

Hello @alimx07 ,

let;s make this as a standalone PR and fix the hardcoded value of unikraft's DNS configuration. What we need is to simply read the /etc/resolv/conf file find the dns server and set DNSServer respectively. See #979 (comment) for more context.

Hi @cmainas , I tried to make it minimal, it does the required functionality but even that we still need the docker PR for docker case and TC rules.

@cmainas cmainas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @alimx07 ,

this PR fixes an existing bug for k8s deployments so it has priority over the docker case.

A few changes for the CI, so we can merge:

  • sign-off and squash your commits
  • add yourself in https://github.com/urunc-dev/urunc/blob/main/.github/contributors.yaml
  • mark this as ready for review. You can can mark the sidecar test PR as draft
  • the test will never succeed. I have created a new image harbor.nbfc.io/nubificus/urunc/dns-test-qemu-unikraft-initrd:latest . The expected output should be github.com OK. I have also added these comments in the respective lines.

Comment thread tests/e2e/test_cases.go Outdated
TestFunc: namespaceTest,
},
{
Image: "ghcr.io/alimx07/dns-test-qemu-unikraft-initrd:latest",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Replace with harbor.nbfc.io/nubificus/urunc/dns-test-qemu-unikraft-initrd:latest

Comment thread tests/e2e/test_cases.go Outdated
StaticNet: false,
SideContainers: []string{},
Skippable: true,
ExpectOut: "Address: 8.8.8.8",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Replace with github.com OK

@alimx07
alimx07 marked this pull request as ready for review September 3, 2026 07:14
Unikraft guests used a hardcoded DNS server, so name resolution inside
the unikernel ignored the DNS configuration of the container. Parse the
nameserver entry from the container's resolv.conf and pass it to the
guest through the kernel command line.

Signed-off-by: Ali Mohamed <amx746@gmail.com>

@cmainas cmainas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @alimx07 ,

thank you for the rebase, but the it does not build. Also, now we need to take into account libcontainer and move the DNS server discovery in the "urunc create" process, since "urunc monitor" in libcontainer does not have a view of the host rootfs.

// virtual ethernet interface inside the namespace
netArgs.MAC = networkInfo.EthDevice.MAC
netArgs.MTU = networkInfo.EthDevice.MTU
netArgs.DNSServer = getDNSServer(mounts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to move this to InitisalSetup so it can also take effect in libcontainer. The monitorSpec struct can be updated to store the value of DNS so it can be then read from the urunc reexec and urunc monitor processes.

@alimx07

alimx07 commented Sep 7, 2026

Copy link
Copy Markdown
Author

Hi @cmainas, sorry, I have been a bit busy these days. If others are blocked, feel free to assign someone else to continue with this PR. Otherwise, I’ll look into it over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants