Implemented vpn (mostly).

This commit is contained in:
Filipe Rodrigues 2022-06-15 16:14:27 +01:00
parent e31bd7b783
commit 6e79197c40
15 changed files with 792 additions and 0 deletions

View File

@ -23,6 +23,10 @@ ifconfig br0 up
iptables -A FORWARD -s 1.2.2.1 -j services
iptables -A FORWARD -d 1.2.2.1 -j services
# Route VPN `1.2.1.0/24` requests/responses to our services chain
iptables -A FORWARD -s 1.2.1.0/24 -j services
iptables -A FORWARD -d 1.2.1.0/24 -j services
# Don't allow requests from inner to inner or outer to outer, to avoid
# ip spoofing
iptables -A FORWARD -s 1.2.0.0/20 -d 1.2.0.0/20 -j DROP

View File

@ -2,3 +2,17 @@ ifconfig eth0 1.2.2.1/24 up
ifconfig eth1 6.6.6.1/24 up
ip route add 1.2.0.0/20 via 1.2.2.2
ip route add 0.0.0.0/0 via 6.6.6.2
# OpenVPN server
# Setup `tun/tap` dev
mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 600 /dev/net/tun
# Fix permissions
cd ~
chmod 0644 router1-server.crt ca.crt dh.pem server.conf
chmod 0600 router1-server.key ta.key
# Then start server
openvpn --client-config-dir ccd --ccd-exclusive --cipher AES-256-CBC --config server.conf &

20
router1/root/ca.crt Normal file
View File

@ -0,0 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDSDCCAjCgAwIBAgIUIyQ/vZh32TKCIbot6AonilBd5fcwDQYJKoZIhvcNAQEL
BQAwFTETMBEGA1UEAwwKcm91dGVyMS1jYTAeFw0yMjA2MTQxNTI0MTBaFw0zMjA2
MTExNTI0MTBaMBUxEzARBgNVBAMMCnJvdXRlcjEtY2EwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQC7Vupbfb+QTXQqfj8XtscFxKBtLFJKHmoyvLEo5R2M
EHWE4eLebjCM0aGc1h+pkH6T9hS2L9Nps9H22dtVwrkthCoyhWqhytElHi3Z9ivE
mbISeGzLpskA+kTwe1KzgTvq6f+65j8eKh0vrI72NhhYHl0kSv25AYizvLanXluh
TCAkNVSWdoDlp2xaGnxv1PMQMwC1GzlVRdzfE2w5+oFthMYuLdspGFqcXLTTmuC+
m/XOUlafEDbEMg9vEvG8gNfvyk+m7mKk1KEdp25XuH4bB8gRsEHNHcdZOXVKjgpE
CzJoSdpQYIakWdHNDd3n9rMsmkbuoHpIDWL+ksVEImXRAgMBAAGjgY8wgYwwHQYD
VR0OBBYEFN9nWL3NEQHILdqgGdNHCD7JPq7WMFAGA1UdIwRJMEeAFN9nWL3NEQHI
LdqgGdNHCD7JPq7WoRmkFzAVMRMwEQYDVQQDDApyb3V0ZXIxLWNhghQjJD+9mHfZ
MoIhui3oCieKUF3l9zAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjANBgkqhkiG
9w0BAQsFAAOCAQEAjuwHrCiLjJPp7DspOY4pDaQQlT2HIZnMXsdRbE3Lc9oSlTiB
vAtm7sOVj/TjIPeqVXXLvPvrejE4S8VyHLD2NyH7vBnZxaXKVMJfseixMMjpRNEy
8W385p5uX/d1ce5KUdTlrPIEWqijntQAidMGwDfkuBZlenWSDMzY6AEGfj3Fwm/Y
mFqrP9vk7us0IGc/t7nisQWvQ9ZDZWNmrxwf4yDC+JfbyzDyZK31/5z1E264j+HI
lW2CnuLI1noZ9wYxMSnoiFu4LrotEIkfixGCeY/zqeiM4cj6ZYpvYWrk/Uz55ixO
8BwoS5CJFvsDrTXDyc+f1FsOJlCzCrkNR54C9A==
-----END CERTIFICATE-----

