Package: wg-meshconf
wg-meshconfwg-meshconf is a tool that will help you to generate peer configuration files for WireGuard mesh networks. You can easily and quickly create WireGuard mesh networks using this tool.Installation (PyPI)This is the recommended way to install wg-meshconf for regular users.This installation method installs the newest release version of wg-meshconf and all of the required dependencies from PyPI.# installing the program with pip# note that Pip for Python3 might be named "pip3" on some systemspipinstall--user-Uwg-meshconf# running the programwg-meshconfshowpeersYou may now run the program by executing thewg-meshconfcommand.Installation (GitHub)Alternatively, if you would like to install the program directly from source code, you can follow the steps below. If you would like to install directly from the Git repository:# install the HEAD (latest) commitpipinstall'wg-meshconf@git+https://github.com/k4yt3x/wg-meshconf.git'# install from a specific tag or commitpipinstall'wg-meshconf@git+https://github.com/k4yt3x/wg-meshconf.git@2.5.1'pipinstall'wg-meshconf@git+https://github.com/k4yt3x/wg-meshconf.git@aa16407'You can also clone it and install it locally.# cloning the repository with gitgitclonehttps://github.com/k4yt3x/wg-meshconf.git# enter the directorycdwg-meshconf# install the program with Pip# Pip and PDM will take care of dependency installationpipinstall-U.Learn by an ExampleUsages are dull and boring. Let's see a real-life example of how this tool can be used. This section will demonstrate how to create a simple mesh network with four nodes using wg-meshconf.For this example, suppose you have four servers as shown below. These servers can reach each other via theEndpointaddress. For instance, servertokyo1can ping servershanghai1with the addressshanghai1.com.Step 1: Add Basic Peer InformationYou will first need to add the peers' information into the database. There are two ways to do it: via Excel and via the command line interface.Method A: With Excelwg-meshconf has changed its database format from JSON to CSV and added theinitcommand since version 2.4.0. This means that it is now possible for users to directly edit the database file with Excel or other CSV-compatible editors to create/read/update/delete peer information.(P.S. I thought about making a fancy GUI for wg-meshconf like the other tools, but then I thought, why do it the complex way when you can simply "borrow" Excel's GUI?)Run the following command to initialize a new database file. By default, the database file is nameddatabase.csv. You can also specify the file's name via-d.wg-meshconfinitOpen the database CSV file with an editor like Excel or LibreOffice Calc. You should see the following column headers.You can then fill in the peers' information.You will need to fill in at least the peers'Name,Address, andEndpointvalues.These values cannot be automatically generated.Once you're done, save the file and execute theinitcommand again to automatically generate the rest of the needed information such as peer private keys.wg-meshconfinitIf you check the file again, you'll see the necessary fields getting automatically filed in.Method B: With TerminalIf, for some reason, you don't want to edit the database file directly, you can also use this tool purely through its command line interface.First we need to add all peers in the mesh network into the database. The basic syntax for adding new peers is:wg-meshconfaddpeerNAME--addressIP_ADDRESS--addressIP_ADDRESS_2--endpointENDPOINTNew private key will be generated automatically if unspecifiedListenPort defaults to 51820 per WireGuard standardAll other values are left empty by defaultThere are more options which you can specify. Use the commandwg-meshconf addpeer -hfor more details.After adding all the peers into the database, you can verify that they have all been added correctly via thewg-meshconf showpeerscommand. Thesimplifyswitch here omits all columns with onlyNones.Step 2: Export Configuration FilesUse thegenconfigcommand to generate configuration files for all peers. You may also export configurations for only one peer by specifying the peer's name.The configuration files will be named after the peers' names. By default, all configuration files are exported into a subdirectory namedoutput. You can change this by specifying output directory using the-oor the--outputoption.Step 3: Copy Configuration Files to PeersCopy each of the configuration files to the corresponding peers.Step 4: Start WireGuard ServicesStart up the WireGuard interfaces using thewg-quickcommand. It is also possible to control WireGuard interfaces via WireGuard'swg-quick@systemd service. WireGuard status can be verified via thewgcommand after WireGuard interfaces are set up.Step 5: Verify ConnectivityVerify that all endpoints have been configured properly and can connect to each other.Done. Now a mesh network has been created between the four servers.Updating Peer InformationIf you would like to update a peer's information, use theupdatepeercommand. The syntax ofupdatepeeris the same as that of theaddpeercommand. Instead of adding a new peer, this command overwrites values in existing entries.In the example below, suppose you would like to updatetokyo1's endpoint address and change it totokyo321.com. Use theupdatepeercommand and specify the new endpoint to betokyo321.com. This will overwritetokyo1's existingEndpointvalue.Show Peer InformationTheshowpeerscommand prints all peers' information by default.Now that's a lot of info and a lot of unnecessary columns which only haveNones. Therefore, I added the-s/--simplifycommand which omits those useless columns.You may also query information about a specific peer.Plaintext mode has a similar usage. It's just a bit harder to read, at least for me.Deleting PeersUse thedelpeercommand to delete peers. The syntax isdelpeer PEER_NAME.This example below shows how to delete the peertokyo1from the database.Database FilesUnlike 1.x.x versions of wg-meshconf, version 2.0.0 does not require the user to save or load profiles. Instead, all add peer, update peer and delete peer operations are file operations. The changes will be saved to the database file immediately. The database file to use can be specified via the-dor the--databaseoption. If no database file is specified,database.csvwill be used.Database files are essentially just CSV files (it was JSON before version 2.4.0). Below is an example."Name","Address","Endpoint","AllowedIPs","ListenPort","PersistentKeepalive","FwMark","PrivateKey","DNS","MTU","Table","PreUp","PostUp","PreDown","PostDown","SaveConfig"
"tokyo1","10.1.0.1/16","tokyo1.com","","51820","","","yJndNh80ToNWGOfDlbtho1wHAEZGa7ZhNpsHf7AJVUM=","","","","","","","",""
"germany1","10.2.0.1/16","germany1.com","","51820","","","SEOaOjTrhR4do1iUrTTRRHZs6xCA3Q/H0yHW3ZpkHko=","","","","","","","",""
"canada1","10.3.0.1/16","canada1.com","","51820","","","2D34jpbTsU+KeBqfItTEbL5m7nYcBomWWJGTYCT6eko=","","","","","","","",""
"shanghai1","10.4.0.1/16","shanghai1.com","","51820","","","CGyR7goj/uGH3TQHgVknpb9ZBR+/yMfkve+kVNGBYlg=","","","","","","","",""Detailed UsagesYou may refer to the program's help page for usages. Use the-hswitch or the--helpswitch to print the help page.$wg-meshconf-h
usage:wg-meshconf[-h][-dDATABASE]{addpeer,updatepeer,delpeer,showpeers,genconfig}...

positionalarguments:{addpeer,updatepeer,delpeer,showpeers,genconfig}optionalarguments:-h,--helpshowthishelpmessageandexit-dDATABASE,--databaseDATABASEpathwherethedatabasefileisstored(default:database.json)Specify-hor--helpafter a command to see this command's usages.$wg-meshconfaddpeer-h
usage:wg-meshconfaddpeer[-h]--addressADDRESS[--endpointENDPOINT][--privatekeyPRIVATEKEY][--listenportLISTENPORT][--fwmarkFWMARK][--dnsDNS][--mtuMTU][--tableTABLE][--preupPREUP][--postupPOSTUP][--predownPREDOWN][--postdownPOSTDOWN][--saveconfig]name

positionalarguments:nameNameusedtoidentifythisnode

optionalarguments:-h,--helpshowthishelpmessageandexit--addressADDRESSaddressoftheserver--endpointENDPOINTpeer'spublicendpointaddress--privatekeyPRIVATEKEYprivatekeyofserverinterface--listenportLISTENPORTporttolistenon--fwmarkFWMARKfwmarkforoutgoingpackets--dnsDNSserverinterfaceDNSservers--mtuMTUserverinterfaceMTU--tableTABLEserverroutingtable--preupPREUPcommandtorunbeforeinterfaceisup--postupPOSTUPcommandtorunafterinterfaceisup--predownPREDOWNcommandtorunbeforeinterfaceisdown--postdownPOSTDOWNcommandtorunafterinterfaceisdown--saveconfigsaveserverinterfacetoconfiguponshutdownLicenseThis project is licensed under theGNU General Public License Version 3 (GNU GPL v3)Copyright (c) 2018-2023 K4YT3X and contributors.This project includes or dependson the following software and projects:ProjectLicenseRichMIT LicenseWireGuardMIT LicensecryptographyBSD LicenseRelated Project:wg-dynamicwg-dynamicis a tool designed officially by the WireGuard developing team. This new utility will provide a convenient way of configuring networks dynamically, where mesh network being one of the them. If you're interested, check it out atwg-dynamic@githuborwg-dynamic@official repository. You might also want to read this project'sidea page.This section used to be on the top of the page, but has been moved since there has been no new commits observed in this project since 2019.