root@gateway: ~ # apt install openvpn
root@gateway: ~ #cd /etc/openvpn
root@gateway: /etc/openvpn #l
insgesamt 12 drwxr-xr-x 2 root root 4096 Feb 20 2019 client drwxr-xr-x 2 root root 4096 Feb 20 2019 server -rwxr-xr-x 1 root root 1468 Feb 20 2019 update-resolv-conf
Da haben wir eine ausführbare Datei und zwei leere Verzeichnisse, ok, wieder suchen:
root@gateway: /etc/openvpn #locate openvpn
/usr/share/logwatch/default.conf/services/openvpn.conf /usr/share/logwatch/dist.conf/services/openvpn.conf /usr/share/logwatch/scripts/services/openvpn
Wie jetzt? Das ist alles?
Nö, da ist ne Menge dazugekommen, locate weiss es nur noch nicht:
root@gateway: /etc/openvpn # updatedb
root@gateway: /etc/openvpn #locate openvpn
Und jetzt sieht man auch was WireGuard meint besser zu machen…
Aber egal, ein
root@gateway: /etc/openvpn #cat /usr/share/doc/openvpn/examples/sample-config-files/README
Sample OpenVPN Configuration Files. These files are part of the OpenVPN HOWTO which is located at: http://openvpn.net/howto.html
Sagt uns wo wir schlauer werden.
Ok, einmal tief durchatmen. Wer mich hier verlässt um doch nochmal bei WireGuard zu schauen, dem kann man keinen Vorwurf machen.
Als ich damit angefangen habe gab es nur „Augen zu, äh auf, und durch“….
gateway: /etc/openvpn # l /usr/share/doc/openvpn/examples/sample-config-files insgesamt 68 -rw-r--r-- 1 root root 3586 Feb 20 2019 client.conf -rwxr-xr-x 1 root root 3562 Feb 20 2019 firewall.sh -rwxr-xr-x 1 root root 62 Feb 20 2019 home.up -rw-r--r-- 1 root root 672 Feb 20 2019 loopback-client -rw-r--r-- 1 root root 675 Feb 20 2019 loopback-server -rwxr-xr-x 1 root root 62 Feb 20 2019 office.up -rwxr-xr-x 1 root root 63 Feb 20 2019 openvpn-shutdown.sh -rwxr-xr-x 1 root root 776 Feb 20 2019 openvpn-startup.sh -rw-r--r-- 1 root root 131 Feb 20 2019 README -rw-r--r-- 1 root root 4353 Feb 20 2019 server.conf.gz -rw-r--r-- 1 root root 1779 Feb 20 2019 static-home.conf -rw-r--r-- 1 root root 1725 Feb 20 2019 static-office.conf -rw-r--r-- 1 root root 1938 Feb 20 2019 tls-home.conf -rw-r--r-- 1 root root 1949 Feb 20 2019 tls-office.conf -rw-r--r-- 1 root root 199 Feb 20 2019 xinetd-client-config -rw-r--r-- 1 root root 989 Feb 20 2019 xinetd-server-config
Wir haben ein paar Dateien, ein paar Scripte und ein gepacktes Archiv server.conf.gz
Was brauchen wir?
Man kann da gerne überall mal reinschauen, aber ich sags jetzt einfach:
client.conf – das kommt später, bearbeitet, auf die Clients
openvpn-shutdown.sh – ein script zum ausschalten des openVPN-Servers
openvpn-startup.sh – ein script zum einschalten des openVPN-Servers
– das ist doch mal was, das ist neu. Vor Debian 10 ging das noch normal mit systemctl, und hat bei der Erstinitiierung auch schonmal für Kopfschmerzen gesorgt….ich bin gespannt!
server.conf.gz – das Paket müssen wir noch auspacken….
auspacken? jo, gz = GNU zip der freie Packer, der Befehl dazu (man gunzip):
gunzip server.conf.gz
Aber zunächst:
root@gateway: /etc/openvpn #cd /usr/share/doc/openvpn/examples/sample-config-files/
root@gateway: /usr/share/doc/openvpn/examples/sample-config-files/ #cp -ax client.conf openvpn-shutdown.sh openvpn-startup.sh server.conf.gz /etc/openvpn/
root@gateway: /usr/share/doc/openvpn/examples/sample-config-files/ # .-
root@gateway: /etc/openvpn # l
insgesamt 32 drwxr-xr-x 2 root root 4096 Feb 20 2019 client -rw-r--r-- 1 root root 3586 Feb 20 2019 client.conf -rwxr-xr-x 1 root root 63 Feb 20 2019 openvpn-shutdown.sh -rwxr-xr-x 1 root root 776 Feb 20 2019 openvpn-startup.sh drwxr-xr-x 2 root root 4096 Feb 20 2019 server -rw-r--r-- 1 root root 4353 Feb 20 2019 server.conf.gz -rwxr-xr-x 1 root root 1468 Feb 20 2019 update-resolv-conf
Ohne -ax wären die Rechte der ausführbaren Dateien (grün) nicht mitgekommen.
root@gateway: /etc/openvpn # gunzip server.conf.gz
root@gateway: /etc/openvpn # l
?? Frag nicht, ich weiss auch nicht was da gepackt werden musste!
Auf jeden Fall haben wir jetzt unsere server.conf, die schauen wir uns an:
root@gateway: /etc/openvpn # cp server.conf server.conf.orig
root@gateway: /etc/openvpn # nano server.conf
################################################# # 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 ';' # ################################################# Als erstes fällt auf, zwei verschiedene Kommentarzeichen, Raute # kommentiert alles blau und erzählt uns was, Semikolon ; bleibt schwarz und zeigt uns ein Beispiel, welches aber weder Standard, noch aktiv ist. Nur unkommentierte Zeilen werden vom Server gelesen! # Which local IP address should OpenVPN # listen on? (optional) ;local a.b.c.d Hier muss die IP-Adresse von eth0 hin local 10.0.2.100 # 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 Ach, hab ich Unsinn erzählt mit 1196 was? Ja, der Standardport ist wohl 1194. Hier muss man nur ändern, wenn es mehrere VPN-Server gibt die man erreichen will. Beispiel: PA macht sein Homeoffice über den Port 1194 mit seiner Firma. Das geht nicht mehr, wenn PA auch seinen eigenen VPN zum Heimnetz auf 1194 aufsetzt! Für dieses Testsystem geht das auch nicht mehr so, deshalb: port 1196 # TCP or UDP server? ;proto tcp proto udp Welches System möchte rein? für Linux, MacOS und Windows ist udp gut, für iOS und Android muss es tcp sein. Wollen beide Systeme Zugang haben, werden zwei Server aufgesetzt, server.tcp.conf und server.udp.conf, beim Start schaut openVPN nach *.conf Dateien, und macht für jede einen eigenen Server, UND AUCH Client auf. Also aufpassen, was nachher noch in dem Verzeichnis /etc/openvpn rumliegt, client.conf muss wegkopiert (zu den künftigen Clients) oder umbenannt werden! # "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 heisst tun ist ok, mit bridging wollen wir uns nicht befassen. Die Firewall Regeln für die neue Schnittstelle tun0 (und eventuell tun1) erstellen wir natürlich noch, dazu muss der Server aber erst laufen. # 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.genau ;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 server.crt ;key server.key # This file should be kept secret wenn die certs und keys nun genau so im Ordner /etc/openvpn liegen, kann das so bleiben. Nach unserer Schlüsselrunde grade ist das aber nicht mehr der Fall, denn unser "server.crt/key heisst gateway.crt/key, ferner packe ich alle Schlüssel für einen Zweck auch immer in ein eigenes Verzeichnis, hier vielleicht to-loc...( das Verzeichnis server ist eigentlich dafür da, und geht genauso ), also oben ein paar Semikolons gesetzt und: ca to-loc/ca.crt cert to-loc/gateway.crt key to-loc/gateway.key # meint die Rechtevergabe: 600 nur lesbar für den Besitzer # Diffie hellman parameters. # Generate your own with: # openssl dhparam -out dh2048.pem 2048 ;dh dh2048.pem Hier ist Easy-RSA 3 auch noch nicht angekommen, unsere Datei heisst dh.pem dh to-loc/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 genau # 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 10.8.0.0 255.255.255.0 das neue Subnetz mit Maske, für das erste ok, für jedes weitere, also tun1 usw, muss das angepasst werden, also 10.9.0.0 z.B. - und, darf natürlich nicht bereits vergeben sein! Macht PA schon Homeoffice auf 10.8.0.0, geht das auch nicht.! # 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 Das Pendant zum Leasefile eines DHCP, diese Datei legt openVPN automatisch an und pflegt sie. Dort werden die "virtuellen" IP-Adressen, also z.B. 10.8.0.6 für Laptop oder 10.9.0.4 für Smartphone vermerkt. Virtuell? Ja, tun0, tun1 werden virtuelle Schnittstellen...mit virtuellen Adressräumen. # 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 Wir haben "tun" gesagt, also kein bridging... # 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 dito # 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" genau das machen wir, aber für: push "route 10.0.0.0 255.255.255.0" push "route 10.0.1.0 255.255.255.0" und es gibt Dinge die werde ich wohl nie verstehen, die ganzen UNIXfuzzies sind totale Abkürzungsjunkies, alles wird aufs möglichste reduziert ( list zu ls, copy zu cp, uswusf ) aber überall ist 192.168 Standard....kratzamkopf.. kak? DA! # 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. Würde mich interessieren ob WireGuard das auch drauf hat? Wir brauchen das hier nicht, aber wen es interessiert: Angenommen dieser Server würde zwei Standorte mit eigenen Gateways und Subnetzen verbinden und diese sollten sich erreichen können, dann ist hier der Weg beschrieben wie es geht. Unter /etc/openvpn gehört ein Verzeichnis "ccd" mit den spezifischen Dateien für gateway.standort1 und gateway.standort2. Dort werden die Informationen eingetragen die openvpn ausliest um damit die passenden Einträge in die Routingtabelle einzutragen. In der dazugehörigen client.conf auf gateway.standortX muss sich diese Information wiederspiegeln. Ein Plan ist auch hier ganz wichtig, es muss alles eindeutig sein, weder Namen noch der IP-Bereich eines beteiligten Subnetzes darf doppelt auftauchen, sonst geht da mal garnixmehr! # 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 Auch nett, ich tendiere zu mehreren openVPN Instanzen, eben tun0 und tun1 für Laptop und Smartphone, die können mit den Zonen in Shorewall dann getrennt behandelt werden. Ein passendes Script setzt ein tiefgreifendes Verständnis der NF-tables voraus. # 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" Das würde den VPN zum Proxy machen, also allen Netzwerkverkehr des Clients über diese Verbindung schicken, auch HTTP/S und MAIL. Will man das? Ich hier nicht, aber Deine Entscheidung. # 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" Windows-specific, kurz - ich hab keine Ahnung, ausprobieren wenn gewünscht ansonsten wird hier der gewünschte Nameserver an die Clients übergeben. # 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 Nö, um ins Heimnetz zu kommen, muss das nicht, aber auch hier wieder: will client.standort1 in standort2 drucken, dann muss das... # 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 Auf keinen Fall # 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 Das geht klar so, wenn Client ohne ordentliche Verabschiedung offline geht, macht der Server die Verbindung nach 120 Sekunden zu. # 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 to-loc/ta.key 0 # This file is secret Extra Sicherheit hört sich immer gut an, und kostet nicht extra, nur ein bisschen Zeit, Generiere mit openvpn --genkey --secret ta.key machen wir gleich... # 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 Wie stark soll die Verschlüsselung sein? Drunter machen wir es nicht. # 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" Tja, Deine Entscheidung, soll die Datenübertragung komprimiert werden? Je nachdem was da über das VPN gehen soll und wie schnell die jeweiligen Partner im Netz sind, macht das mehr oder weniger Sinn. Ausprobieren, ich hab es an. 1. macht die Kompression an, 2. zwingt sie dem Client auf # 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 Alte Version der Kompression, eigentlich nicht mehr, aber wenn dann nur für Clients die die neue nicht können. Ausserdem geht das push nicht, die Option muss also auch in der client.conf aktiviert sein. # The maximum number of concurrently connected # clients we want to allow. ;max-clients 100 Also, wenn es nur 1 Client gibt, dann max-clients 1 Laptop, oder? Smartphone verbindet sich extra via tcp... # 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 Startet den openVPN als root und wechselt dann zu nobody, gute Idee, scheint aber mit Windows nicht zu gehen. Hier ist jetzt aber nicht klar ob das nur gilt, wenn openVPN als Server auf Windows laufen soll, oder auch wenn sich Windows als Client verbinden will. Ausprobieren...tendenz immer ja. # 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 Per default an, und ich will mal nicht behaupten ich würde verstehen was das soll... # Output a short status file showing # current connections, truncated # and rewritten every minute. status /var/log/openvpn/openvpn-status.udp.log log ist immer gut, wo soll ich sonst gucken ob die Verbindung steht. # 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.udp.log ;log-append /var/log/openvpn/openvpn.log auch das finde ich prima, wenn - dann aber für jede Instanz einen eigenen bitte, also hier openvpn.udp.log und in der zweiten config openvpn.tcp.log. Wobei wie beschrieben log bei jedem Neustart des Servers eine neue Logdatei startet und log-append in der alten weiterschreibt. # 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 selbsterklärend, schau in die Logs und entscheide, suchst Du den Fehler oder alles tutti? # Silence repeating messages. At most 20 # sequential messages of the same message # category will be output to the log. mute 20 Das ist mal super, eine sich wiederholende Meldung wird nach 20 Wiederholungen nicht mehr gelogt. # Notify the client that when the server restarts so it # can automatically reconnect. explicit-exit-notify 1
Das würde ich jetzt als server.udp.conf sichern und das ganze mit fünf Änderungen:
# TCP or UDP server? ;proto tcp proto tcp und server 10.9.0.0 255.255.255.0 und status /var/log/openvpn/openvpn-status.tcp.log und log /var/log/openvpn/openvpn.tcp.log und #explicit-exit-notify 1 denn das geht nur auf udp
gleich nochmal als server.tcp.conf speichern, damit Smartphone auch mitspielen kann.
Dann die erste, server.conf löschen.
root@gateway: /etc/openvpn # rm server.conf
root@gateway: /etc/openvpn # l
insgesamt 52 drwxr-xr-x 2 root root 4096 Feb 20 2019 client -rw-r--r-- 1 root root 3586 Feb 20 2019 client.conf.orig -rwxr-xr-x 1 root root 63 Feb 20 2019 openvpn-shutdown.sh -rwxr-xr-x 1 root root 776 Feb 20 2019 openvpn-startup.sh drwxr-xr-x 2 root root 4096 Feb 20 2019 server -rw-r--r-- 1 root root 10880 Nov 11 16:39 server.tcp.conf -rw-r--r-- 1 root root 10880 Nov 11 16:38 server.udp.conf drwxr-xr-x 2 root root 4096 Nov 11 14:41 to-loc -rwxr-xr-x 1 root root 1468 Feb 20 2019 update-resolv-conf
Fehlt noch ta.key und alle anderen nach to-loc
root@gateway: /etc/openvpn # openvpn –genkey –secret ta.key
root@gateway: /etc/openvpn #mv ta.key to-loc/
zurück zu meinPC, wir brauchen noch dh.pem, ca.crt, gateway.crt und gateway.key, siehe:

ich@meinPC: ~ / scp ./openvpn/dh.pem root@gateway:/etc/openvpn/to-loc
ich@meinPC: ~ / scp ./openvpn/ca.crt root@gateway:/etc/openvpn/to-loc
ich@meinPC: ~ / scp ./openvpn/private/gateway.key root@gateway:/etc/openvpn/to-loc
ich@meinPC: ~ / scp ./openvpn/issued/gateway.crt root@gateway:/etc/openvpn/to-loc
jetzt Kontrolle ob die Rechte alle stimmen!!
gateway: /etc/openvpn # l to-loc
insgesamt 24 -rw------- 1 root root 1200 Nov 10 16:49 ca.crt -rw------- 1 root root 424 Nov 10 17:36 dh.pem -rw------- 1 root root 4608 Nov 10 16:57 gateway.crt -rw------- 1 root root 1704 Nov 10 16:56 gateway.key -rw------- 1 root root 636 Nov 11 16:47 ta.key
Das sieht gut aus, damit kann der Server loslegen: Ein Blick in die startup.sh zeigt aber, das ist doch nichts für uns, der althergebrachte Weg bleibt, wir machen ein zweites Terminalfenster dazu auf:
gateway: /etc/openvpn # rm openvpn-s*
gateway: /etc/openvpn # openvpn server.udp.conf
auf dem zweiten Terminal jetzt schauen ob tun0 da ist
gateway: /etc/openvpn # ip a
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100 link/none inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0 valid_lft forever preferred_lft forever
Prima, jetzt control+c im ersten Fenster und tun0 ist wieder weg
dann das Ganze einmal mit:
gateway: /etc/openvpn # openvpn server.tcp.conf
auf dem zweiten Terminal jetzt schauen ob tun0 da ist
gateway: /etc/openvpn # ip a
11: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100 link/none inet 10.9.0.1/24 brd 10.9.0.255 scope global tun0 valid_lft forever preferred_lft forever
Auch prima, wieder tun0, diesmal aber 10.9.0.1
Perfekt, also anschmeissen die Kiste
gateway: /etc/openvpn # systemctl enable openvpn server bitte nach reboot automatisch starten ( enable, gegenteil: disable )
gateway: /etc/openvpn # systemctl restart openvpn
12: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100 link/none inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0 valid_lft forever preferred_lft forever 13: tun1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100 link/none inet 10.9.0.1/24 brd 10.9.0.255 scope global tun1 valid_lft forever preferred_lft forever
Passt. Spätestens jetzt darf ein Blick in die Logs unter /var/log/openvpn geworfen werden, – sind alle da und was sagen sie? So muss das jetzt ungefähr aussehen, wenn alles gut ist:
Mon Nov 11 17:59:16 2019 OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Feb 20 2019 Mon Nov 11 17:59:16 2019 library versions: OpenSSL 1.1.1d 10 Sep 2019, LZO 2.10 Mon Nov 11 17:59:16 2019 Diffie-Hellman initialized with 2048 bit key Mon Nov 11 17:59:16 2019 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Mon Nov 11 17:59:16 2019 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication Mon Nov 11 17:59:16 2019 TUN/TAP device tun0 opened Mon Nov 11 17:59:16 2019 TUN/TAP TX queue length set to 100 Mon Nov 11 17:59:16 2019 /sbin/ip link set dev tun0 up mtu 1500 Mon Nov 11 17:59:16 2019 /sbin/ip addr add dev tun0 10.8.0.1/24 broadcast 10.8.0.255 Mon Nov 11 17:59:16 2019 Could not determine IPv4/IPv6 protocol. Using AF_INET Mon Nov 11 17:59:16 2019 Socket Buffers: R=[212992->212992] S=[212992->212992] Mon Nov 11 17:59:16 2019 UDPv4 link local (bound): [AF_INET]10.0.2.100:1196 Mon Nov 11 17:59:16 2019 UDPv4 link remote: [AF_UNSPEC] Mon Nov 11 17:59:16 2019 GID set to nogroup Mon Nov 11 17:59:16 2019 UID set to nobody Mon Nov 11 17:59:16 2019 MULTI: multi_init called, r=256 v=256 Mon Nov 11 17:59:16 2019 IFCONFIG POOL: base=10.8.0.2 size=252, ipv6=0 Mon Nov 11 17:59:16 2019 IFCONFIG POOL LIST Mon Nov 11 17:59:16 2019 Initialization Sequence Completed
Bzw. man schaut drüber und sieht am Ende „Initialization Sequence Completed“ und denkt sich gut.
Aber nix ist gut, bei genauerem Betrachten fällt auf:
Authentication: Using 160 bit message hash ‚SHA1‘ for HMAC authentication
Der Standard ist mir zu klein, das geht besser!
Unter die Zeile
cipher AES-256-CBC
bitte noch
auth SHA512
in beiden Konfigs, server.udp.conf und server.tcp.conf
speichern und ein systemctl restart openvpn
und nochmal der Blick ins Log:
Mon Nov 11 18:15:24 2019 Outgoing Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication Mon Nov 11 18:15:24 2019 Incoming Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication
Besser! Das ist vielleicht auch wieder etwas übertrieben, aber soweit ich weiss, ist SHA1 schon länger geknackt. Ob das hier eine Rolle spielt? Nicht unbedingt, aber…Unser Server läuft!
Endspurt: Shorewall anpassen, Portweiterleitung am Plasterouter einrichten.
next > Shorewall anpassen