You are not logged in.

#1 2023-02-05 20:10:37

Del.Mar
Member
Registered: 2023-01-01
Posts: 5

[SOLVED] wg0 state UNKNOWN

Hi mates!
After activate wg0 interface the network doesn't work.

# wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip link set mtu 1420 up dev wg0
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n
[root@beast me]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 04:92:26:59:24:34 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.29/24 brd 192.168.0.255 scope global dynamic noprefixroute enp4s0
       valid_lft 23998sec preferred_lft 23998sec
    inet6 fe80::e854:1b76:e142:e6f1/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none 

Systemctl status show that service is active

# systemctl status wg-quick@wg0
● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/usr/lib/systemd/system/wg-quick@.service; enabled; preset: disabled)
     Active: active (exited) since Sun 2023-02-05 23:04:43 MSK; 1s ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 3575 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=0/SUCCESS)
   Main PID: 3575 (code=exited, status=0/SUCCESS)
        CPU: 29ms

Feb 05 23:04:43 beast systemd[1]: Starting WireGuard via wg-quick(8) for wg0...
Feb 05 23:04:43 beast wg-quick[3575]: [#] ip link add wg0 type wireguard
Feb 05 23:04:43 beast wg-quick[3575]: [#] wg setconf wg0 /dev/fd/63
Feb 05 23:04:43 beast wg-quick[3575]: [#] ip link set mtu 1420 up dev wg0
Feb 05 23:04:43 beast wg-quick[3575]: [#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
Feb 05 23:04:43 beast wg-quick[3575]: [#] ip -4 rule add not fwmark 51820 table 51820
Feb 05 23:04:43 beast wg-quick[3575]: [#] ip -4 rule add table main suppress_prefixlength 0
Feb 05 23:04:43 beast wg-quick[3575]: [#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
Feb 05 23:04:43 beast wg-quick[3610]: [#] iptables-restore -n
Feb 05 23:04:43 beast systemd[1]: Finished WireGuard via wg-quick(8) for wg0.

 # ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 04:92:26:59:24:34 brd ff:ff:ff:ff:ff:ff
7: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/none 

Last edited by Del.Mar (2023-02-06 07:55:06)

Offline

#2 2023-02-05 20:49:04

-thc
Member
Registered: 2017-03-15
Posts: 599

Re: [SOLVED] wg0 state UNKNOWN

Executing "wg-quick" normally sets the address via

ip -4 address add 10.1.2.3/24 dev wg0

which in your case is missing.

Please post your obfuscated "wg0.conf" from "/etc/wireguard".

Offline

#3 2023-02-05 21:19:12

Del.Mar
Member
Registered: 2023-01-01
Posts: 5

Re: [SOLVED] wg0 state UNKNOWN

-thc wrote:

Please post your obfuscated "wg0.conf" from "/etc/wireguard".

Yes, I've add Address and DNS, but still status unknown.

# cat /etc/wireguard/wg0.conf 
[Interface]
Address = 10.0.1.4/32
PrivateKey = key
DNS = 1.1.1.1,8.8.8.8

[Peer]
PublicKey = key
PresharedKey = key
AllowedIPs = 0.0.0.0/0
Endpoint = ip:51820
PersistentKeepalive = 15

Ip address set correctly

8: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    link/none 
    inet 10.0.1.4/32 scope global wg0
       valid_lft forever preferred_lft forever

But problem with routes

[root@beast user]# wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.0.1.4/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a wg0 -m 0 -x
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] iptables-restore -n

[root@beast user]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         _gateway        0.0.0.0         UG        0 0          0 enp4s0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 enp4s0

Offline

#4 2023-02-06 06:35:56

-thc
Member
Registered: 2017-03-15
Posts: 599

Re: [SOLVED] wg0 state UNKNOWN

Del.Mar wrote:
8: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000

State "UNKNOWN" is normal.

Del.Mar wrote:

But problem with routes

Wireguard as a "full tunnel" VPN operates with a separate, numbered routing table (51820) and a packet marker (fwmark 51820) to route all packets through the wg0 tunnel except the tunnel packets themselves.

So - everything looks o.k. now.

Offline

#5 2023-02-06 07:54:20

Del.Mar
Member
Registered: 2023-01-01
Posts: 5

Re: [SOLVED] wg0 state UNKNOWN

-thc wrote:

So - everything looks o.k. now.

Yeah, today it's works fine.
Thanks, mate!

Offline

Board footer

Powered by FluxBB