View File

@ -0,0 +1 @@
iroute 5.4.3.0 255.255.255.0

8
router1/root/dh.pem Normal file
View File

@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEArgFfYRjmc0A8alcC4TYgLx5Fn4yUyuJgQbdAVqjB0y68RK2KUbSq
qkaCNc84EXK57ucN98/Gju/LtEi74/VWnyNxy8Rva31Kij41qzbyHHLaFnkyICwK
fgPp/6QVFWXS47HxkjnpvwvV22cO8bq0pPw1bNUEFbbPh1lv0QZPJw//nFtH4vD1
jZZpN24LCEADs0MYXT2QOmVATL0lAmB8Jo2Q4YDSfpwm8wwVjuC6b+FBkC/mMDO2
/m3n74VIDIXT4vim6KpzWIx/a1qGnssZKM7u1s9B6CSe/Ol0SsElBl67S1kvcznh
TLTyEMgzxVdYARMamIyHUDbL0plH6PysQwIBAg==
-----END DH PARAMETERS-----

View File

@ -0,0 +1,87 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
e6:c4:7f:6b:2c:2c:9f:53:fb:7d:de:57:ee:54:39:f5
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=router1-ca
Validity
Not Before: Jun 14 15:29:20 2022 GMT
Not After : May 29 15:29:20 2025 GMT
Subject: CN=router1-server
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Modulus:
00:c8:b4:7a:8c:c2:53:f9:a8:a6:63:e8:37:e0:67:
d4:3b:69:c1:31:61:42:20:0d:e6:e1:84:cc:5c:4a:
45:cd:a7:f5:1d:f1:5a:c9:f8:17:f5:c9:7e:5b:1d:
f9:ac:2b:37:4a:d0:dc:4b:22:b1:03:07:ca:f3:6b:
7a:c3:34:f3:04:35:ec:f5:4f:d6:e3:b1:c3:3f:96:
da:62:5f:6e:2d:69:b3:b7:c3:e9:a9:4f:ee:dc:33:
ce:c3:62:a4:38:01:b2:20:72:79:f4:f5:28:aa:b7:
eb:33:5f:b9:e6:ce:eb:ca:3e:6b:d9:74:86:02:13:
91:8a:a5:1f:fd:ad:05:71:f9:4b:28:e4:5f:dc:4e:
42:d6:53:15:3d:b2:67:3d:d9:ae:a5:64:ee:9d:bc:
f9:68:bb:a8:74:de:33:57:27:62:ee:46:c3:26:f7:
89:f0:6b:1a:ad:5e:f1:f7:cf:a4:3f:08:00:c9:37:
f4:9b:26:35:a1:24:84:8d:0b:ab:a9:12:9e:35:93:
5d:41:a0:35:f2:74:43:22:33:2d:d1:41:ba:41:87:
68:90:69:3d:38:16:2c:1f:f7:dc:6a:de:d7:16:62:
86:c6:f8:b8:72:26:bc:f9:fa:1e:cf:59:36:aa:ac:
28:67:d1:83:dd:fb:0c:ce:0c:22:54:fb:2f:02:8f:
58:d5
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
E7:65:D8:AC:C9:27:CC:05:7B:C4:D4:78:57:BA:75:00:D9:C0:1F:42
X509v3 Authority Key Identifier:
keyid:DF:67:58:BD:CD:11:01:C8:2D:DA:A0:19:D3:47:08:3E:C9:3E:AE:D6
DirName:/CN=router1-ca
serial:23:24:3F:BD:98:77:D9:32:82:21:BA:2D:E8:0A:27:8A:50:5D:E5:F7
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Key Usage:
Digital Signature, Key Encipherment
X509v3 Subject Alternative Name:
DNS:router1-server
Signature Algorithm: sha256WithRSAEncryption
4f:a5:4d:75:ef:f3:9c:a2:ff:ad:36:64:23:5b:31:fe:c4:fe:
6a:1c:72:9a:66:8a:2a:bd:ce:2b:61:1e:0e:e6:35:8b:21:16:
52:92:fe:0f:83:16:35:99:1d:d3:03:01:7a:a8:75:18:2f:96:
bd:b7:c4:65:f0:69:11:bf:14:41:d5:12:81:7e:59:84:fe:7d:
c9:2f:ed:02:d3:d9:56:c1:47:2a:6c:15:66:ed:6d:ff:e8:e7:
2e:9e:36:3d:87:a6:ce:2f:a9:51:d4:1f:71:4b:5e:75:04:4a:
39:8d:d9:e7:7f:4d:f8:4e:2e:83:72:97:1a:ee:f4:8c:5a:95:
14:07:d3:87:af:a6:05:81:34:47:1f:7a:a3:8d:43:1b:31:a5:
d8:3e:46:7c:20:b6:d8:4f:ab:e9:17:1c:e8:38:44:7f:32:bd:
b8:e9:93:df:0b:88:87:89:bc:75:9d:07:29:47:a5:7b:f6:e4:
6f:37:cf:db:2b:e6:55:0b:ae:fb:4e:87:22:91:5a:f7:99:eb:
5c:85:e3:be:d9:cc:2e:79:9e:ea:40:7b:d8:83:36:f1:3e:e1:
ab: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mjE3U
5BcRG9gpVKinarZ04mBApS74Yn506m/lizy79qYD4HETH+SigDXKMngV7j4A2Wd9
ckktu2fKQ9u5VZ2sbvTZuAUkS1Zlv1/2zp0GBSclDMVDPQHcM+5hgwOmqLDg7IkK
q4B9QRFx1aH2NtlVZZl4uhnXlwKBgQDaJ8CgGcmgPytYWW4TVpMTWFPC+W3dCqxv
dvt+5ctESaVg92nCRxB9L8oh2g+MBf6KWOOiPHGpf3fhITkVZHVnen/LABP9N8ml
ih88LD13/BniB7SjqdQ6TY3rucxv6tn/D3whgsMPjC3aZon0DXU0t2e32Crfj3DQ
5FlI0RiAcwKBgQDXCrSboZD99zfJN4XBAdlF18SQSCoNYlPheOglXiz6wQNxQLSW
Q4FapaODGqRjr9UTwjhau6YFcBfQsq/ZTEYgqWHkvfyaxd9HF7AcMfcP4nGqSQgX
0yJv4riRDY33DHbsVcYr5nGo85E8bPvbcCfLNWP2KfbNVdsuK6vrHRCHVQKBgH0T
w65HesGk1i4+gA0YWxUBVGz6Y5ITV5BE8KbuC5/odahl0j4wTnToHIVSKA3JNgqO
Ml1HOIfM7KeoS7lHMsUUiAaU0eEhxjxiN8xhNREA+roMXvZjHaob4x3fFiaoyToi
37G67imQ3o1Usw25VZTW/uF6UAKDlFRASCymrdyfAoGBAKhAD1P+vHTdMWt2ePM2
g+CzggAFbDzYgfLvzovC9CJTl3gaOTmy/nbNBkRefnnWOZKUxq784IUz77OO9nHt
5CSRAjr/ozhtXBgFoQEF5Q+FC7q1gY2ktX5c9t3aTJalo+uPcny90kZpqkDBHDKo
G+gYiZRSI/Bjp8cXmRPHXTaL
-----END PRIVATE KEY-----

315
router1/root/server.conf Normal file
View File

@ -0,0 +1,315 @@
#################################################
# Sample OpenVPN 2.0 config file for #
# multi-client server. #
# #
# This file is for the server side #
# of a many-clients <-> one-server #
# OpenVPN configuration. #
# #
# OpenVPN also supports #
# single-machine <-> single-machine #
# configurations (See the Examples page #
# on the web site for more info). #
# #
# This config should work on Windows #
# or Linux/BSD systems. Remember on #
# Windows to quote pathnames and use #
# double backslashes, e.g.: #
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
# #
# Comments are preceded with '#' or ';' #
#################################################
# Which local IP address should OpenVPN
# listen on? (optional)
;local a.b.c.d
# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one. You will need to
# open up this port on your firewall.
port 1194
# TCP or UDP server?
;proto tcp
proto udp
# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one. On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap
# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key). Each client
# and the server must have their own cert and
# key file. The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys. Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca ca.crt
cert router1-server.crt
key router1-server.key # This file should be kept secret
# Diffie hellman parameters.
# Generate your own with:
# openssl dhparam -out dh2048.pem 2048
dh dh.pem
# Network topology
# Should be subnet (addressing via IP)
# unless Windows clients v2.0.9 and lower have to
# be supported (then net30, i.e. a /30 per client)
# Defaults to net30 (not recommended)
;topology subnet
# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 1.2.1.0 255.255.255.0
# Maintain a record of client <-> virtual IP address
# associations in this file. If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist /var/log/openvpn/ipp.txt
# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface. Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0. Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients. Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100
# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses. You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
;server-bridge
# Push routes to the client to allow it
# to reach other private subnets behind
# the server. Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).
# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
# iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN. This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.
# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
# ifconfig-push 10.9.0.1 10.9.0.2
# Suppose that you want to enable different
# firewall access policies for different groups
# of clients. There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
# group, and firewall the TUN/TAP interface
# for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
# modify the firewall in response to access
# from different clients. See man
# page for more info on learn-address script.
;learn-address ./script
# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"
# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses. CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"
# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client
# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names. This is recommended
# only for testing purposes. For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn
# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120
# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
# openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
tls-auth ta.key 0 # This file is secret
# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
cipher AES-256-CBC
# Enable compression on the VPN link and push the
# option to the client (v2.4+ only, for earlier
# versions see below)
;compress lz4-v2
;push "compress lz4-v2"
# For compression compatible with older clients use comp-lzo
# If you enable it here, you must also
# enable it in the client config file.
;comp-lzo
# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100
# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
;user nobody
;group nogroup
# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun
# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status /var/log/openvpn/openvpn-status.log
# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it. Use one
# or the other (but not both).
;log /var/log/openvpn/openvpn.log
;log-append /var/log/openvpn/openvpn.log
# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3
# Silence repeating messages. At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20
# Notify the client that when the server restarts so it
# can automatically reconnect.
explicit-exit-notify 1

