Coder Social home page Coder Social logo

netmaker-openwrt's Introduction

Netmaker-OpenWRT

Netmaker is a platform for creating and managing fast, secure, and dynamic virtual overlay networks using WireGuard. This project offers OpenWRT packages for Netmaker.

Installing package

Download the prebuild package and copy it onto your OpenWRT installation, preferably into the /tmp folder.

Then install the ipk package file:

opkg install netmaker_*.ipk

Now start netclient of Netmaker:

/etc/init.d/netclient start

Compiling from Sources

To include Netmaker into your OpenWRT image or to create an .ipk package (equivalent to Debians .deb files), you have to build an OpenWRT image.

Now prepare OpenWRT:

git clone https://github.com/openwrt/openwrt
cd openwrt

./scripts/feeds update -a
./scripts/feeds install -a

To build Netmaker for OpenWRT, you need to have Golang with OpenWRT build envirment. Then, you can insert the Netmaker package using a package feed or add the package manually.

Add package by feed

A feed is the standard way packages are made available to the OpenWRT build system.

Put this line in your feeds list file (e.g. feeds.conf.default)

src-git netmaker http://github.com/sbilly/netmaker-openwrt.git

Update and install the new feed

./scripts/feeds update netmaker
./scripts/feeds install netmaker

Now continue with the building packages section.

Building Packages

Configure packages:

make menuconfig

Now select the appropiate "Target System" and "Target Profile" depending on what target chipset/router you want to build for. Also mark the Netmaker package under Network ---> VPN ---> <*> netmaker.

Now compile/build everything:

make

The images and all *.ipk packages are now inside the bin/ folder, including the netmaker package. You can install the Netmaker .ipk on the target device using opkg install .

For details please check the OpenWRT documentation.

Build bulk packages

For a release, it is useful the build packages at a bulk for multiple targets:

#!/bin/sh

# dump-target-info.pl is used to get all targets configurations:
# https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=scripts/dump-target-info.pl

./scripts/dump-target-info.pl architectures | while read pkgarch target1 rest; do
  echo "CONFIG_TARGET_${target1%/*}=y" > .config
  echo "CONFIG_TARGET_${target1%/*}_${target1#*/}=y" >> .config
  echo "CONFIG_PACKAGE_example1=y" >> .config

  # Debug output
  echo "pkgarch: $pkgarch, target1: $target1"

  make defconfig
  make -j4 tools/install
  make -j4 toolchain/install

  # Build package
  make package/netmaker/{clean,compile}

  # Free space (optional)
  rm -rf build_dir/target-*
  rm -rf build_dir/toolchain-*
done

Thanks

netmaker-openwrt's People

Contributors

sbilly avatar xcf13363175 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netmaker-openwrt's Issues

Build netmaker_0.9.4-1_mipsel_24kc.ipk too big

Hello,

I built netmaker_0.9.4-1_mipsel_24kc.ipk for my router (target platform ramips/mt7621).
However, the file size ~8MB, and this is by far too big.

Any suggestions how to reduze package size of netmaker?

I assume this package is for the server, however I only need client software.

Compiling an update 0.14.5 for openwrt

I could use a small hand on compiling netmaker on openwrt. I'm trying to update the package to 0.14.5 as the API has changed and is no longer backwards compatible.
I can build openwrt normally but not when including netmaker.
My openwrt build fails trying to include from glfw libraries and X11.h (!)

My build machine is ubuntu 20.04 focal. I have golang-go compiler installed.

Here's the log from the build process:

