Bring up wireguard interface with wg script: Difference between revisions

From AcrodusWiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
This is the example script and associated config file for the vpn client. This was connecting to a vpn server hosted on the home network.
This is the example script and associated config file for the vpn client. This was connecting to a vpn server hosted on the home network.


<pre>
wg_acrodus_up.sh  
wg_acrodus_up.sh  


Line 16: Line 17:
ip -6 rule add not fwmark 51821 table 51821
ip -6 rule add not fwmark 51821 table 51821
ip -6 route add ::/0 dev wg0 table 51821
ip -6 route add ::/0 dev wg0 table 51821
</pre>


<pre>
wg_acrodus.conf


wg_acrodus.conf
[Interface]
[Interface]
PrivateKey = KMbtL28SVof35/RM9/aqFvbpuSH4PRpuzDGtfq9UhXQ=
PrivateKey = KMbtL28SVof35/RM9/aqFvbpuSH4PRpuzDGtfq9UhXQ=
Line 29: Line 32:
EndPoint = vpn.acrodus.uk:51821
EndPoint = vpn.acrodus.uk:51821
PersistentKeepalive = 10
PersistentKeepalive = 10
 
</pre>


A note to future Alex, wg-quick .conf files have different parameters to wg .conf files. Also remember the importance of the fwmark.
A note to future Alex, wg-quick .conf files have different parameters to wg .conf files. Also remember the importance of the fwmark.

Latest revision as of 16:03, 18 November 2024

This is the example script and associated config file for the vpn client. This was connecting to a vpn server hosted on the home network.

wg_acrodus_up.sh 

#!/bin/bash

ip l add dev wg0 type wireguard
wg setconf wg0 wg_acrodus.conf
ip a add 10.0.0.2/32 dev wg0
ip l set dev wg0 up
wg set wg0 fwmark 51821

ip -4 rule add not fwmark 51821 table 51821
ip -4 route add 0.0.0.0/0 dev wg0 table 51821

ip -6 rule add not fwmark 51821 table 51821
ip -6 route add ::/0 dev wg0 table 51821
wg_acrodus.conf 

[Interface]
PrivateKey = KMbtL28SVof35/RM9/aqFvbpuSH4PRpuzDGtfq9UhXQ=
ListenPort = 51821
fwMark = 51821

[Peer]
PublicKey = cNfZAhVdRi83k35yHOF9rFeOk9KT94vvSj1ALw8GSnE=
AllowedIPs = 0.0.0.0/0, 0::/0
EndPoint = vpn.acrodus.uk:51821
PersistentKeepalive = 10

A note to future Alex, wg-quick .conf files have different parameters to wg .conf files. Also remember the importance of the fwmark.