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

Podman machine user mode networking reset doesn't restore wsl.conf #20625

Closed
Narwhalrus opened this issue Nov 7, 2023 · 6 comments · Fixed by #20798
Closed

Podman machine user mode networking reset doesn't restore wsl.conf #20625

Narwhalrus opened this issue Nov 7, 2023 · 6 comments · Fixed by #20798
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. remote Problem is in podman-remote windows issue/bug on Windows

Comments

@Narwhalrus
Copy link

Narwhalrus commented Nov 7, 2023

Issue Description

When switching between "normal" networking and user mode networking on the WSL2 podman machine, the wsl.conf isn't restored to it's default state, which results in networking issues when communicating from containers to the Windows host.

Steps to reproduce the issue

Steps to reproduce the issue
In powershell...

PS> podman machine init
PS> podman machine start
PS> wsl -d podman-machine-default cat /etc/resolve.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:                                                                                                            
# [network]                                                                                                             
# generateResolvConf = false                                                                                           
nameserver <virtual_adaptor_ip_addr>
PS> wsl -d podman-machine-default cat /etc/wsl.conf
[user]                                                                                                                  
default=user
PS> podman machine stop
PS> podman machine set --user-mode-networking
PS> podman machine start
PS> wsl -d podman-machine-default cat /etc/resolve.conf
; generated by /usr/sbin/dhclient-script                                                                               
nameserver <user_mode_networking_ip_addr>
PS> wsl -d podman-machine-default cat /etc/wsl.conf
[user]
default=user

[network]
generateResolvConf = false
PS> podman machine stop
PS> podman machine set --user-mode-networking=false
PS> podman machine start
PS> wsl -d podman-machine-default cat /etc/resolve.conf
...
nameserver <another_ip_addr>
options edns0 trust-ad
search .
PS> wsl -d podman-machine-default cat /etc/wsl.conf
[user]
default=user

[network]
generateResolvConf = false

Describe the results you received

/etc/wsl.conf is not restored to the default:

[user]
default=user

that is installed with the podman machine

Describe the results you expected

/etc/wsl.conf is restored to the default when switching from user mode networking to "normal" networking

podman info output

host:
  arch: amd64
  buildahVersion: 1.32.0
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.7-2.fc38.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 98.66
    systemPercent: 0.74
    userPercent: 0.6
  cpus: 8
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: container
    version: "38"
  eventLogger: journald
  freeLocks: 2048
  hostname: windev1
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 5.15.90.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 16058023936
  memTotal: 16605179904
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.8.0-1.fc38.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.8.0
    package: netavark-1.8.0-2.fc38.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.8.0
  ociRuntime:
    name: crun
    package: crun-1.11-1.fc38.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.11
      commit: 11f8d3dc9fc4bb8a0adcff5ba8bd340f24612701
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20231004.gf851084-1.fc38.x86_64
    version: |
      pasta 0^20231004.gf851084-1.fc38.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-1.fc38.x86_64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 4294967296
  swapTotal: 4294967296
  uptime: 0h 2m 53.00s
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 618876928
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 4.7.2
  Built: 1698762611
  BuiltTime: Tue Oct 31 09:30:11 2023
  GitCommit: ""
  GoVersion: go1.20.10
  Os: linux
  OsArch: linux/amd64
  Version: 4.7.2

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

No

Additional environment details

No response

Additional information

Workaround is to manually restore /etc/wsl.conf to the original configuration without generateResolvConf = false and restart the podman machine.

@Narwhalrus Narwhalrus added the kind/bug Categorizes issue or PR as related to a bug. label Nov 7, 2023
@github-actions github-actions bot added the remote Problem is in podman-remote label Nov 7, 2023
@ashley-cui ashley-cui added the windows issue/bug on Windows label Nov 8, 2023
@Luap99
Copy link
Member

Luap99 commented Nov 10, 2023

@n1hility PTAL

@n1hility
Copy link
Member

Thanks for the report this is indeed a bug. Will take a look at it soon.

@n1hility
Copy link
Member

/assign

@Narwhalrus
Copy link
Author

A somewhat related question on this that just came up. Feel free to ignore or tell me to ask elsewhere if this isn't the place:

With user mode networking active, how does one communicate between the podman machine (or a container running on the machine) and the windows host? For example, if I wanted to forward X to an X server running on my Windows machine.

With the default networking I can get the windows host IP from /etc/resolv.conf or using the route command, but I've been unable to find a way to communicate to/from the host with user mode networking active.

Thanks for working on the bug!

@n1hility
Copy link
Member

@Narwhalrus If you are using user-mode networking you could always use the IP address 192.168.127.254, which is the internal host.

Alternatively with either user-mode / non user-mode you can use your windows host pc / host name with a .local suffix (e.g foo.local). Although for this particular .local name to route correctly (since it points to your external ip), it does require that your local windows defender policy allow it. You may need to add a rule if it does not.

@Narwhalrus
Copy link
Author

@Narwhalrus If you are using user-mode networking you could always use the IP address 192.168.127.254, which is the internal host.

Alternatively with either user-mode / non user-mode you can use your windows host pc / host name with a .local suffix (e.g foo.local). Although for this particular .local name to route correctly (since it points to your external ip), it does require that your local windows defender policy allow it. You may need to add a rule if it does not.

I'll give that a shot. Thank you for the quick reply!

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Feb 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. remote Problem is in podman-remote windows issue/bug on Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants