Skip to content

Install on OpenWRT X86_64

David Ansart edited this page Apr 6, 2026 · 39 revisions

Build vwifi for OpenWRT

  • On the cross-compiler

  • Install additional packages that may be required :

    sudo apt install --yes zstd unzip
    
  • Install necessary packages for libnl :

    sudo apt install --yes make bison flex
    
  • Install necessary packages for vwifi :

    sudo apt install --yes cmake pkg-config
    
  • Create the working folder ${HOME}/OpenWRT :

    mkdir ${HOME}/OpenWRT
    cd ${HOME}/OpenWRT
    

OpenWRT

Download the SDK of OpenWRT

Download the Toolchain of OpenWRT

  • Download it :

    wget https://downloads.openwrt.org/releases/25.12.2/targets/x86/64/openwrt-toolchain-25.12.2-x86-64_gcc-14.3.0_musl.Linux-x86_64.tar.zst
    
  • Uncompress and rename it to ${HOME}/OpenWRT/TOOLCHAIN :

    tar --zstd -xf openwrt-toolchain-25.12.2-x86-64_gcc-14.3.0_musl.Linux-x86_64.tar.zst
    mv openwrt-toolchain-25.12.2-x86-64_gcc-14.3.0_musl.Linux-x86_64 TOOLCHAIN
    
  • Update PATH :

    PATH=$PATH:"${HOME}/OpenWRT/TOOLCHAIN/toolchain-x86_64_gcc-14.3.0_musl/bin"
    
    export STAGING_DIR="/tmp"
    

LibNL

Download the code of libnl

  • The file is here : https://github.com/thom311/libnl

  • Download it :

    wget https://github.com/thom311/libnl/releases/download/libnl3_12_0/libnl-3.12.0.tar.gz
    
  • Uncompress and rename it to ${HOME}/OpenWRT/libnlsrc :

    tar xf libnl-3.12.0.tar.gz
    mv libnl-3.12.0 libnlsrc
    

Compilation of libnl for OpenWRT

  • Go to the folder ${HOME}/OpenWRT/libnlsrc :

    cd ${HOME}/OpenWRT/libnlsrc
    
  • Build :

    ./configure --prefix=${HOME}/OpenWRT/LIBNL --build=x86_64-unknown-linux-gnu  --host=x86_64-openwrt-linux-musl LDFLAGS="-static"
    make
    
  • Link necessary files in ${HOME}/OpenWRT/LIBNL :

    mkdir ${HOME}/OpenWRT/LIBNL
    ln -s ${HOME}/OpenWRT/libnlsrc/lib/.libs ${HOME}/OpenWRT/LIBNL/lib
    ln -s ${HOME}/OpenWRT/libnlsrc/include ${HOME}/OpenWRT/LIBNL/include
    ln -s ${HOME}/OpenWRT/LIBNL/lib ${HOME}/OpenWRT/LIBNL/include/libnl3
    

VWifi

Download the code of vwifi

  • Download it :

    cd ${HOME}/OpenWRT/
    wget https://github.com/Raizo62/vwifi/archive/refs/heads/master.zip
    
  • Uncompress and rename it to ${HOME}/OpenWRT/vwifi :

    unzip master.zip
    mv vwifi-master vwifi
    cd vwifi
    
  • Build vwifi-client :

    mkdir build && cd build
    
    export PKG_CONFIG_PATH=${HOME}/OpenWRT/libnlsrc
    cmake .. \
          -DCMAKE_CXX_COMPILER=x86_64-openwrt-linux-musl-g++ \
          -DCMAKE_EXE_LINKER_FLAGS="-L${HOME}/OpenWRT/LIBNL/lib -lnl-genl-3 -lnl-3" \
          -DCMAKE_CXX_FLAGS="-I${HOME}/OpenWRT/LIBNL/include"
    
  • If you will not build vsock for OpenWRT, you can disable it in vwifi :

    cmake .. -DENABLE_VHOST=OFF
    
  • Build :

    make
    
  • Copy vwifi-client on OpenWRT, in the folder /usr/sbin/ :

    scp -O vwifi-client root@192.168.1.1:/usr/sbin/
    

On OpenWRT

Prerequisites

mac80211-hwsim

  • Install le package kmod-mac80211-hwsim :

    apk update
    apk add kmod-mac80211-hwsim
    
  • Unload it and set the default number of radios to 0 :

    rmmod mac80211-hwsim
    echo 'mac80211_hwsim radios=0' > /etc/modules.d/mac80211-hwsim
    
  • Delete the configurations generated by OpenWRT for the radios created by the install of kmod-mac80211-hwsim :

    uci delete wireless.radio0
    uci delete wireless.default_radio0
    uci delete wireless.radio1
    uci delete wireless.default_radio1
    
  • Apply the changes :

    uci commit wireless
    
  • Reboot Openwrt :

    reboot
    

libstdcpp6

  • Package required because vwifi is C++ :

    apk update
    apk add libstdcpp6
    

Run with command line

  • vwifi-client 172.16.0.1 --number 1 with 172.16.0.1 the IP of vwifi-server

Run like a service

  • Create the service file : /etc/init.d/vwifi-client :

    #!/bin/sh /etc/rc.common
    
    USE_PROCD=1
    START=99
    STOP=10
    
    start_service() {
          procd_open_instance
    
          procd_set_param command /usr/sbin/vwifi-client 172.16.0.1 --number 1 --mac '74:f8:f6:66'
    
          # Redirect output
          procd_set_param stdout 1
          procd_set_param stderr 1
    
          # Enable automatic restart if process crashes
          procd_set_param respawn
    
          procd_close_instance
    }
    
    • Modify 172.16.0.1 to the IP of vwifi-server
  • Make /etc/init.d/vwifi-client executable :

    chmod +x /etc/init.d/vwifi-client
    
  • Configure to run the service when OpenWRT boots :

    service vwifi-client enable
    
  • Run the service :

    service vwifi-client start
    

Test Wifi from OpenWRT

  • Don't forget to install "wpa-supplicant" and "hostapd" :

    apk add hostapd
    apk add wpa-supplicant
    

Clone this wiki locally