1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AlmaLinux 9 on VirtualBox (Windows11)

Last updated at Posted at 2022-10-07

やろうとしたこと

Windows11にて、VirtualBox 6.1.38にAlmaLinux 9を入れて、OpenVPNサーバーを立て、Windows11(ホスト)とVirtualBoxの内部ネットワーク(intnet)から、別の内部ネットワーク(intnet2)へpingが通るようにする。

インストール環境

  • Windows11 21H2 (Build 22000.1042)
  • VirtualBox 6.1.38 r153438 (Qt5.6.2)
  • AlmaLinux OS 9 Latest (2022/10/07)

躓いたところ

  • VirtualBoxに、AlmaLinux9をインストールしようとしたら、Kernel Panicに。
  • なって、どうやっても先に進めず、インストールができたあとは、共有フォルダーを利用しようとしたら、GuestAdditionsのインストールもうまくいかず・・・
  • クライアントからの接続に伴う、OpenVPNサーバーの設定を少し試行錯誤・・・

試したこと

  • VirtualBoxのGUIでできるオプションをいろいろ変更

結果

ISOからのインストール

検索したら、VirtualBoxのフォーラムでも議論になっていました。
参考: AlmaLinux/RedHat 9 not installing on VirtualBox 6.1.36 (kernel panic)

結果、そのスレッドの一番下に記載されたコマンドを実行したら、無事インストールできました。
※ただ、インストール後の再起動がうまくいかなかったようなので、ゲストの電源OFF→起動をしました。

C:\Program Files\Oracle\VirtualBox> VBoxManage.exe setextradata "VM name" "VBoxInternal/CPUM/IsaExts/POPCNT" 1

これでもダメな場合は、

VBoxManage setextradata "VM name" "VBoxInternal/CPUM/IsaExts/POPCNT" "2"

を試してみて、と書いてありましたが、こちらは試してません。

GuestAdditionsをインストール

インストールを試みたところ、下記のエラーが出てしまっていました。

  Kernel headers not found for target kernal

なので、以下のように対処。

  1. # dnf -y update kernel
    Updateしているようであれば、# systemctl reboot
  2. # dnf -y install epel-release
  3. # dnf -y install kernel-devel kernel-headers gcc gcc-c++ make bzip2 tar elfutils-libelf-devel perl dkms
  4. 改めてGuestAdditionsのインストール

OpenVPNサーバーをインストール&設定

  • 複数の端末から接続するために、
    duplicate-cn
    を設定
  • VyOS on VirtualBox にて、TLS-Authができなかったので、
    +#tls-auth ta.key 0 # This file is secret
    でTLS-Authを無効化
# dnf -y update
# dnf -y install epel-release
# dnf --enablerepo=epel -y install systemd.x86_64 openvpn easy-rsa net-tools patch.x86_64
# cd /usr/share/easy-rsa/3
# export EASYRSA_BATCH="yes"
# export EASYRSA_REQ_CN="Test AlmaLinux9"
# ./easyrsa init-pki
# ./easyrsa build-ca nopass
# ./easyrsa build-server-full server1 nopass
# ./easyrsa build-client-full client1 nopass
# ./easyrsa gen-dh
# openvpn --genkey secret ./pki/ta.key
# /bin/cp -pRf /usr/share/easy-rsa/3/pki/{issued,private,ca.crt,dh.pem,ta.key} /etc/openvpn/server/
# /bin/cp -f /usr/share/doc/openvpn/sample/sample-config-files/server.conf /etc/openvpn/server/

# cat /tmp/shared/openvpn_server.conf.patch
--- /usr/share/doc/openvpn/sample/sample-config-files/server.conf       2022-05-24 17:48:18.000000000 +0900
+++ /etc/openvpn/server/server.conf     2022-10-09 19:13:50.315364019 +0900
@@ -76,13 +76,16 @@
 # 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
+#cert server.crt
+cert issued/server1.crt
+#key server.key  # This file should be kept secret
+key private/server1.key  # This file should be kept secret
 
 # Diffie hellman parameters.
 # Generate your own with:
 #   openssl dhparam -out dh2048.pem 2048
-dh dh2048.pem
+#dh dh2048.pem
+dh dh.pem
 
 # Network topology
 # Should be subnet (addressing via IP)
@@ -98,6 +101,7 @@
 # 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
 server 10.8.0.0 255.255.255.0
 
 # Maintain a record of client <-> virtual IP address
@@ -140,6 +144,8 @@
 # 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"
+push "route 192.168.40.0 255.255.255.0"
+push "route 192.168.200.0 255.255.255.0"
 
 # To assign specific IP addresses to specific
 # clients or if a connecting client has a private
@@ -219,7 +225,7 @@
 # CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
 # EACH HAVING ITS OWN UNIQUE "COMMON NAME",
 # UNCOMMENT THIS LINE OUT.
-;duplicate-cn
+duplicate-cn
 
 # The keepalive directive causes ping-like
 # messages to be sent back and forth over
@@ -241,7 +247,7 @@
 # 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
+#tls-auth ta.key 0 # This file is secret
 
 # Select a cryptographic cipher.
 # This config item must be copied to
@@ -260,7 +266,7 @@
 # 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
+comp-lzo
 
 # The maximum number of concurrently connected
 # clients we want to allow.
@@ -284,7 +290,8 @@
 # Output a short status file showing
 # current connections, truncated
 # and rewritten every minute.
-status openvpn-status.log
+#status openvpn-status.log
+status /var/log/openvpn-status.log
 
 # By default, log messages will go to the syslog (or
 # on Windows, if running as a service, they will go to
@@ -295,6 +302,8 @@
 # or the other (but not both).
 ;log         openvpn.log
 ;log-append  openvpn.log
+log         /var/log/openvpn.log
+log-append  /var/log/openvpn.log
 
 # Set the appropriate level of log
 # file verbosity.
@@ -312,4 +321,4 @@
 
 # Notify the client that when the server restarts so it
 # can automatically reconnect.
-explicit-exit-notify 1
\ No newline at end of file
+explicit-exit-notify 1

# patch -u /etc/openvpn/server/server.conf < /tmp/shared/openvpn_server.conf.patch
# /bin/cp -pf /etc/openvpn/server/{ca.crt,ta.key,issued/client1.crt,private/client1.key} /tmp/shared/

# systemctl edit openvpn-server@server
[Service]
ExecStartPost=/etc/openvpn/server/add-bridge.sh
ExecStopPost=/etc/openvpn/server/remove-bridge.sh

# /bin/cp -pf /tmp/shared/{add,remove}-bridge.sh /etc/openvpn/server/
# chmod +x /etc/openvpn/server/{add,remove}-bridge.sh

# systemctl enable --now openvpn-server@server
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?