├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── PULL_REQUEST_TEMPLATE.md ├── semantic.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .goreleaser.yml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── Vagrantfile ├── backend ├── backend.go ├── consul.go ├── discover.go ├── etcd.go ├── http.go └── plumber.go ├── cmd └── wirey │ ├── main.go │ ├── root.go │ └── version.go ├── examples └── httpbackend │ ├── .gitignore │ └── main.go ├── go.mod ├── go.sum └── pkg ├── utils └── utils.go └── wireguard ├── README.md ├── conf_template.go ├── wireguard.go └── wireguard_test.go /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 17 | 18 | __Steps to reproduce:__ 19 | List the minimal actions needed to reproduce the behavior. 20 | 21 | 1. ... 22 | 2. ... 23 | 3. ... 24 | 25 | __Expected behavior:__ 26 | Describe what you expected to happen. 27 | 28 | __Actual behavior:__ 29 | Describe What actually happened. 30 | 31 | __Environment info:__ 32 | 33 | * System info: Run `uname -srm` and copy the output here 34 | * Wirey version: Run `wirey version` and copy the output here 35 | * Other relevant environment details: Container runtime, disk info, etc 36 | 37 | __Config:__ 38 | Copy any non-default config values here or attach the full config as a gist or file. 39 | 40 | 41 | 42 | __Logs:__ 43 | Include snippet of errors in log. 44 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Closes # 2 | 3 | Describe your proposed changes here. 4 | 5 | 6 | 7 | - [ ] [Well-formatted commit messages](https://www.conventionalcommits.org/en/v1.0.0-beta.3/) 8 | - [ ] Rebased/mergeable 9 | - [ ] Tests pass 10 | - [ ] Documentation updated or issue created (provide link to issue/pr) 11 | - [ ] Signed [CLA](https://influxdata.com/community/cla/) (if not already signed) -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | # docs: https://github.com/probot/semantic-pull-requests#configuration 2 | # Always validate the PR title AND all the commits 3 | titleAndCommits: true 4 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - '*' 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Install Go 16 | uses: actions/setup-go@v2 17 | with: 18 | go-version: 1.17 19 | - name: Checkout code 20 | uses: actions/checkout@v2 21 | - name: Restore cache 22 | uses: actions/cache@v2 23 | with: 24 | path: ~/go/pkg/mod 25 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 26 | restore-keys: | 27 | ${{ runner.os }}-go- 28 | - name: Format 29 | run: if [ "$(go fmt ./... && git status --porcelain --untracked-files=no | wc -l)" -gt 0 ]; then exit 1; fi 30 | - name: Test 31 | run: make test 32 | - name: Build 33 | run: make build 34 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | goreleaser: 12 | if: startsWith(github.ref, 'refs/tags/') 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v2 17 | with: 18 | fetch-depth: 0 19 | - name: Set up Go 20 | uses: actions/setup-go@v2 21 | with: 22 | go-version: 1.17 23 | - name: Run GoReleaser 24 | uses: goreleaser/goreleaser-action@v2 25 | with: 26 | distribution: goreleaser 27 | version: latest 28 | args: release --rm-dist 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | vendor/ 3 | bin/ 4 | 5 | # Common config files 6 | wirey.json 7 | wirey.yaml 8 | 9 | # VSCode settings 10 | .vscode 11 | .idea/ 12 | 13 | dist/ 14 | 15 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | before: 2 | hooks: 3 | - go mod tidy 4 | builds: 5 | - env: 6 | - CGO_ENABLED=0 7 | goos: 8 | - linux 9 | goarch: 10 | - amd64 11 | - arm64 12 | - arm 13 | goarm: 14 | - 6 15 | - 7 16 | main: ./cmd/wirey 17 | ldflags: 18 | - -s -X main.Version={{.Version}} 19 | archives: 20 | - replacements: 21 | linux: Linux 22 | amd64: x86_64 23 | checksum: 24 | name_template: 'checksums.txt' 25 | snapshot: 26 | name_template: "{{ incpatch .Version }}-next" 27 | release: 28 | github: 29 | owner: influxdata 30 | name: wirey 31 | prerelease: auto 32 | changelog: 33 | sort: asc 34 | filters: 35 | exclude: 36 | - '^docs:' 37 | - '^test:' 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.12.9-alpine3.10 as build 2 | 3 | # Set the Current Working Directory inside the container 4 | WORKDIR /app 5 | 6 | # Install dependencies 7 | RUN apk update && apk upgrade && apk add --no-cache \ 8 | bash \ 9 | git \ 10 | bzr 11 | 12 | # Copy go mod and sum files 13 | COPY go.mod go.sum ./ 14 | 15 | # Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed 16 | RUN go mod download 17 | 18 | # Copy the source from the current directory to the Working Directory inside the container 19 | COPY . . 20 | 21 | # Build the Go app 22 | ENV GOOS linux 23 | ENV GARCH amd64 24 | ENV CGO_ENABLED 0 25 | 26 | RUN go build -ldflags="-s -w" -o wirey cmd/wirey/main.go 27 | 28 | # Release container 29 | FROM alpine:3.10 30 | 31 | WORKDIR /app 32 | 33 | COPY --from=build /app/wirey /app/wirey 34 | 35 | # Command to run the executable 36 | ENTRYPOINT ["/app/wirey"] 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | COMMIT_NO := $(shell git rev-parse --short=7 HEAD 2> /dev/null || true) 3 | GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}") 4 | LDFLAGS=-ldflags "-s -X main.Version=${GIT_COMMIT}" 5 | 6 | .PHONY: help 7 | help: ## This is the help target 8 | @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) 9 | 10 | all: build ## Build wirey for local development 11 | 12 | .PHONY: clean 13 | clean: ## Cleanup build directories 14 | $(RM) -r bin/ 15 | $(RM) -r dist/ 16 | 17 | .PHONY: build 18 | build: ## Build wirey for local development 19 | mkdir -p bin 20 | go build ${LDFLAGS} -o bin/wirey ./cmd/wirey 21 | 22 | .PHONY: vendor 23 | vendor: ## Execute go mod vendor 24 | go mod vendor 25 | 26 | .PHONY: test 27 | test: vendor ## Execute go test 28 | go test -v ./... 29 | 30 | .PHONY: fmt 31 | fmt: ## Execute go fmt 32 | go fmt ./... 33 | 34 | .PHONY: tidy 35 | tidy: ## Execute go mod tidy 36 | go mod tidy 37 | 38 | 39 | gorelease: ## Execute goreleaser with snapshot flag 40 | goreleaser release --snapshot --rm-dist 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wirey 2 | 3 | Tool to manage local [wireguard](https://www.wireguard.com/) interfaces in a distributed system. 4 | 5 | By using a remote distributed backend, wirey can synchronize wireguard peers among a cluster of machines 6 | in order to let them share the same tunnel without having to manually configure them by hand. 7 | 8 | Each machine should be able to see the same distributed backend in order to join the pool. 9 | 10 | ## Implemented backends 11 | 12 | - etcd 13 | - consul 14 | - http(s) - with optional basic auth 15 | 16 | ### ETCD 17 | 18 | The etcd backend is useful when you want to use etcd to synchronize wireguard peers. 19 | 20 | Example usage: 21 | 22 | - endpoint: the listen ip address on the current machine 23 | - ipaddr: the ip address you want to assign to the interface 24 | - etcd comma seprated list of etcd servers 25 | 26 | ```bash 27 | ./bin/wirey --endpoint 192.168.33.11 --ipaddr 172.30.0.4 --etcd 192.168.33.10:2379 28 | ``` 29 | 30 | ### CONSUL 31 | 32 | The consul backend is useful when you want to use consul to synchronize wireguard peers. 33 | 34 | Example usage: 35 | 36 | - endpoint: the listen ip address on the current machine 37 | - ipaddr: the ip address you want to assign to the interface 38 | - consul ip from the consul server 39 | - consul-port is the port from consul server 40 | - consul-address overrides consul ip and port 41 | - consul-token is the token used for consul authentication 42 | 43 | ```bash 44 | ./bin/wirey --endpoint 192.168.33.11 --ipaddr 172.30.0.4 --consul 192.168.33.10 45 | ``` 46 | 47 | ### HTTP(s) with optional basic auth 48 | 49 | The http backend is useful when you want to write your own implementation. 50 | 51 | The only suppported auth mechanism for now is Basic Authentication. 52 | 53 | Example usage: 54 | 55 | - endpoint: the listen ip address on the current machine 56 | - ipaddr: the ip address you want to assign to the interface 57 | - http: the http endpoint where to reach the server without trailing slash (/) 58 | - httpbasicauth: username and password to use if the server implements basic auth, in the form `username:password` 59 | 60 | ```bash 61 | ./bin/wirey --endpoint 192.168.33.12 --ipaddr 10.30.0.80 --http http://192.168.33.10:8080 --httpbasicauth "time:series" 62 | ``` 63 | 64 | Example usage using env variables: 65 | 66 | ```bash 67 | export WIREY_ENDPOINT="192.168.33.12" 68 | export WIREY_IPADDR="10.30.0.80" 69 | export WIREY_HTTP="http://192.168.33.10:8080" 70 | export WIREY_HTTPBASICAUTH="time:series" 71 | ./bin/wirey 72 | ``` 73 | 74 | #### HTTP Server endpoints 75 | You can find an example of http server in [examples/httpbackend](examples/httpbackend) 76 | 77 | Starting from the endpoint you provide you provide to wirey, the expected routes are: 78 | 79 | #### POST `/{ifname}/{publickeysha}` 80 | 81 | **URL parameters:** 82 | 83 | - ifname: interface name, wirey defaults to `wg0` 84 | - publickeysha: the sha256 of the public key, this is just used as a key and as of now it's not matched with anything in `wirey` since the real public key is embedded in the body. 85 | 86 | **URL Example:** 87 | 88 | ``` 89 | https://myservice.com/wireguard-discovery/wg0/234sfkske03kdssk32 90 | ``` 91 | 92 | **Request Body example:** 93 | 94 | ```json 95 | { 96 | "Endpoint": "192.168.33.11:2345", 97 | "IP": "10.30.0.10", 98 | "PublicKey": "T053azhMRW1sV2tQbjVISUgycnZtQWt5bDdKN3hJL3IwMjhDWG1zNVRpbz0K" 99 | } 100 | ``` 101 | 102 | **Expected status codes:** 103 | 104 | - 201 Created 105 | - 401 Unauthorized (for basic auth) 106 | 107 | #### GET `/{ifname}` 108 | 109 | **URL Example:** 110 | 111 | ``` 112 | https://myservice.com/wireguard-discovery/wg0 113 | ``` 114 | 115 | **URL parameters:** 116 | 117 | - ifname: interface name, wirey defaults to `wg0` 118 | 119 | **Description:** 120 | 121 | Returns all the peers for the provided interface. 122 | 123 | 124 | **Expected status codes:** 125 | 126 | - 200 OK 127 | - 401 Unauthorized (for basic auth) 128 | 129 | **Response body example:** 130 | 131 | ```json 132 | [ 133 | { 134 | "Endpoint": "192.168.33.11:2345", 135 | "IP": "10.30.0.10", 136 | "PublicKey": "T053azhMRW1sV2tQbjVISUgycnZtQWt5bDdKN3hJL3IwMjhDWG1zNVRpbz0K" 137 | }, 138 | { 139 | "Endpoint": "192.168.33.12:2345", 140 | "IP": "10.30.0.80", 141 | "PublicKey": "ZlE5a005ZDV1enpGei8xc25STXpnb3U4MVJkYVFmTXczL0NRR2svdEFpRT0K" 142 | }, 143 | { 144 | "Endpoint": "192.168.33.13:2345", 145 | "IP": "10.30.0.60", 146 | "PublicKey": "WUp2cDFPb0FhTkU5UC9vdlQrb0tIK29XRGtxVDhQenlzZnR1R1p4eEF5OD0K" 147 | } 148 | ] 149 | ``` 150 | 151 | 152 | ## Local Development 153 | 154 | Due to the nature of this project (networking on the root namespace) the easiest way to test if wirey works is by using Vagrant. 155 | 156 | A brave person could transpile that to a set of rootless runc containers, or even a set of docker containers with the network namespace transposed from root to the container itself. 157 | 158 | BTW, to use vagrant: 159 | 160 | The machines available are: 161 | 162 | - discovery-server 163 | - net-1 164 | - net-2 165 | - net-3 166 | 167 | 1. Start the vagrant machines and the sync 168 | 169 | ```bash 170 | vagrant up 171 | vagrant rsync-auto 172 | ``` 173 | 174 | 2. Compile wirey and execute it on both the machines 175 | 176 | ```bash 177 | make 178 | ``` 179 | 180 | ### on net-1 181 | 182 | ```bash 183 | vagrant ssh net-1 184 | sudo su - 185 | cd /vagrant 186 | ./bin/wirey --endpoint 192.168.33.11 --ipaddr 172.30.0.4 --etcd 192.168.33.10:2379 187 | ``` 188 | 189 | ### on net-2 190 | 191 | ```bash 192 | vagrant ssh net-2 193 | sudo su - 194 | cd /vagrant 195 | ./bin/wirey --endpoint 192.168.33.12 --ipaddr 172.30.0.5 --etcd 192.168.33.10:2379 196 | ``` 197 | 198 | ### on net-3 199 | 200 | ```bash 201 | vagrant ssh net-2 202 | sudo su - 203 | cd /vagrant 204 | ./bin/wirey --endpoint 192.168.33.13 --ipaddr 172.30.0.6 --etcd 192.168.33.10:2379 205 | ``` 206 | 207 | ### Verify that the interfaces are up 208 | 209 | ```bash 210 | vagrant ssh net-1 211 | ping 172.30.0.11 212 | ``` 213 | 214 | Result: 215 | ``` 216 | PING 172.30.0.11 (172.30.0.11) 56(84) bytes of data. 217 | 64 bytes from 172.30.0.11: icmp_seq=1 ttl=64 time=0.414 ms 218 | 64 bytes from 172.30.0.11: icmp_seq=2 ttl=64 time=2.54 ms 219 | ``` 220 | 221 | ### Check the wg status in a machine 222 | 223 | ```bash 224 | vagrant ssh net-1 225 | wg show 226 | ``` 227 | 228 | Result: 229 | ``` 230 | interface: wg0 231 | public key: 12XP/T4UEfLx6REuFxZWNPrrmrox5xgSRMNExCeNEws= 232 | private key: (hidden) 233 | listening port: 2345 234 | 235 | peer: 59Je0kMsYkWkQ52Rt7o9Ss60QP3fTcoTQgJgsWDW/QQ= 236 | endpoint: 192.168.33.12:2345 237 | allowed ips: 0.0.0.0/0 238 | latest handshake: 1 minute, 55 seconds ago 239 | transfer: 820 B received, 764 B sent 240 | ``` 241 | 242 | 243 | ### Check the etcd store 244 | 245 | ```bash 246 | vagrant ssh discovery-server 247 | docker exec -e ETCDCTL_API=3 -e ETCDCTL_ENDPOINTS=http://192.168.33.10:2379 -ti etcd etcdctl get --prefix=true /wirey 248 | ``` 249 | 250 | Result: 251 | ``` 252 | /wirey/wg0/12XP/T4UEfLx6REuFxZWNPrrmrox5xgSRMNExCeNEws= 253 | 254 | {"PublicKey":"MTJYUC9UNFVFZkx4NlJFdUZ4WldOUHJybXJveDV4Z1NSTU5FeENlTkV3cz0K","Endpoint":"192.168.33.11:2345","IP":"172.30.0.4"} 255 | /wirey/wg0/59Je0kMsYkWkQ52Rt7o9Ss60QP3fTcoTQgJgsWDW/QQ= 256 | 257 | {"PublicKey":"NTlKZTBrTXNZa1drUTUyUnQ3bzlTczYwUVAzZlRjb1RRZ0pnc1dEVy9RUT0K","Endpoint":"192.168.33.12:2345","IP":"172.30.0.11"} 258 | ``` 259 | 260 | ### Sample configuration file 261 | 262 | wirey.json 263 | ``` 264 | { 265 | "endpoint": "{{ GetPrivateIP }}", 266 | "endpoint-port": "51820", 267 | "etcd": "", 268 | "etcd-port": "", 269 | "consul": "", 270 | "consul-port": "", 271 | "consul-address": "", 272 | "consul-token": "", 273 | "http": "", 274 | "http-port": "", 275 | "httpbasicauth": "", 276 | "ifname": "wg0", 277 | "ipaddr": "172.30.0.1", 278 | "discover": "", 279 | "allowedips": "" 280 | } 281 | ``` -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = "2" 5 | 6 | $discovery=<