This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

AWSでSoftEther VPNを構築してみた記事

Last updated at Posted at 2024-03-12

やりたかったこと

以下のエントリを見て、自分でもやってみたいと思った。

手元の環境から接続できることが目的。

変更点

  • インスタンスのOSはUbuntuに

  • systemdのユニットファイルについては、
    https://gihyo.jp/admin/serial/01/ubuntu-recipe/0788
    を参考に次のように改変した。

    vpnserver.service
    [Unit]
    Description=SoftEther VPN Server
    After=network.target auditd.service
    ConditionPathExists=!/opt/vpnserver/do_not_run
    
    [Service]
    Type=forking
    EnvironmentFile=-/opt/vpnserver
    ExecStartPre=/sbin/ip link set dev <NICの名前> promisc on
    ExecStart=/opt/vpnserver/vpnserver start
    ExecStop=/opt/vpnserver/vpnserver stop
    KillMode=process
    Restart=on-failure
    
    # Hardening
    PrivateTmp=yes
    ProtectHome=yes
    ProtectSystem=full
    ReadOnlyDirectories=/
    ReadWriteDirectories=-/opt/vpnserver
    CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST 
    CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
    
    [Install]
    WantedBy=multi-user.target
    
  • vpncmdで以下のコマンドを打った時の、

    DhcpSet /START:192.168.30.10 /END:192.168.30.200 /MASK:255.255.255.0 /EXPIRE:7200 
    /GW:192.168.30.1 /DNS:192.168.30.1 /DNS2:none /DOMAIN:none /LOG:yes 
    /PUSHROUTE:"10.0.0.0/255.255.0.0/192.168.30.1"
    

    /PUSHROUTE:"10.0.0.0/255.255.240.0/192.168.30.1"の部分については、

    EC2のコンソールからインスタンスIDをクリック
    スクリーンショット 2024-03-12 231908.png

    インスタンス概要からVPC IDをクリック
    スクリーンショット 2024-03-12 231939.png

    IPv4 CIDRから、(プライベート)IPアドレスとサブネットを確認
    スクリーンショット 2024-03-12 232046.png

    今回はIPアドレスが172.31.0.0、サブネットが(prefix表記で/16なので)255.255.0.0となるので、以下のようになる。
    /PUSHROUTE:"172.31.0.0/255.255.0.0/192.168.30.1"

あとはがんばる

がんばって!💪

1

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