IRCNow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vpn:openbsd [2019/11/07 07:34]
jrmu
vpn:openbsd [2020/06/14 03:57] (current)
jrmu
Line 1: Line 1:
-====== OpenBSD 6.6 on amd64 ======+ ====== OpenBSD 6.6 on amd64 ======
  
-Add this to /​etc/​iked.conf:​+Add this to /​etc/​iked.conf ​(replace 203.0.113.5 with your server'​s public IP address):
  
-     user '​username'​ '​password'​ +<​code>​ 
-     ​ikev2 '​vpn.ircnow.org'​ passive esp \ +user '​username'​ '​password'​ 
-        from 0.0.0.0/0 to 0.0.0.0/0 \ +ikev2 '​vpn.ircnow.org'​ passive esp \ 
-        local 69.85.86.144 peer any \ +    from 0.0.0.0/0 to 0.0.0.0/0 \ 
-        srcid vpn.ircnow.org \ +    local 203.0.113.peer any \ 
-        eap "​mschap-v2"​ \ +    srcid vpn.ircnow.org \ 
-        config address 10.0.5.0/24 \ +    eap "​mschap-v2"​ \ 
-        config name-server ​69.85.86.144 +    config address 10.0.5.0/24 \ 
-        tag "​ROADW"​+    config name-server ​203.0.113.
 +    tag "​ROADW"​ 
 +</​code>​ 
 + 
 +The '​from'​ rule allows any user to connect. The name-server provides the name-server that vpn clients will use. So in this example, you must have a valid caching name server running on IP 203.0.113.5. Note that these packets will get tagged as ROADW.
  
 Add this to /​etc/​pf.conf:​ Add this to /​etc/​pf.conf:​
  
 +<​code>​
 pass in inet proto udp to port {isakmp, ipsec-nat-t} tag IKED pass in inet proto udp to port {isakmp, ipsec-nat-t} tag IKED
 pass in inet proto esp tag IKED pass in inet proto esp tag IKED
Line 20: Line 25:
 match out on $ext_if inet tagged ROADW nat-to $ext_if match out on $ext_if inet tagged ROADW nat-to $ext_if
 match in quick on enc0 inet proto { tcp, udp } to port 53 rdr-to 127.0.0.1 port 53 match in quick on enc0 inet proto { tcp, udp } to port 53 rdr-to 127.0.0.1 port 53
 +</​code>​
  
-(Note that in pf.conf, we had defined this earlier) +where ext_if ​is your external interface.
- +
-ext_if ​= "​em0"​+
  
 To reload the new pf ruleset: To reload the new pf ruleset:
  
 +<​code>​
 $ doas pfctl -f /​etc/​pf.conf ​ $ doas pfctl -f /​etc/​pf.conf ​
 +</​code>​
  
 +At this point, we need to create PKI and X.509 certificates that the vpn client can use to verify the server. From the command line, run:
 +
 +<​code>​
 # ikectl ca vpn create # ikectl ca vpn create
 # ikectl ca vpn install # ikectl ca vpn install
Line 37: Line 46:
 writing RSA key writing RSA key
 # cp /​etc/​iked/​ca/​ca.crt /​var/​www/​htdocs/​ # cp /​etc/​iked/​ca/​ca.crt /​var/​www/​htdocs/​
 +</​code>​
 +
 +We will use unbound as the caching DNS resolver. Our servers have static IP addresses so we do not use DHCP (if DHCP is used, you must ignore the provided name servers):
 +
 +/​etc/​resolv.conf:​
 +
 +<​code>​
 +nameserver 127.0.0.1
 +lookup file bind
 +</​code>​
 +
 +/​etc/​resolv.conf.tail:​
 +
 +<​code>​
 +lookup file bind
 +</​code>​
 +
 +/​var/​unbound/​etc/​unbound.conf:​
 +
 +<​code>​
 +outgoing-interface:​ 203.0.113.5
 +access-control:​ 10.0.0.0/8 allow
 +...
 +
 +local-zone: "​www.domain.com"​ static
 +
 +...
 +
 +forward-zone:​
 +forward-addr:​ 185.121.177.177
 +forward-addr:​ 169.239.202.202
 +
 +...
 +</​code>​
 +
 +The local-zone lines are only needed if you want to filter/​censor domains. You can obtain a list of domains to block using [[https://​github.com/​StevenBlack/​hosts|StevenBlack'​s hosts]] files. I used the [[https://​raw.githubusercontent.com/​StevenBlack/​hosts/​master/​alternates/​gambling-porn/​hosts|unified hosts + porn + gambling]] filter to block unwanted content.
 +
 +<​code>​
 +$ curl -L -O https://​raw.githubusercontent.com/​StevenBlack/​hosts/​master/​alternates/​gambling-porn/​hosts
 +</​code>​
 +
 +We need to reformat this hosts file:
 +
 +<​code>​
 +$ awk '!/^ *#/ && NF' hosts > newhosts # taken from stevenblack'​s list
 +$ sed '​s/​0\.0\.0\.0 \([^#​]*\).*$/​local-zone:​ "​\1"​ static/'​ newhosts > newhosts2
 +$ sed '​s/ ​ "/"/'​ newhosts2 > newhosts3
 +</​code>​
 +
 +Manually check for malformed entries, then put this into /​var/​unbound/​etc/​unbound.conf.
 +
 +Does this need to be added to /​etc/​sysctl.conf:​
 +
 +<​code>​
 +net.inet.ip.forwarding=1
 +net.inet.ipcomp.enable=1
 +net.inet.esp.enable=1
 +net.inet.ah.enable=1
 +</​code>​
 +
  
 To start iked, To start iked,
  
 +<​code>​
 $ doas rcctl enable iked $ doas rcctl enable iked
 $ doas rcctl set iked flags -6 $ doas rcctl set iked flags -6
 $ doas rcctl start iked $ doas rcctl start iked
 +</​code>​
  
 To turn on debugging, replace the last step with: To turn on debugging, replace the last step with:
  
-$ doas iked -dv+<​code>​ 
 +$ doas iked -6 -dv 
 +</​code>​ 
 + 
 +Note: You may consider using blacklists from here: 
 +https://​dsi.ut-capitole.fr/​blacklists/​index_en.php 
 +https://​github.com/​4skinSkywalker/​anti-porn-hosts-file/​blob/​master/​HOSTS.txt 
 +https://​mirror1.malwaredomains.com/​files/​justdomains https://​blocklist.site/​app/​dl/​piracy https://​blocklist.site/​app/​dl/​torrent https://​mirror1.malwaredomains.com/​files/​justdomains https://​github.com/​mmotti/​pihole-regex/​blob/​master/​regex.list https://​blocklist.site/​app/​dl/​porn 
 + 
 +Banned networks: 
 + 
 +irc.p2p-network.net 
 +irc.gazellegames.net 
 +irc.nzbs.in