From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: hegyi.mokka@gmail.com Received: from krantz.zx2c4.com (localhost [127.0.0.1]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 52bfb062 for ; Sun, 22 Jul 2018 06:36:08 +0000 (UTC) Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 943d0450 for ; Sun, 22 Jul 2018 06:36:08 +0000 (UTC) Received: by mail-it0-x22d.google.com with SMTP id p17-v6so19658337itc.2 for ; Sat, 21 Jul 2018 23:45:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zsolt Hegyi Date: Sun, 22 Jul 2018 08:44:47 +0200 Message-ID: Subject: Re: WireGuard on Docker To: Mohammad Amir Heshmatkhah , wireguard@lists.zx2c4.com Content-Type: multipart/alternative; boundary="00000000000019ae4e057190de0a" List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , --00000000000019ae4e057190de0a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable CC'ing the list as well. On Sun, 22 Jul 2018, 08:43 Zsolt Hegyi, wrote: > Hi Mohammad, > > You need to load the WireGuard kernel module on your host OS, not inside > the containers. All containers "share" and run on the same kernel as the > host OS does. > > Best regards, > Zsolt > > > On Sat, 21 Jul 2018, 23:34 Mohammad Amir Heshmatkhah, < > maheshmatkhah.soft@gmail.com> wrote: > >> Hi, >> I want to run WireGuard on a docker container as server, >> I try difrent base Images but I get this error message every time: >> >> [#] ip link add wg0 type wireguard >> RTNETLINK answers: Operation not supported >> Unable to access interface: Protocol not supported >> [#] ip link delete dev wg0 >> Cannot find device "wg0" >> >> Here is 3 Dokerfiles I tried: >> >> FROM alpine:3.7 >> RUN apk upgrade --update \ >> && echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> >> /etc/apk/repositories \ >> && apk add --no-cache bash wireguard-tools >> >> ENTRYPOINT [ "wg-quick", "up", "wg0" ] >> >> =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94- >> >> FROM ubuntu:16.04 >> RUN apt-get update && apt-get install -y software-properties-common >> apt-utils \ >> && add-apt-repository ppa:wireguard/wireguard \ >> && apt-get update \ >> && apt-get install -y iproute linux-headers-$(uname -r) wireguard-dkms >> wireguard-tools wireguard >> >> ENTRYPOINT [ "wg-quick", "up", "wg0" ] >> >> =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94- >> >> FROM debian:9 >> RUN echo "deb http://deb.debian.org/debian/ unstable main" > >> /etc/apt/sources.list.d/unstable.list \ >> && printf 'Package: *\nPin: release a=3Dunstable\nPin-Priority: 150\n' > >> /etc/apt/preferences.d/limit-unstable \ >> && apt-get update && apt-get install -y wireguard >> >> ENTRYPOINT [ "wg-quick", "up", "wg0" ] >> >> =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94- >> >> I run this containers with: >> >> sudo docker run -it -v $(pwd)/config:/etc/wireguard/ -v /dev:/dev -v >> /lib/modules:/lib/modules --cap-add=3DALL --privileged >> >> where wg0.conf is located in " $(pwd)/config/wg0.conf" on host machine >> >> =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94- >> >> and here is my wg0.conf file: >> >> [Interface] >> Address =3D 172.26.10.1/24 >> SaveConfig =3D true >> PrivateKey =3D >> ListenPort =3D 40540 >> >> [Peer] >> PublicKey =3D >> AllowedIPs =3D 172.26.10.2/32 >> >> =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94- >> >> So, How can I fix this "*Unable to access interface: Protocol not >> supported*" error? >> >> _______________________________________________ >> WireGuard mailing list >> WireGuard@lists.zx2c4.com >> https://lists.zx2c4.com/mailman/listinfo/wireguard >> > --00000000000019ae4e057190de0a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable CC'ing the list as well.

On Sun, 22 Jul 2018, 08:43 Zsolt Hegyi, <hegyi.mokka@gmail.com> wrote:
Hi Mohammad,

You need to load the WireG= uard kernel module on your host OS, not inside the containers. All containe= rs "share" and run on the same kernel as the host OS does.
<= div>
Best regards,
Zsolt


On Sat, 21 Jul 2018, 23:34 Mohammad Ami= r Heshmatkhah, <maheshmatkhah.soft@gmail.com> wrote:
Hi,
I want to run WireGuard on a docker container as server,
I try difrent base Images but=C2=A0 I get this error message every= time:

[#] ip link add wg0 t= ype wireguard
RTNETLINK answers: Operation not support= ed
Unable to access interface: Protocol not supported<= /div>
[#] ip link delete dev wg0
Cannot= find device "wg0"

Here is 3 Dokerfiles I tried:

FROM alpine:3.7
RUN apk upgrade --update \
&& echo=C2=A0http://dl-cdn.alpinelinux.org/alpine/edge/testing=C2=A0>> /etc/apk/repositories \
&& apk a= dd --no-cache bash wireguard-tools

ENTRYPOINT [ "wg-quick", "up", "wg0" ]=

=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94-

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y softwar= e-properties-common apt-utils \=C2=A0
&& add-a= pt-repository ppa:wireguard/wireguard \
&& apt= -get update \
&& apt-get install -y iproute li= nux-headers-$(uname -r) wireguard-dkms wireguard-tools wireguard

ENTRYPOINT [ "wg-quick", &qu= ot;up", "wg0" ]

=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94-

FROM debian:9
RUN echo "deb=C2=A0= http://deb.debian.org/debian/=C2=A0= unstable main" > /etc/apt/sources.list.d/unstable.list \
&& printf 'Package: *\nPin: release a=3Dunstable\nPi= n-Priority: 150\n' > /etc/apt/preferences.d/limit-unstable \
&& apt-get update && apt-get install -y wireg= uard

ENTRYPOINT [ "wg-q= uick", "up", "wg0" ]

=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94-
<= br>
I run this containers with:
<= br>
sudo docker run -it -v $(pwd)/config:/etc/wireguar= d/ -v=C2=A0 /dev:/dev=C2=A0 -v=C2=A0 /lib/modules:/lib/modules=C2=A0 --cap-= add=3DALL --privileged <image name here>

where wg0.conf is located in " $(pwd)/config/wg0.= conf" on host machine

=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94-

and here is my wg0.conf file:

<= div style=3D"font-size:small;text-decoration-style:initial;text-decoration-= color:initial">[Interface]
Address =3D=C2=A0172.26.10.1/24
SaveConfig =3D true
PrivateKey =3D <server private key here>
ListenPort =3D 40540

[Peer]
PublicKey =3D <client public key here&= gt;
AllowedIPs =3D=C2=A0172.26.10= .2/32

=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94-

So, How can= I fix this "Unable to access interface: Protocol not supported= " error?

_______________________________________________
WireGuard mailing list
WireGuard@li= sts.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard=
--00000000000019ae4e057190de0a--