PostUp = resolvectl domain %i small.private
[Peer]
-PublicKey = S+6HaTnOwwhWgUGXjSBcPAvifKw+j8BDTRfq534gNW4=
EndPoint = 192.168.15.5:39608
+PublicKey = S+6HaTnOwwhWgUGXjSBcPAvifKw+j8BDTRfq534gNW4=
AllowedIPs = 10.177.87.1
AllowedIPs = 192.168.56.0/24
AllowedIPs = 192.168.57.0/24
#+BEGIN_SRC conf
[Interface]
Address = 10.84.139.2
-PrivateKey = wg set %i private-key /etc/wireguard/private-key
+PrivateKey = <hidden>
+PublicKey = LdsCsgfjKCfd5+VKS+Q/dQhWO8NRNygByDO2VxbXlSQ=
DNS = 192.168.56.1
Domain = small.private
# Gate
[Peer]
-PublicKey = y3cjFnvQbylmH4lGTujpqc8rusIElmJ4Gu9hh6iR7QI=
EndPoint = 192.168.57.1:51820
+PublicKey = y3cjFnvQbylmH4lGTujpqc8rusIElmJ4Gu9hh6iR7QI=
AllowedIPs = 10.84.139.1
AllowedIPs = 192.168.56.0/24
-AllowedIPs = 192.168.57.0/24
AllowedIPs = 10.177.87.0/24
AllowedIPs = 10.84.139.0/24
#+END_SRC
# Gate
[Peer]
+EndPoint = 192.168.57.1:51820
PublicKey = y3cjFnvQbylmH4lGTujpqc8rusIElmJ4Gu9hh6iR7QI=
AllowedIPs = 10.84.139.1
AllowedIPs = 192.168.56.0/24
-AllowedIPs = 192.168.57.0/24
AllowedIPs = 10.177.87.0/24
AllowedIPs = 10.84.139.0/24
#+END_SRC
sub write_wg_client ($$$$$$) {
my ($file, $addr, $type, $pubkey, $endpt, $server_addr) = @_;
+
my $O = new IO::File;
+ open ($O, ">$file.tmp") or die "Could not open $file.tmp: $!\n";
+
my $DNS = ($type eq "android"
? "
-DNS = $core_addr\nDomain = $domain_priv"
+DNS = $core_addr
+Domain = $domain_priv"
: "
+PostUp = wg set %i private-key /etc/wireguard/private-key
PostUp = resolvectl dns %i $core_addr
PostUp = resolvectl domain %i $domain_priv");
- open ($O, ">$file.tmp") or die "Could not open $file.tmp: $!\n";
+
+ my $WILD = ($file eq "public.conf"
+ ? "
+AllowedIPs = $wild_net_cidr"
+ : "");
+
print $O "[Interface]
-Address = $addr
-PostUp = wg set %i private-key /etc/wireguard/private-key$DNS
+Address = $addr$DNS
[Peer]
PublicKey = $pubkey
EndPoint = $endpt
AllowedIPs = $server_addr
-AllowedIPs = $private_net_cidr
-AllowedIPs = $wild_net_cidr
+AllowedIPs = $private_net_cidr$WILD
AllowedIPs = $public_wg_net_cidr
AllowedIPs = $campus_wg_net_cidr\n";
close $O or die "Could not close $file.tmp: $!\n";
sub write_wg_client ($$$$$$) {
my ($file, $addr, $type, $pubkey, $endpt, $server_addr) = @_;
+
my $O = new IO::File;
+ open ($O, ">$file.tmp") or die "Could not open $file.tmp: $!\n";
+
my $DNS = ($type eq "android"
? "
-DNS = $core_addr\nDomain = $domain_priv"
+DNS = $core_addr
+Domain = $domain_priv"
: "
+PostUp = wg set %i private-key /etc/wireguard/private-key
PostUp = resolvectl dns %i $core_addr
PostUp = resolvectl domain %i $domain_priv");
- open ($O, ">$file.tmp") or die "Could not open $file.tmp: $!\n";
+
+ my $WILD = ($file eq "public.conf"
+ ? "
+AllowedIPs = $wild_net_cidr"
+ : "");
+
print $O "[Interface]
-Address = $addr
-PostUp = wg set %i private-key /etc/wireguard/private-key$DNS
+Address = $addr$DNS
[Peer]
PublicKey = $pubkey
EndPoint = $endpt
AllowedIPs = $server_addr
-AllowedIPs = $private_net_cidr
-AllowedIPs = $wild_net_cidr
+AllowedIPs = $private_net_cidr$WILD
AllowedIPs = $public_wg_net_cidr
AllowedIPs = $campus_wg_net_cidr\n";
close $O or die "Could not close $file.tmp: $!\n";