21
router1/root/ta.key Normal file
View File

@ -0,0 +1,21 @@
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
24dff1306f2509bf80fc9a8a01308331
0bd5b9ac340d0ef918546a9e08617fda
fcee97e86bcc1fb6e9d665e9b606111a
ed1042578967d9e00a2cba534c548b70
0b120ec3cbe74a3cdb4edfc7b529cb98
df44c6154f4523c20b47a112c5de16fe
1da57de88affb37a30b9f69df1351e37
5c7febf2a4ed6eac524f1e49410cb5b7
05801a33c4dc1eda407884d95a056daa
e4b1de5ffc398d298db5452b58a90086
b2cf6517f5b678fac8f70791248b995b
deebe75fd6484dfad48c71b17d36035f
05a40c55b9020760f597fa3b9b04d9b3
59a70017960aa2c1e81c93c0e3f358a1
6555125831a9389eb78c7e0d9552c602
f39a71c0c514be574ae26bf836a5121e
-----END OpenVPN Static key V1-----

View File

@ -28,3 +28,17 @@ ip route add 0.0.0.0/0 via 6.6.6.1
# Allow requests/responses to Oeiras smb (tcp/445)
iptables -A FORWARD -i eth0 -d 1.2.4.55 -p tcp --dport 445 -j ACCEPT
iptables -A FORWARD -i eth1 -s 1.2.4.55 -p tcp --sport 445 -j ACCEPT
# OpenVPN client
# Setup `tun/tap` dev
mkdir -p /dev/net
mknod /dev/net/tun c 10 200
chmod 600 /dev/net/tun
# Fix permissions
cd ~
chmod 0644 router3-client.crt ca.crt client.conf
chmod 0600 router3-client.key ta.key
# Then start client
openvpn --redirect-gateway def1 --cipher AES-256-CBC --config client.conf &

20
router3/root/ca.crt Normal file
View File

@ -0,0 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDSDCCAjCgAwIBAgIUIyQ/vZh32TKCIbot6AonilBd5fcwDQYJKoZIhvcNAQEL
BQAwFTETMBEGA1UEAwwKcm91dGVyMS1jYTAeFw0yMjA2MTQxNTI0MTBaFw0zMjA2
MTExNTI0MTBaMBUxEzARBgNVBAMMCnJvdXRlcjEtY2EwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQC7Vupbfb+QTXQqfj8XtscFxKBtLFJKHmoyvLEo5R2M
EHWE4eLebjCM0aGc1h+pkH6T9hS2L9Nps9H22dtVwrkthCoyhWqhytElHi3Z9ivE
mbISeGzLpskA+kTwe1KzgTvq6f+65j8eKh0vrI72NhhYHl0kSv25AYizvLanXluh
TCAkNVSWdoDlp2xaGnxv1PMQMwC1GzlVRdzfE2w5+oFthMYuLdspGFqcXLTTmuC+
m/XOUlafEDbEMg9vEvG8gNfvyk+m7mKk1KEdp25XuH4bB8gRsEHNHcdZOXVKjgpE
CzJoSdpQYIakWdHNDd3n9rMsmkbuoHpIDWL+ksVEImXRAgMBAAGjgY8wgYwwHQYD
VR0OBBYEFN9nWL3NEQHILdqgGdNHCD7JPq7WMFAGA1UdIwRJMEeAFN9nWL3NEQHI
LdqgGdNHCD7JPq7WoRmkFzAVMRMwEQYDVQQDDApyb3V0ZXIxLWNhghQjJD+9mHfZ
MoIhui3oCieKUF3l9zAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjANBgkqhkiG
9w0BAQsFAAOCAQEAjuwHrCiLjJPp7DspOY4pDaQQlT2HIZnMXsdRbE3Lc9oSlTiB
vAtm7sOVj/TjIPeqVXXLvPvrejE4S8VyHLD2NyH7vBnZxaXKVMJfseixMMjpRNEy
8W385p5uX/d1ce5KUdTlrPIEWqijntQAidMGwDfkuBZlenWSDMzY6AEGfj3Fwm/Y
mFqrP9vk7us0IGc/t7nisQWvQ9ZDZWNmrxwf4yDC+JfbyzDyZK31/5z1E264j+HI
lW2CnuLI1noZ9wYxMSnoiFu4LrotEIkfixGCeY/zqeiM4cj6ZYpvYWrk/Uz55ixO
8BwoS5CJFvsDrTXDyc+f1FsOJlCzCrkNR54C9A==
-----END CERTIFICATE-----

127
router3/root/client.conf Normal file
View File

@ -0,0 +1,127 @@
##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
##############################################
# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one. On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap
# Are we connecting to a TCP or
# UDP server? Use the same setting as
# on the server.
;proto tcp
proto udp
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 6.6.6.1 1194
;remote my-server-2 1194
# Choose a random host from the remote
# list for load-balancing. Otherwise
# try hosts in the order specified.
;remote-random
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# Most clients don't need to bind to
# a specific local port number.
nobind
# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup
# Try to preserve some state across restarts.
persist-key
persist-tun
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]
# Wireless networks often produce a lot
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
# SSL/TLS parms.
# See the server config file for more
# description. It's best to use
# a separate .crt/.key file pair
# for each client. A single ca
# file can be used for all clients.
ca ca.crt
cert router3-client.crt
key router3-client.key
# Verify server certificate by checking that the
# certicate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
# http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
# digitalSignature, keyEncipherment
# and the extendedKeyUsage to
# serverAuth
# EasyRSA can do this for you.
remote-cert-tls server
# If a tls-auth key is used on the server
# then every client must also have the key.
tls-auth ta.key 1
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
# Note that v2.4 client/server will automatically
# negotiate AES-256-GCM in TLS mode.
# See also the ncp-cipher option in the manpage
cipher AES-256-CBC
# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
#comp-lzo
# Set log file verbosity.
verb 3
# Silence repeating messages
;mute 20

View File

@ -0,0 +1,84 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
f6:69:8c:88:61:b9:db:34:92:7b:26:2d:08:a9:4d:52
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=router1-ca
Validity
Not Before: Jun 14 15:29:09 2022 GMT
Not After : May 29 15:29:09 2025 GMT
Subject: CN=router3-client
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Modulus:
00:b1:74:03:c5:52:00:a7:ee:0a:ef:d0:17:14:23:
95:fc:98:a9:e0:16:6e:21:50:b8:16:83:45:de:7c:
f1:8a:94:02:a2:ff:91:c2:b2:9f:2a:54:1d:20:b6:
2b:c2:25:e6:50:fe:ef:a5:31:57:0c:01:60:e7:0a:
f4:cc:cd:7b:af:f4:93:b2:45:98:3e:b5:bc:68:35:
7d:e3:7c:47:14:13:67:28:60:9c:ee:a7:70:97:74:
7a:9c:c1:17:ab:33:8b:e1:a8:55:61:3b:b6:c0:28:
44:ed:da:57:61:0a:10:d2:c1:88:81:d8:b9:bc:1a:
5f:20:09:97:c0:83:50:51:7d:2e:85:e9:a0:18:bd:
f7:3e:79:22:63:ac:c0:9f:9a:ec:f7:7e:fe:9a:22:
d3:3a:cc:5f:4a:14:ab:1c:50:e7:ba:b5:63:a9:3a:
f0:47:80:97:28:9b:a9:2a:79:aa:72:39:b7:5b:d1:
01:24:b6:5e:fb:21:3c:60:5d:ed:da:aa:97:93:ef:
73:c5:bf:a6:aa:cb:60:8b:88:e2:da:e6:76:3b:af:
c9:6e:62:30:80:f3:43:e1:a1:e9:6e:a2:b1:1f:40:
64:87:e6:44:d2:e4:d2:04:46:58:8a:22:d6:57:6d:
1b:d2:cc:bb:fb:97:bf:c3:b0:0e:ab:eb:1c:39:0d:
16:83
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
X509v3 Subject Key Identifier:
32:0A:DF:5C:00:FF:12:BD:EC:3D:77:46:E1:68:25:2F:57:16:67:34
X509v3 Authority Key Identifier:
keyid:DF:67:58:BD:CD:11:01:C8:2D:DA:A0:19:D3:47:08:3E:C9:3E:AE:D6
DirName:/CN=router1-ca
serial:23:24:3F:BD:98:77:D9:32:82:21:BA:2D:E8:0A:27:8A:50:5D:E5:F7
X509v3 Extended Key Usage:
TLS Web Client Authentication
X509v3 Key Usage:
Digital Signature
Signature Algorithm: sha256WithRSAEncryption
49:77:de:3e:cc:2a:75:ed:c4:ae:29:3a:94:56:b5:c5:8d:30:
a5:63:45:f8:9e:85:fc:c4:97:cc:10:84:a1:56:f9:33:0b:91:
e3:f8:8c:c2:fb:c3:47:3c:76:0d:1e:9e:bf:d0:1d:16:9e:83:
1e:c8:c3:c3:fa:03:6e:93:56:0f:5c:93:80:39:78:fe:88:81:
d2:4e:19:ee:99:a8:65:00:50:ed:a8:aa:c9:1f:4f:92:26:7b:
08:e8:f1:33:2e:a6:26:03:89:ec:a0:b9:d2:60:0e:8a:0e:bf:
6d:b2:07:67:1e:28:3c:5e:b8:8b:b3:fb:6e:0e:30:7c:80:84:
6d:d0:11:57:ad:a8:44:69:e9:9b:05:64:3c:f3:92:8f:9f:21:
5a:e7:fc:42:f0:5e:89:a7:d5:4e:9f:3d:ef:37:10:03:75:90:
21:2f:fb:9c:43:8e:2e:0a:9d:a3:55:78:a1:4e:f1:3c:dd:70:
3b:82:37:df:72:e6:c2:b8:7e:99:a0:47:07:96:30:c3:6b:47:
13:88:31:91:1b:8e:90:f1:3a:41:61:48:e1:34:e7:71:e3:b9:
6e:58:be:d5:eb:dd:8b:6f:30:79:f9:5e:d7:f0:d2:15:dd:41:
72:e0:7d:d9:38:81:ba:d3:41:60:0c:f5:f3:8c:99:d1:ab:71:
7d:ed:fb:17
-----BEGIN CERTIFICATE-----
MIIDWzCCAkOgAwIBAgIRAPZpjIhhuds0knsmLQipTVIwDQYJKoZIhvcNAQELBQAw
FTETMBEGA1UEAwwKcm91dGVyMS1jYTAeFw0yMjA2MTQxNTI5MDlaFw0yNTA1Mjkx
NTI5MDlaMBkxFzAVBgNVBAMMDnJvdXRlcjMtY2xpZW50MIIBIjANBgkqhkiG9w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1LbUeYDSEsLYg4KYiZhOIcCzyk5MlF+dYTDcFlJndw7LVNqD
xqSjS5h2LKIcNAQVDJVa+iw6GWZ6dU4wtLE/GPfAfRMgfnVvfzzo3YCK1pdqWjI1
gj6vr5t07QaLuwGFO3j9M2274u983bxi+7/O2MJzliR8HvKPjPMu4YpqEQKBgQCh
+5xkY59foGUdPnjFTpe/9zFH9KOStUGGWFTp81c9EYfc7O6H55uAxh7Ws6HoLh4t
zraGsQ0iauyPRvgIOULqEL0ej+pj4DR4I+ZhtMODgsLpGJI7LJwOo7m99lRyLrRt
dgL5I0MwgDzmfj+vl8Xnejn1Efq8we+3/r2yJfkSYwKBgEK0/aXtaMFK6neaTNfI
QdxizQgGiNPmcCD7FyEOH7ZmD1P9cq+wtgwBFoXLsaflxNUAc/wVpu6ghMsbtsjR
fOclsu2PUEVcGHVe77f8lwA6+J/x/gslCxGCacvXRYnOuyhDaAlWoAoP7KE4xPLg
1NsL/c4otOU0fpydjKnBQWcb
-----END PRIVATE KEY-----

21
router3/root/ta.key Normal file
View File

@ -0,0 +1,21 @@
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
24dff1306f2509bf80fc9a8a01308331
0bd5b9ac340d0ef918546a9e08617fda
fcee97e86bcc1fb6e9d665e9b606111a
ed1042578967d9e00a2cba534c548b70
0b120ec3cbe74a3cdb4edfc7b529cb98
df44c6154f4523c20b47a112c5de16fe
1da57de88affb37a30b9f69df1351e37
5c7febf2a4ed6eac524f1e49410cb5b7
05801a33c4dc1eda407884d95a056daa
e4b1de5ffc398d298db5452b58a90086
b2cf6517f5b678fac8f70791248b995b
deebe75fd6484dfad48c71b17d36035f
05a40c55b9020760f597fa3b9b04d9b3
59a70017960aa2c1e81c93c0e3f358a1
6555125831a9389eb78c7e0d9552c602
f39a71c0c514be574ae26bf836a5121e
-----END OpenVPN Static key V1-----