Skip to content

Instantly share code, notes, and snippets.

@sidmulajkar
Created October 10, 2022 18:18
Show Gist options
  • Save sidmulajkar/472cc9dd475ef14a598db0c64f025491 to your computer and use it in GitHub Desktop.
Save sidmulajkar/472cc9dd475ef14a598db0c64f025491 to your computer and use it in GitHub Desktop.
/usr/bin/wg-quick: line 32: resolvconf: command not found

/usr/bin/wg-quick: line 32: resolvconf: command not found

This issue is caused while using the Wireguard in Ubuntu as the installation doesn't come with resolvconf or openresolv

Problem

sid@sid:~$ sudo wg-quick up /etc/wireguard/abc.conf
[sudo] password for sid: 
[#] ip link add abc type wireguard
[#] wg setconf abc /dev/fd/63
[#] ip -4 address add 10.2.0.2/32 dev abc
[#] ip link set mtu 1420 up dev abc
[#] resolvconf -a abc -m 0 -x
/usr/bin/wg-quick: line 32: resolvconf: command not found
[#] ip link delete dev abc
sid@sid:~$

To solve this we need to install resolvconf or openresolv

sudo apt install openresolv
sudo apt install resolvconf
sid@sid:~$ sudo nala install openresolv
================================================================================
 Installing                                                                     
================================================================================
  Package:                  Version:                                     Size:  
  openresolv                3.12.0-2                                     26 KB  
                                                                                
================================================================================
 Summary                                                                        
================================================================================
 Install 1 Packages                                                             
                                                                                
 Total download size   26 KB   
 Disk space required  105 KB   
                               
Do you want to continue? [Y/n] Y
╭─ Downloading… ───────────────────────────────────────────────────────────────╮
│ Total Packages: 1/1                                                          │
│ Last Completed: openresolv_3.12.0-2_all.deb                                  │
│ Time Remaining: 0:00:00 ━━━━━━━━━━━━━━━━━━ 100.0% • 25.6/25.6 KB • 70.7 KB/s │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Installing Packages ────────────────────────────────────────────────────────╮
│Unpacking:  openresolv (3.12.0-2)                                             │
│Setting up: openresolv (3.12.0-2)                                             │
│Processing: triggers for man-db (2.10.2-1)                                    │
│╭────────────────────────────────────────────────────────────────────────────╮│
││✔ Running dpkg … ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 0:00:00 • 3/3││
│╰────────────────────────────────────────────────────────────────────────────╯│
╰──────────────────────────────────────────────────────────────────────────────╯
Finished Successfully
sid@sid:~$ sudo wg-quick up /etc/wireguard/abc.conf
[#] ip link add abc type wireguard
[#] wg setconf abc /dev/fd/63
[#] ip -4 address add 10.2.0.2/32 dev abc
[#] ip link set mtu 1420 up dev abc
[#] resolvconf -a abc -m 0 -x
[#] wg set abc fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev abc 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
[#] nft -f /dev/fd/63
sid@sid:~$ 
@duzhuoshanwai
Copy link

root@armbian:/etc/wireguard# sudo apt install openresolv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package openresolv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'openresolv' has no installation candidate
root@armbian:/etc/wireguard# resolvconf
Command 'resolvconf' not found, but can be installed with:
apt install systemd-resolved
root@armbian:/etc/wireguard# apt install systemd-resolved
.......... succeed
root@armbian:/etc/wireguard# systemctl start wg-quick@wg0
root@armbian:/etc/wireguard# 

its work for me . ubuntu luner

@gearhead
Copy link

gearhead commented Dec 21, 2023

it works, but is 'less than desirable'. What would be better is if the wg-quick script would be able to tell if systemd-resolved is running or not then set the DNS appropriately. I was able to 'fix' the script by changing this portion of the script for my install:

HAVE_SET_DNS=0
set_dns() {
    [[ ${#DNS[@]} -gt 0 ]] || return 0
    local nameservers=$(IFS=" "; echo "${DNS[*]}")
    local searchdomains=$(IFS=","; echo "${DNS_SEARCH[*]}")
    if [[ -n $searchdomains ]]; then
        resolvectl dns "$INTERFACE" "$nameservers" --domain="$searchdomains"
    else
        resolvectl dns "$INTERFACE" "$nameservers"
    fi
    HAVE_SET_DNS=1
}

unset_dns() {
    [[ ${#DNS[@]} -gt 0 ]] || return 0
}

I do not have resolvconf installed and this works for me to start and stop my wireguard tunnel. It would be 'best' if the script could detect if systemd-resolved is ruinning then do this and use the original bits when resolvconf is needed.

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