$make -j1 V=sc package/netmaker/compile 
make[2]: Entering directory '/home/void/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/void/openwrt/scripts/config'
time: target/linux/prereq#0.07#0.01#0.09
make[1]: Entering directory '/home/void/openwrt'
cd "/home/void/openwrt"; git log --format=%h -1 toolchain > /home/void/openwrt/tmp/.ver_check
cmp -s /home/void/openwrt/tmp/.ver_check /home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/stamp/.ver_check || { \
        rm -rf /home/void/openwrt/build_dir/target-x86_64_musl /home/void/openwrt/staging_dir/target-x86_64_musl /home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl /home/void/openwrt/build_dir/toolchain-x86_64_gcc-11.2.0_musl; \
        mkdir -p /home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/stamp; \
        mv /home/void/openwrt/tmp/.ver_check /home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/stamp/.ver_check; \
}
make[2]: Entering directory '/home/void/openwrt/feeds/packages/lang/golang/golang'
find /home/void/openwrt/build_dir/hostpkg/go-1.18.3 -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | xargs -r rm -rf
make[2]: Leaving directory '/home/void/openwrt/feeds/packages/lang/golang/golang'
time: package/feeds/packages/golang/host-compile#0.23#0.01#0.23
make[2]: Entering directory '/home/void/openwrt/package/libs/toolchain'
Makefile:735: WARNING: skipping libgomp -- package has no install section
echo "libc" >> /home/void/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "libgcc" >> /home/void/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "libpthread" >> /home/void/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
echo "librt" >> /home/void/openwrt/staging_dir/target-x86_64_musl/pkginfo/toolchain.default.install
touch -r /home/void/openwrt/build_dir/target-x86_64_musl/toolchain/.built /home/void/openwrt/build_dir/target-x86_64_musl/toolchain/.autoremove 2>/dev/null >/dev/null
find /home/void/openwrt/build_dir/target-x86_64_musl/toolchain -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' -and -not -name '.pkgdir' | xargs -r rm -rf
make[2]: Leaving directory '/home/void/openwrt/package/libs/toolchain'
time: package/libs/toolchain/compile#0.09#0.01#0.11
make[2]: Entering directory '/home/void/openwrt/feeds/netmaker/netmaker'
mkdir -p /home/void/openwrt/dl
SHELL= flock /home/void/openwrt/tmp/.netmaker-0.14.5.tar.xz.flock -c '          /home/void/openwrt/scripts/download.pl "/home/void/openwrt/dl" "netmaker-0.14.5.tar.xz" "skip" "" || (  /home/void/openwrt/scripts/dl_github_archive.py --dl-dir="/home/void/openwrt/dl" --url="https://github.com/gravitl/netmaker.git" --version="8182673992dd609fb4e35b2ed0c261aa3319392b" --subdir="netmaker-0.14.5" --source="netmaker-0.14.5.tar.xz" --hash="skip" || (     echo "Checking out files from the git repository..."; mkdir -p /home/void/openwrt/tmp/dl && cd /home/void/openwrt/tmp/dl && rm -rf netmaker-0.14.5 && [ \! -d netmaker-0.14.5 ] && git clone  https://github.com/gravitl/netmaker.git netmaker-0.14.5 && (cd netmaker-0.14.5 && git checkout 8182673992dd609fb4e35b2ed0c261aa3319392b && git submodule update --init --recursive) && echo "Packing checkout..." && export TAR_TIMESTAMP=`cd netmaker-0.14.5 && git log -1 --format='\''@%ct'\''` && rm -rf netmaker-0.14.5/.git &&  tar --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name ${TAR_TIMESTAMP:+--mtime="$TAR_TIMESTAMP"} -c netmaker-0.14.5 |  xz -zc -7e > /home/void/openwrt/tmp/dl/netmaker-0.14.5.tar.xz && mv /home/void/openwrt/tmp/dl/netmaker-0.14.5.tar.xz /home/void/openwrt/dl/ && rm -rf netmaker-0.14.5; );  )    '
rm -f /home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.built
touch /home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.built_check
CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE="" GO_BUILD_CACHE_DIR="/home/void/openwrt/tmp/go-build" GO_MOD_CACHE_DIR="/home/void/openwrt/dl/go-mod-cache" GO_MOD_ARGS="-modcacherw" GO_PKG="github.com/gravitl/netmaker" GO_INSTALL_EXTRA="extra/file extra/dir" GO_INSTALL_ALL="" GO_SOURCE_ONLY="" GO_BUILD_PKG="github.com/gravitl/netmaker/..." GO_EXCLUDES="excluded" GO_GO_GENERATE="" GO_INSTALL_BIN_PATH="/usr/bin" BUILD_DIR="/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5" GO_BUILD_DIR="/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.go_work/build" GO_BUILD_BIN_DIR="/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.go_work/build/bin" GO_BUILD_DEPENDS_PATH="/usr/share/gocode" GO_BUILD_DEPENDS_SRC="/home/void/openwrt/staging_dir/target-x86_64_musl/usr/share/gocode/src" GOOS="linux" GOARCH="amd64" GO386="" GOAMD64="v1" GOARM="" GOMIPS="" GOMIPS64="" GOPPC64="" CGO_ENABLED=1 CC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" CGO_CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -ffile-prefix-map=/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5=netmaker-0.14.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" CGO_CPPFLAGS="-I/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/include -I/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include/fortify -I/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/include" CGO_CXXFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -ffile-prefix-map=/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5=netmaker-0.14.5 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" CGO_LDFLAGS="-L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/lib -L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/lib -znow -zrelro" GOPATH="/home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.go_work/build" GOCACHE="/home/void/openwrt/tmp/go-build" GOMODCACHE="/home/void/openwrt/dl/go-mod-cache" GOENV=off /usr/bin/env bash /home/void/openwrt/feeds/packages/lang/golang//golang-build.sh build -v -buildvcs=false -trimpath -ldflags "all=-buildid '1657134579' -linkmode external -extldflags '-L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/lib -L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/lib -Wl,-z,now -Wl,-z,relro'"        -ldflags "-s -w  -buildid '1657134579' -linkmode external -extldflags '-L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/usr/lib -L/home/void/openwrt/staging_dir/toolchain-x86_64_gcc-11.2.0_musl/lib -Wl,-z,now -Wl,-z,relro'"
Finding targets

Building targets
github.com/go-gl/glfw/v3.3/glfw
github.com/go-gl/gl/v3.2-core/gl
# /home/void/openwrt/staging_dir/host/bin/pkg-config --cflags  -- gl gl
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gl', required by 'virtual:world', not found
Package 'gl', required by 'virtual:world', not found
/home/void/openwrt/staging_dir/host/bin/pkg-config: exit status 1
# github.com/go-gl/glfw/v3.3/glfw
In file included from ./glfw/src/internal.h:188,
                 from ./glfw/src/context.c:30,
                 from ../../../../../dl/go-mod-cache/github.com/go-gl/glfw/v3.3/[email protected]/c_glfw.go:4:
./glfw/src/x11_platform.h:33:10: fatal error: X11/Xlib.h: No such file or directory
   33 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.

make[2]: *** [Makefile:93: /home/void/openwrt/build_dir/target-x86_64_musl/netmaker-0.14.5/.built] Error 2
make[2]: Leaving directory '/home/void/openwrt/feeds/netmaker/netmaker'
time: package/feeds/netmaker/netmaker/compile#2.51#1.09#0.90
    ERROR: package/feeds/netmaker/netmaker failed to build.
make[1]: *** [package/Makefile:116: package/feeds/netmaker/netmaker/compile] Error 1
make[1]: Leaving directory '/home/void/openwrt'
make: *** [/home/void/openwrt/include/toplevel.mk:230: package/netmaker/compile] Error 2

What am I doing wrong?

Install error and join jie'dian

2021/12/02 06:39:14 [netclient] node created on remote server...updating configs
2021/12/02 06:39:14 [netclient] retrieving peers
2021/12/02 06:39:14 [netclient] starting wireguard
2021/12/02 06:39:14 error running command: /usr/bin/ip link add dev nm-SA0 type wireguard
2021/12/02 06:39:14 RTNETLINK answers: Not supported
2021/12/02 06:39:14 error running command: /usr/bin/ip address add dev nm-SA0 10.20.30.3/24
2021/12/02 06:39:14 Cannot find device "nm-SA0"
Device does not exist:
file does not exist
Device does not exist:
file does not exist
2021/12/02 06:39:14 [netclient] attempted to remove interface before editing
2021/12/02 06:39:14 [netclient] error installing: exit status 1
2021/12/02 06:39:15 [netclient] removed machine from SA0 network on remote server
2021/12/02 06:39:15 [netclient] removed SA0 network locally
2021/12/02 06:39:15 [netclient] removed systemd remnants if any existed
2021/12/02 06:39:15 [netclient] removed systemd remnants if any existed

Can't running on openwrt #error "wg-quick": executable file not found

firmware
--OpenWrt R22.3.13

netmaker client
--netmaker_0.9.4-1_x86_64-openwrt-21.02.ipk

netmaker server
--0.9.4

exec log is below:
root@openwrt:~# netclient join -t eyJjb3JlZG5zYWRkciI6IjQyLjE5NC4xMzEuODciLCJhcGljb25uIjoiIiwiYXBpaG9zdCI6IjQyLjE5NC4xMzEuODciLCJhcGlwb3J0IjoiODA4MSIsImdycGNjb25uIjoiIiwiZ3JwY2hvc3QiOiI0Mi4xOTQuMTMxLjg3IiwiZ3JwY3BvcnQiOiI1MDA1MSIsImdycGNzc2wiOiJvZmYiLCJjaGVja2luaW50ZXJ2YWwiOiIxNSIsIm5ldHdvcmsiOiJqeXd4LXRlc3QiLCJrZXkiOiJtcTh6UzdxOVFET2FDbTQ3IiwibG9jYWxyYW5nZSI6IjE3Mi4xNi4wLjAvMTYiLCJncnBjd2ciOiIiLCJncnBjd2dhZGRyIjoiIiw************************
2022/03/25 04:10:42 local vpn, getting local address from range: 172.16.0.0/16
2022/03/25 04:10:42 [netclient] joining jywx-test at 42.194.xx.xx:50051
2022/03/25 04:10:42 [netclient] node created on remote server...updating configs
2022/03/25 04:10:42 [netclient] retrieving peers
2022/03/25 04:10:42 [netclient] starting wireguard
2022/03/25 04:10:42 [netclient] writing wg conf file to: /etc/netclient/config/nm-jywx-test.conf
2022/03/25 04:10:42 [netclient] failed to create wireguard interface
2022/03/25 04:10:42 [netclient] error installing: exec: "wg-quick": executable file not found in $PATH
2022/03/25 04:10:42 [netclient] removed machine from jywx-test network on remote server
2022/03/25 04:10:42 [netclient] error running command: wg-quick down /etc/netclient/config/nm-jywx-test.conf
2022/03/25 04:10:42 [netclient]
2022/03/25 04:10:42 [netclient] unable to wipe local config
2022/03/25 04:10:42 [netclient] removed systemd remnants if any existed
2022/03/25 04:10:42 [netclient] removed systemd remnants if any existed

opkg installed list
root@openwrt:~# opkg list-installed | grep wireguard
kmod-wireguard - 5.15.29-1
luci-app-wireguard - git-22.068.45502-a50e601-1
luci-i18n-wireguard-zh-cn - git-22.068.45502-a50e601-1
luci-proto-wireguard - git-22.068.45502-a50e601-1
wireguard-tools - 1.0.20210914-2

anyone happen to this issue? help

2022/09/30 06:48:22 no server address provided

efine Package/netmaker/install
$(INSTALL_DIR) $(1)/etc/netclient/
$(INSTALL_DIR) $(1)/etc/netclient/config
$(INSTALL_DIR) $(1)/etc/systemd/
$(INSTALL_DIR) $(1)/etc/systemd/system
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/netmaker $(1)/usr/bin/
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/netclient $(1)/usr/bin/
$(CP) ./root/* $(1)/
$(LN) netclient $(1)/etc/netclient/netclient
endef

I can't run it on openwrt right now.
Please tell me is there any way to make openwrt run automatically as a service.
For example, a configuration file like frpc can be defined in /etc/config/frpc.
It starts automatically every time you turn it on.

root@antrouter:# netclient join -t eyJhcGljb25uc3RyaW5nIjoiYXBpLnNkd2FuLjU1ODYwLmNvbTo0NDMiLCJuZXR3b3JrIjoibXluZXQiLCJrZXkiOiI4MDhkYmMyMGUzZjE1NjMx
IiwibG9jYWxyYW5nZSI6IiJ9
2022/09/30 06:48:22 no server address provided
root@antrouter:
#
My router has installed netclient/ correctly
The path is /etc/init.d/netclient
I have created netmaker correctly
create network, KEY
At the same time my windows and linux are running and joining the network.
What I want to achieve is that two PCs under openwrt can communicate with each other.
For example openwrt A 192.168.100.x
For example Openwrt B 192.168.101.x
PCs connected below them are able to access each other via netmaker.
???

openwrt 21.02.1

#/etc/init.d/netclient start
#/etc/rc.common: line 22: bash: not found
#start

installation using ipk does not install /etc/init.d/netclient

Specifically "opkg install netmaker-dev_0.9.0-1_all-openwrt-19.07.ipk" finishes silently, without indicating success or failure. No /etc/init.d/netclient as expected. There is, however, /usr/share/gocode/src/github.com/gravitl/netmaker/netclient on the file system.

Installation on OpenWrt 21.02 is incomplete

Hello,
I'm running OpenWrt 21.02 on this device.
This router is MMIPS architecture with MT7621A CPU.

I downloaded pre-compiled package netmaker-dev_0.9.4-1_all-openwrt-21.02.ipk assuming this would be correct for my architecture.

Installation with command

root@eddie:~# opkg install netmaker-dev_0.9.4-1_all-openwrt-21.02.ipk 
Installing netmaker-dev (0.9.4-1) to root...
Configuring netmaker-dev.

finished w/o errors.

However, there's no file in /etc/init.d to start the service:

root@eddie:~# ls /etc/init.d/
boot              cron              firewall          luci_statistics   set-irq-affinity  sysctl            ucitrack          urngd
bootcount         dnsmasq           gpio_switch       network           sqm               sysfixtime        uhttpd            wpad
chronyd           done              led               odhcpd            stubby            sysntpd           umount
collectd          dropbear          log               rpcd              sudo              system            urandom_seed

Therefore I conclude that the installation is incomplete.
Please advise how to fix this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.