Skip to content
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

Request: Add User Mode Networking #5

Closed
lars18th opened this issue Oct 1, 2024 · 10 comments
Closed

Request: Add User Mode Networking #5

lars18th opened this issue Oct 1, 2024 · 10 comments
Labels
question Further information is requested

Comments

@lars18th
Copy link
Contributor

lars18th commented Oct 1, 2024

Hi,

This project is very interesting. However, for developing the execution in Docker Desktop (Windows) will be desirable. At time, the networking is implemented using only the macvlan support. Other similar projects (using QEMU/KVM inside Docker) are supporting as an alternative the User Mode Networking. See more here: https://wiki.qemu.org/Documentation/Networking

I hope you want to consider it.

@AlbrechtL
Copy link
Owner

Actually, user mode network is already included. If you set the environment variable to WAN_IF: "host" is uses SLIRP. But the performance is really bad.

What is your use case?

@lars18th
Copy link
Contributor Author

lars18th commented Oct 2, 2024

Hi @AlbrechtL ,

What is your use case?

Running it (for testing and developing) in Windows 11 (Docker Desktop + WSL).

I have shown (a few minutes ago) that yes the SLIRP mode is supported...
But I suggest to do these small changes to make it more visible:

  • In docker-compose.yml add something like: #If WAN_IF is missing then "host" mode is selected.
  • Do the same for LAN_IF and add support for host mode in:
    if [[ -z "${LAN_IF}" ]]; then

Thank you.

@AlbrechtL
Copy link
Owner

In docker-compose.yml add something like: #If WAN_IF is missing then "host" mode is selected.

Great idea. I will add it.

Do the same for LAN_IF and add support for host mode in:

I did some experiments with it. The thing is that OpenWrt configures a DHCP server at the LAN side because it is a router. The SLIRP implementation on the other side has fixed IPs, a DHCP server and router functionally. See the QEMU SLIRP concept picture.
grafik
Source: https://wiki.qemu.org/Documentation/Networking

So you don't have any benefits of SLIRP at the LAN side. What do you want to do with it? Maybe I miss something here.

@lars18th
Copy link
Contributor Author

lars18th commented Oct 2, 2024

What do you want to do with it? Maybe I miss something here.

Do tests of complex configurations with it in my workstation.

Now it runs inside Windows (Docker Destop + WSL2) with this config:
(( NOTE: in .wslconfig >> [wsl2] networkingMode=mirrored ))

    environment:
        WAN_IF: "host"
        #LAN_IF: "" # Not defined. In the future "host"

    volumes:
      - ./data:/storage/  # With this you control where is the storage... start docker from the wsl shell.

Then the localhost:8006 is the program GUI. And with /usr/bin/fw_wan_open_* you will enable localhost:8000 for Luci and localhost:8022 for SSH.

Nice!

@lars18th
Copy link
Contributor Author

lars18th commented Oct 2, 2024

Hi @AlbrechtL ,

One small suggestion for the "host" mode of WAN_IF and LAN_IF:

  • With this "host mode networking" it will be interesting to add support to select IPv4 and/or IPv6 (with the option ipv4=on|off and ipv6=on|off). Using IPv6 it's a pain in several environments. Therefore if you support something like host4 to use ipv4=on,ipv6=off then it will be useful. Options could be host (default 4 and 6), host4 (only 4) and host6 (only 6). The idea is to block traffic at the qemu virtual interface and after configure OpenWRT with the corresponding values.

I hope you agree with that suggestion.

@AlbrechtL
Copy link
Owner

I'm not sure if I understood you correctly. But you are free to implement the options that you are needing, test it and send a pull request afterwards.

@lars18th
Copy link
Contributor Author

lars18th commented Oct 2, 2024

I'm not sure if I understood you correctly. But you are free to implement the options that you are needing, test it and send a pull request afterwards.

OK. But the problem is that the current documention is not sufficient for some aspects (however the project seems to be good maintained). Any recommendation to execute the tests inside the command line?

@AlbrechtL
Copy link
Owner

I just realized that I already implement SLIRP in LAN. The environment variable needs to be cleared, see

LAN_ARGS=""
if [[ -z "${LAN_IF}" ]]; then
LAN_ARGS="-device virtio-net,netdev=qlan0 -netdev user,id=qlan0,net=192.168.1.0/24"

But I never used it. Fell free to play with it.

Any recommendation to execute the tests inside the command line?

A good starting point is to build the Docker image yourself. Executing the automated tests something for an advanced usage. But you can read the test pipline https://github.com/AlbrechtL/openwrt-docker/blob/master/.github/workflows/test.yml how to do it.

@lars18th
Copy link
Contributor Author

lars18th commented Oct 2, 2024

Hi @AlbrechtL ,

I created the PR #7 to make it explicit. It's relevant in environments like Windows where only user networking is available. It works without problems with LAN_IF="host" and WAN_IF="host".

@AlbrechtL
Copy link
Owner

Thanks for your work! I merged your PR.

@AlbrechtL AlbrechtL added the question Further information is requested label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants