Skip to content

ping(8) does not work #214

Closed
Closed

Description

@kamalmarhubi

Not sure why this doesn't work. I have CAP_NET_RAW and CAP_NET_ADMIN in the bounding set inside the container, and ping has the required capabilities

⬢[kamal@toolbox ~]$ capsh --print | grep '^Bounding' | egrep -o 'cap_net_(raw|admin)'
cap_net_admin
cap_net_raw
⬢[kamal@toolbox ~]$ getcap $(readlink -f $(which ping))
/usr/bin/ping = cap_net_admin,cap_net_raw+p

but

⬢[kamal@toolbox ~]$ ping 1.1
ping: socket: Operation not permitted

This makes it hard to really use the toolbox as a day-to-day development environment.

Environment:

kamal@kx7 ~> rpm -q toolbox
toolbox-0.0.11-1.fc30.noarch
kamal@kx7 ~> rpm-ostree status
State: idle
AutomaticUpdates: disabled
Deployments:
● ostree://fedora:fedora/30/x86_64/silverblue
                   Version: 30.20190630.0 (2019-06-30T00:38:30Z)
                BaseCommit: b6aa90afa5dace3cdb49ceb35c3bf6ba735638015e6239fa52bfbfb110aab9cf
              GPGSignature: Valid signature by F1D8EC98F241AAF20DF69420EF3C111FCFC659B9
           LayeredPackages: fish gstreamer1-libav htop iotop neovim powertop ripgrep tmux
             LocalPackages: rpmfusion-free-release-30-1.noarch

Activity

  1. ibotty commented on Jul 19, 2019

    @ibotty

    This can be allowed with the sysctl net.ipv4.ping_group_range. If you set it to e.g. 0 2000000, it will work.

  2. debarshiray commented on Jul 22, 2019

    @debarshiray
    Member

    Yes, this is a known shortcoming of rootless Podman. podman-container-tools/podman#1550 has some discussion on the topic specifically for Toolbox.

  3. debarshiray commented on Jul 22, 2019

    @debarshiray
    Member

    One immediate workaround is to use flatpak-spawn --host ping ...

  4. debarshiray commented on Jul 22, 2019

    @debarshiray
    Member

    I filed systemd/systemd#13141 to get net.ipv4.ping_group_range enabled by default.

  5. debarshiray commented on Jul 24, 2019

    @debarshiray
    Member

    This should now start working once systemd 243 gets released and is picked up by distributors.

    In the meantime, you can put the following in a file in /etc/sysctl.d and reboot:

    net.ipv4.ping_group_range = 0 2147483647
    
  6. changed the title [-]ping does not work inside the container[/-] [+]ping(8) does not work[/+] on Jul 24, 2019
  7. lukehutch commented on Nov 24, 2019

    @lukehutch

    I have the same issue on an f30 host, running an f31 toolbox. The flatpak-spawn --host ping ... workaround works for me. But ping is not the only command affected. There is also some issue with DNS resolution:

    $ git clone https://pagure.io/ros.git
    Cloning into 'ros'...
    fatal: unable to access 'https://pagure.io/ros.git/': Could not resolve host: pagure.io
    $ flatpak-spawn --host git clone https://pagure.io/ros.git
    Cloning into 'ros'...
    remote: Counting objects: 4308, done.        
    remote: Compressing objects: 100% (1146/1146), done.        
    remote: Total 4308 (delta 3941), reused 3467 (delta 3141)        
    Receiving objects: 100% (4308/4308), 857.30 KiB | 2.74 MiB/s, done.
    Resolving deltas: 100% (3941/3941), done.
    $
    

    flatpak-spawn --host bash seems to solve the problem, but there is no ⬢ in front of the prompt. (I assume it's impossible for anything to break out of the container, so this is just a nested bash instance.)

    ⬢[luke@toolbox ~]$ flatpak-spawn --host bash
    bash: cannot set terminal process group (-1): Inappropriate ioctl for device
    bash: no job control in this shell
    [luke@localhost ~]$ ping 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=34.0 ms
    64 bytes from 8.8.8.8: icmp_seq=2 ttl=45 time=33.9 ms
    ^C
    --- 8.8.8.8 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 3ms
    rtt min/avg/max/mdev = 33.911/33.965/34.020/0.192 ms
    [luke@localhost ~]$ exit
    ⬢[luke@toolbox ~]$ 
    

    The first time I exited out of the nested bash instance, the host kernel locked up hard, but I don't know if this has anything to do with podman, or if it was just a freak occurrence.

  8. debarshiray commented on Nov 25, 2019

    @debarshiray
    Member

    There is also some issue with DNS resolution:

    $ git clone https://pagure.io/ros.git
    Cloning into 'ros'...
    fatal: unable to access 'https://pagure.io/ros.git/': Could not resolve host: pagure.io
    $ flatpak-spawn --host git clone https://pagure.io/ros.git
    Cloning into 'ros'...
    remote: Counting objects: 4308, done.        
    remote: Compressing objects: 100% (1146/1146), done.        
    remote: Total 4308 (delta 3941), reused 3467 (delta 3141)        
    Receiving objects: 100% (4308/4308), 857.30 KiB | 2.74 MiB/s, done.
    Resolving deltas: 100% (3941/3941), done.
    $
    

    This might be unrelated. What does /etc/resolv.conf look like inside your toolbox container?

    flatpak-spawn --host bash seems to solve the problem, but there is no ⬢ in front of the
    prompt. (I assume it's impossible for anything to break out of the container, so this is just a
    nested bash instance.)

    flatpak-spawn is how you break out of the container. :)

    The first time I exited out of the nested bash instance, the host kernel locked up hard, but
    I don't know if this has anything to do with podman, or if it was just a freak occurrence.

    My first instinct is that it was just a coincidence. However if you can reliably reproduce it, then it might be worth looking into.

  9. lukehutch commented on Nov 25, 2019

    @lukehutch

    This might be unrelated. What does /etc/resolv.conf look like inside your toolbox container?

    I just tried this in a freshly created toolbox (which also does not have working DNS), f30 on an f30 host:

    $ toolbox enter
    ⬢[luke@toolbox ~]$ cat /etc/resolv.conf 
    cat: /etc/resolv.conf: No such file or directory
    ⬢[luke@toolbox ~]$ logout
    [luke@localhost ~]$ cat /etc/resolv.conf 
    # Generated by NetworkManager
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    flatpak-spawn is how you break out of the container. :)

    Ah, thanks for explaining! I read the man page now.

    My first instinct is that it was just a coincidence. However if you can reliably reproduce it, then it might be worth looking into.

    I haven't seen the hard lockup more than once.

    Separately, are the following warnings expected? TTY control sequences are broken in the spawned bash. (Sorry for the slightly off topic question...)

    ⬢[luke@toolbox ~]$ flatpak-spawn --host bash
    bash: cannot set terminal process group (-1): Inappropriate ioctl for device
    bash: no job control in this shell
    
  10. debarshiray commented on Nov 26, 2019

    @debarshiray
    Member

    I just tried this in a freshly created toolbox (which also does not have working DNS),
    f30 on an f30 host:

    $ toolbox enter
    ⬢[luke@toolbox ~]$ cat /etc/resolv.conf 
    cat: /etc/resolv.conf: No such file or directory
    ⬢[luke@toolbox ~]$ logout
    [luke@localhost ~]$ cat /etc/resolv.conf 
    # Generated by NetworkManager
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    I think the lack of DNS is the real problem here. However, I am not sure how that came to be.

    Is /etc/resolv.conf symbolic link on the host? What version of Toolbox are you using?

    Separately, are the following warnings expected? TTY control sequences are broken in the
    spawned bash. (Sorry for the slightly off topic question...)

    Yes, the warnings are expected. They are caused by the absence of a controlling TTY device for the shell. The controlling TTY device is propagated from parent to child processes, but in this case, flatpak-spawn operates over D-Bus, which is a client-server model. Hence the new shell is not a child of the previous one, which means it doesn't get the controlling TTY device.

  11. lukehutch commented on Nov 26, 2019

    @lukehutch

    I think the lack of DNS is the real problem here. However, I am not sure how that came to be.

    toolbox-0.0.16-1.fc30.noarch

    I just discovered that /etc/resolv.conf is a broken link:

    ⬢[luke@toolbox ~]$ ls -l /etc/resolv.conf 
    lrwxrwxrwx 1 root root 25 Nov 26 11:07 /etc/resolv.conf -> /run/host/etc/resolv.conf
    ⬢[luke@toolbox ~]$ ls -l /run/host/etc/resolv.conf 
    lrwxrwxrwx 1 nobody nobody 35 Nov 26 07:34 /run/host/etc/resolv.conf -> /var/run/NetworkManager/resolv.conf
    ⬢[luke@toolbox ~]$ $ ls -l /var/run/NetworkManager/resolv.conf
    ls: cannot access '/var/run/NetworkManager/resolv.conf': No such file or directory
    
  12. debarshiray commented on Nov 26, 2019

    @debarshiray
    Member

    I just discovered that /etc/resolv.conf is a broken link:

    ⬢[luke@toolbox ~]$ ls -l /etc/resolv.conf 
    lrwxrwxrwx 1 root root 25 Nov 26 11:07 /etc/resolv.conf -> /run/host/etc/resolv.conf
    ⬢[luke@toolbox ~]$ ls -l /run/host/etc/resolv.conf 
    lrwxrwxrwx 1 nobody nobody 35 Nov 26 07:34 /run/host/etc/resolv.conf -> /var/run/NetworkManager/resolv.conf
    ⬢[luke@toolbox ~]$ $ ls -l /var/run/NetworkManager/resolv.conf
    ls: cannot access '/var/run/NetworkManager/resolv.conf': No such file or directory
    

    That's due to #187 and https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/269

    sudo rm /etc/resolv.conf on the host, followed by an immediate reboot should sort out the NetworkManager mix-up.

    Anyway, it's not related to this issue, but thanks for stopping by. :)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions