LoginSignup
0
0

More than 1 year has passed since last update.

VyOS on VirtualBox (Windows11)

Last updated at Posted at 2022-10-07

やろうとしたこと

VyOSをVirtualBoxにインストールして、別に立てたOpenVPNサーバーへクライアント接続をすることを目標に始めました。

インストール環境

  • Windows11 21H2 (Build 22000.1042)
  • VirtualBox 6.1.38 r153438 (Qt5.6.2)
  • VyOS 1.4 (rolling-202210050218-amd64)

躓いたところ

  1. Windows11上のVirtualBoxにVyOSをインストールしようとしたところ、Kernel Panicに。
  2. VyOSをインストール後、OpenVPNサーバへ接続するマニュアルや記事を書いている人がおどろくほど少なかった&TLS-Authの設定に難があり・・・

試したこと

  • VirtualBoxのGUIでできるオプションをいろいろ変更
  • OpenVPN TLSの設定を追加したり削除したり、いろいろ小細工したり・・・

結果

VirtualBoxのゲストの設定

「システム→アクセラレーション」タブにある
準仮想化インターフェース
を、
ディフォルト→Hyper-V
にしたところ、無事起動。
※Hyper-Vが生きているから、このオプションにしないといけないのかな・・・?

VPN接続(OpenVPNサーバーへ)

行った設定

  • キーボードを日本語レイアウトに変更

    vyos$ sudo su -
    root# vi /etc/default/keyboard
    - XKBMODEL="pc105"
    - XKBLAYOUT="us"
    + XKBMODEL="pc106"
    + XKBLAYOUT="up"
    root# exit
    vyos$ reboot
    
  • タイムゾーンを変更

    vyos$ configure
    vyos# set system time-zone Asia/Tokyo
    vyos# commit
    vyos# save
    vyos# date
    
  • イーサネットを設定
    vyos# set interfaces NIC# address 'IP_Address'
    vyos# set interfaces NIC# description 'Network_Label'

    vyos# set interfaces eth1 address '192.168.100.1'
    vyos# set interfaces eth1 description 'LAN'
    vyos# show interfaces
    vyos# commit
    vyos# save
    
  • SSHサービスを起動

    vyos# set service ssh
    vyos# commit
    vyos# save
    vyos# exit
    vyos$ reboot
    
  • NTPサーバーを設定
    vyos# set system ntp server NTP_Server_IP/Host

    vyos$ configure
    vyos# delete system ntp server
    vyos# set system ntp server ntp.nict.jp
    vyos# commit
    vyos# save
    
  • NATを設定
    vyos# set nat source rule Rule# outbound-interface _NIC#
    vyos# set nat source rule Rule# translation address masquerade

    vyos# set nat source rule 999 outbound-interface eth0
    vyos# set nat source rule 999 translation address masquerade
    vyos# commit
    vyos# save
    
  • VPNを設定

    • Shared Secretを設定 (たぶん不要?)

      vyos$ generate pki openvpn shared-secret install shared-secret1
        ※ここで表示されたコマンドをconfigureした後で入力する※
      vyos$ configure
      vyos# set pki openvpn shared-secret shared-secret1 key 'blah blah'
      vyos# set pki openvpn shared-secret shared-secret1 version '1'
      vyos# commit
      vyos# save
      
    • 証明書をPKIに設定
      set pki ca PKI CA Name certificate 'CA_Certificate_String1'
      set pki certificate PKI_Certificate_Name certificate 'Certificate_String2'
      set pki certificate PKI_Certificate_Name private key `Private_Key_String3'

      vyos# set pki ca ca1 certificate 'blahblah'
      vyos# set pki certificate client1 certificate `blahblah`
      vyos# set pki certificate client1 private key `blahblah'
      vyos# commit
      vyos# save
      
    • VPN(OpenVPN)を設定
      set interfaces openvpn VTUN# encryption cipher 'aes256'
      set interfaces openvpn VTUN# hash 'sha512'
      set interfaces openvpn VTUN# mode 'client'
      set interfaces openvpn VTUN# persistent-tunnel
      set interfaces openvpn VTUN# protocol 'udp'
      set interfaces openvpn VTUN# remote-host 'VPN_Server_IP/Host'
      set interfaces openvpn VTUN# remote-port 'VPN_Server_Port#'
      set interfaces openvpn VTUN# tls ca-certificate PKI_CA_Name
      set interfaces openvpn VTUN# tls certificate PKI_Certificate_Name
      set interfaces openvpn VTUN# use-lzo-compression
      set interfaces openvpn VTUN# openvpn-option 'fast-io'
      set interfaces openvpn VTUN# openvpn-option 'allow-compression yes'
      set interfaces openvpn VTUN# openvpn-option 'route-nopull'
      set interfaces openvpn VTUN# openvpn-option 'ping-restart 60'
      set interfaces openvpn VTUN# openvpn-option 'persist-tun'
      set interfaces openvpn VTUN# openvpn-option 'persist-key'
      set interfaces openvpn VTUN# openvpn-option 'ping 10'
      set interfaces openvpn VTUN# openvpn-option 'dev __VTUN#'
      set interfaces openvpn VTUN# openvpn-option 'log Log_File_Path'
      set interfaces openvpn VTUN# openvpn-option 'remote-cert-tls server'

      ※TLS-Authの設定は、いろいろなところで、openvpn-option 'tls-auth Path_to_Key' でできると書いてありましたが、うまく読み込めていなかったようなので外しました。

      e.g.

      vyos# set interfaces openvpn vtun1 encryption cipher 'aes256'
      vyos# set interfaces openvpn vtun1 hash 'sha512'
      vyos# set interfaces openvpn vtun1 mode 'client'
      vyos# set interfaces openvpn vtun1 persistent-tunnel
      vyos# set interfaces openvpn vtun1 protocol 'udp'
      vyos# set interfaces openvpn vtun1 remote-host '10.0.0.1'
      vyos# set interfaces openvpn vtun1 remote-port '1194'
      vyos# set interfaces openvpn vtun1 tls ca-certificate ca1
      vyos# set interfaces openvpn vtun1 tls certificate client1
      vyos# set interfaces openvpn vtun1 use-lzo-compression
      vyos# set interfaces openvpn vtun1 openvpn-option "fast-io"
      vyos# set interfaces openvpn vtun1 openvpn-option "allow-compression yes"
      vyos# set interfaces openvpn vtun1 openvpn-option "route-nopull"
      vyos# set interfaces openvpn vtun1 openvpn-option "ping-restart 60"
      vyos# set interfaces openvpn vtun1 openvpn-option "persist-tun"
      vyos# set interfaces openvpn vtun1 openvpn-option "persist-key"
      vyos# set interfaces openvpn vtun1 openvpn-option "ping 10"
      vyos# set interfaces openvpn vtun1 openvpn-option "dev vtun10"
      vyos# set interfaces openvpn vtun1 openvpn-option "log /var/log/openvpn.log"
      vyos# set interfaces openvpn vtun1 openvpn-option "remote-cert-tls server"
      
    • ファイヤーウォールを設定
      set firewall name Firewall Name rule Rule# destination port Port#
      set firewall name Firewall Name rule Rule# action accept
      set firewall name Firewall Name rule Rule# protocol Protocol Name

      vyos# set firewall name openvpn rule 999 destination port 1194
      vyos# set firewall name openvpn rule 999 action accept
      vyos# set firewall name openvpn rule 999 protocol udp
      
    • SNATを設定
      vyos# set nat source rule Rule# outbound-interface 'vtun#'
      vyos# set nat source rule Rule# source address 'IP Address Range'
      vyos# set nat source rule Rule# translation address masquerade

      vyos# set nat source rule 100 outbound-interface 'vtun1'
      vyos# set nat source rule 100 source address '0.0.0.0/0'
      vyos# set nat source rule 100 translation address masquerade
      

おまけ

  • rootになる
    vyos$ sudo su -
    
  • GuestAdditionsのインストール
    できないのかな・・・?まだ未確認。
  1. CA証明書ファイルの -----BEGIN CERTIFICATE----- から -----END CERTIFICATE----- の間の文字列を1行にしたもの

  2. クライアント証明書の -----BEGIN CERTIFICATE----- から -----END CERTIFICATE----- の間の文字列を1行にしたもの

  3. クライアント証明書の秘密鍵の -----BEGIN PRIVATE KEY----- から -----END PRIVATE KEY----- の間の文字列を1行にしたもの

0
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
0
0