Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
P
playbooks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
playbooks
Commits
78a9c689
Commit
78a9c689
authored
Apr 13, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vdip
parent
7f37e390
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
0 deletions
+84
-0
files/vdip/client.conf.j2
files/vdip/client.conf.j2
+12
-0
files/vdip/server.conf.j2
files/vdip/server.conf.j2
+11
-0
files/vdip/server.sh.j2
files/vdip/server.sh.j2
+17
-0
vdip.yml
vdip.yml
+44
-0
No files found.
files/vdip/client.conf.j2
0 → 100644
View file @
78a9c689
[Interface]
Address = {{clientAddress}}/32
PrivateKey = {{clientKey.priv}}
Table = 100
PostUp = /sbin/ip rule add pref 80 to 10.0.0.0/7 lookup main; /sbin/ip rule add pref 80 to 172.16.0.0/12 lookup main; /sbin/ip rule add pref 80 to 192.168.0.0/16 lookup main; /sbin/ip rule add pref 100 fwmark 100 lookup 100; /sbin/ip route replace {{address}}/32 dev %i; ipset create vdiplocal hash:net maxelem 1000000; /sbin/ipset add vdiplocal 10.0.0.0/7; /sbin/ipset add vdiplocal 172.16.0.0/12; /sbin/ipset add vdiplocal 192.168.0.0/16; /sbin/iptables -t mangle -A PREROUTING -i %i ! -d 224.0.0.0/3 -m set ! --match-set vdiplocal src -j CONNMARK --set-xmark 100; /sbin/iptables -t mangle -A PREROUTING -m connmark --mark 100 -j CONNMARK --restore-mark; /sbin/iptables -t mangle -A OUTPUT -m connmark --mark 100 -j CONNMARK --restore-mark; true
PreDown = /sbin/ip rule del pref 80 to 10.0.0.0/7 lookup main; /sbin/ip rule del pref 80 to 172.16.0.0/12 lookup main; /sbin/ip rule del pref 80 to 192.168.0.0/16 lookup main; /sbin/ip rule del pref 100 fwmark 100 lookup 100; /sbin/iptables -t mangle -D PREROUTING -i %i ! -d 224.0.0.0/3 -m set ! --match-set vdiplocal src -j CONNMARK --set-xmark 100; /sbin/iptables -t mangle -D PREROUTING -m connmark --mark 100 -j CONNMARK --restore-mark; /sbin/iptables -t mangle -D OUTPUT -m connmark --mark 100 -j CONNMARK --restore-mark; ipset destroy vdiplocal; true
[Peer]
PublicKey = {{serverKey.pub}}
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = {{ansible_ssh_host}}:{{port}}
PersistentKeepalive = 1
files/vdip/server.conf.j2
0 → 100644
View file @
78a9c689
[Interface]
Address = {{address}}/32
PrivateKey = {{serverKey.priv}}
ListenPort = {{port}}
PostUp = /etc/wireguard/server.sh up
PreDown = /etc/wireguard/server.sh down
[Peer]
PublicKey = {{clientKey.pub}}
AllowedIPs = {{clientAddress}}/32
files/vdip/server.sh.j2
0 → 100755
View file @
78a9c689
#!/bin/bash
up
()
{
iptables
-t
nat
-N
VDIP
iptables
-t
nat
-A
VDIP
-p
tcp
-m
multiport
--dports
{{
ansible_ssh_port
}}
-j
RETURN
iptables
-t
nat
-A
VDIP
-p
udp
-m
multiport
--dports
{{
port
}}
-j
RETURN
iptables
-t
nat
-A
VDIP
-j
DNAT
--to-destination
{{
clientAddress
}}
iptables
-t
nat
-A
PREROUTING
-m
addrtype
--dst-type
LOCAL
-j
VDIP
}
down
()
{
iptables
-t
nat
-D
PREROUTING
-m
addrtype
--dst-type
LOCAL
-j
VDIP
iptables
-t
nat
-F
VDIP
iptables
-t
nat
-X
VDIP
}
"
$@
"
vdip.yml
0 → 100644
View file @
78a9c689
---
-
hosts
:
vdip
remote_user
:
root
tasks
:
-
name
:
wireguard
become
:
true
apt
:
update_cache
:
true
name
:
wireguard
when
:
ansible_os_family == "Debian"
-
name
:
wg directory
become
:
true
file
:
path
:
/etc/wireguard
state
:
directory
-
name
:
server conf
become
:
true
template
:
src
:
./files/vdip/server.conf.j2
dest
:
/etc/wireguard/wgvdip.conf
notify
:
restart_wg
-
name
:
server sh
become
:
true
template
:
src
:
./files/vdip/server.sh.j2
dest
:
/etc/wireguard/server.sh
mode
:
0777
notify
:
restart_wg
-
name
:
client conf
template
:
src
:
./files/vdip/client.conf.j2
dest
:
'
{{ansible_user_dir}}/client.conf'
-
name
:
start wg
become
:
true
systemd
:
name
:
'
wg-quick@wgvdip'
state
:
started
enabled
:
true
handlers
:
-
name
:
restart_wg
become
:
true
systemd
:
name
:
'
wg-quick@wgvdip'
state
:
restarted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment