OpenVPNクライアント設定(iphone)

iOSから接続できるOpenVPNサーバーは仮想NICドライバとしてTUNデバイスを使用し

ている必要がある。

 

設定ファイル

 拡張子は、iphone.ovpn である必要がある。

 必要なファイルは、

  ca.crt client1.crt client1.key ta.key

 の4つ。

 

iphone.ovpn の編集箇所↓

 

以下4つはコメントアウト

#ca ca.crt

#cert client.crt

#key client.key

#tls-auth ta.key

 

<ca> ←ca.crt(追記)
-----BEGIN CERTIFICATE-----
・・・
-----END CERTIFICATE-----
</ca>

 

<cert> ←client1.crt(追記)
-----BEGIN CERTIFICATE-----
・・・
-----END CERTIFICATE-----
</cert>

 

<key> ←client1.key(追記)
-----BEGIN PRIVATE KEY-----
・・・

-----END PRIVATE KEY-----
</key>

 

key-direction 1 ←追記

<tls-auth> ←ta.key(追記)
-----BEGIN OpenVPN Static key V1-----
・・・
-----END OpenVPN Static key V1-----
</tls-auth>

 

iphone側では、openvpnのアプリをインストールする。

VPNサーバとiphoneを有線で接続して、アプリの中に設定ファイルを挿入する。

 

参考サイト

iPhoneやiPad (iOS) でOpenVPNを使ってみよう! | OpenVPN.JP

OpenVPNサーバの構築

VPNの種類

  • インターネットVPN

  ・使用技術

    IPsec-VPN:セキュリティプロトコルIPsecを使用。

              SSL-VPN   :セキュリティプロトコルSSLを使用。

  ・接続タイプ

    サイト間VPN

      VPN機能を実装したルータ同士を接続する。

      VPNの実装(パケットの暗号化、復号、カプセル化、非カプセル化)

      を全てルータで行う。

      クライアント(PC、サーバetc)には、専用のソフトウェアはいらない。

    リモートアクセスVPN

      VPN機能を実装したルータとVPNクライアントソフトを

      インストールしたPCを接続する。

      クライアント側(PC、サーバetc)には、専用のソフトウェアがいる。

  ・使用技術

    MPLS-VPN:通信事業者のプライベートIP網内で

            経路情報の探索にMPLSを採用したVPNのこと。

 

 

 

OpenVPNサーバの構築

 

 リモートアクセスVPN技術を使用したOpenVPNサーバを構築する。

 

 インストール

[root@centos8-test ~]# dnf install -y openvpn easy-rsa net-tools

 

 サーバ認証局、証明書などを作成

[root@centos8-test ~]# ll /usr/share/easy-rsa
合計 0
lrwxrwxrwx. 1 root root 5 3月 31 22:04 3 -> 3.0.7
lrwxrwxrwx. 1 root root 5 3月 31 22:04 3.0 -> 3.0.7
drwxr-xr-x. 3 root root 66 6月 18 19:47 3.0.7
[root@centos8-test ~]# cd /usr/share/easy-rsa
[root@centos8-test easy-rsa]# ll
合計 0
lrwxrwxrwx. 1 root root 5 3月 31 22:04 3 -> 3.0.7
lrwxrwxrwx. 1 root root 5 3月 31 22:04 3.0 -> 3.0.7
drwxr-xr-x. 3 root root 66 6月 18 19:47 3.0.7
[root@centos8-test easy-rsa]# cd 3

 

 初期化

[root@centos8-test 3]# ./easyrsa init-pki

 

 認証局の作成(青色の部分は自由に決める)

[root@centos8-test 3]# ./easyrsa build-ca
Using SSL: openssl OpenSSL 1.1.1c FIPS 28 May 2019

Enter New CA Key Passphrase:〇〇〇
Re-Enter New CA Key Passphrase:〇〇〇
Generating RSA private key, 2048 bit long modulus (2 primes)
.........................+++++
.............+++++
e is 65537 (0x010001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:centos8

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
/usr/share/easy-rsa/3/pki/ca.crt

 

 サーバ証明書作成([server1]の部分は任意。証明書のファイル名になる。)

[root@centos8-test 3]# ./easyrsa build-server-full server1 nopass

Using SSL: openssl OpenSSL 1.1.1c FIPS 28 May 2019
Generating a RSA private key
........................+++++
......................+++++
writing new private key to '/usr/share/easy-rsa/3/pki/easy-rsa-2014.7aTQ0X/tmp.VZ9Mf8'
-----
Using configuration from /usr/share/easy-rsa/3/pki/easy-rsa-2014.7aTQ0X/tmp.tMJ7RF

認証局作成時のパス
Enter pass phrase for /usr/share/easy-rsa/3/pki/private/ca.key:〇〇〇
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'server1'
Certificate is to be certified until Sep 21 12:52:13 2022 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

 

 クライアント証明書作成([client1]の部分は任意。証明書のファイル名になる。)

[root@centos8-test 3]# ./easyrsa build-client-full client1 nopass
Using SSL: openssl OpenSSL 1.1.1c FIPS 28 May 2019
Generating a RSA private key
............................................................+++++
......................................................................................+++++
writing new private key to '/usr/share/easy-rsa/3/pki/easy-rsa-2103.GT2DK4/tmp.cdLx4o'
-----
Using configuration from /usr/share/easy-rsa/3/pki/easy-rsa-2103.GT2DK4/tmp.pFk3id

認証局作成時のパス
Enter pass phrase for /usr/share/easy-rsa/3/pki/private/ca.key:〇〇〇
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'client1'
Certificate is to be certified until Sep 21 12:56:19 2022 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

 

 Diffie Hellman(DH)パラメーター生成

[root@centos8-test 3]# ./easyrsa gen-dh
Using SSL: openssl OpenSSL 1.1.1c FIPS 28 May 2019
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
.......+...........................................................................................................................................................................

DH parameters of size 2048 created at /usr/share/easy-rsa/3/pki/dh.pem

 

 TLS-Authキー作成

[root@centos8-test 3]# openvpn --genkey --secret ./pki/ta.key

 

 生成したファイル等をコピー

[root@centos8-test 3]# cp -pR /usr/share/easyrsa/3/pki/{issued,private,ca.crt,dh.pem,ta.key}

/etc/openvpn/server/

 

 

 IPフォワードを有効化

[root@centos8-test 3]# vi /etc/sysctl.d/10-ipv4_forward.conf

追記

net.ipv4.ip_forward = 1

 

[root@centos8-test 3]# sysctl --system

 

 OpenVPNサーバの設定ファイルの編集&起動

1.サンプルの設定ファイルをコピー

[root@centos8-test ~]# cp

/usr/share/doc/openvpn/sample/sample-config-files/server.conf

/etc/openvpn/server/

 

2.サーバ設定ファイルの編集

[root@centos8-test server]# vi server.conf

port 1194

proto udp

dev tun

ca ca.crt
cert issued/server1.crt
key private/server1.key

dh dh.pem

server 10.0.0.0 255.255.255.0 //VPNで使用するNWの指定

push "route 192.168.1.0 255.255.255.0" //自NWの指定

client-to-client //クライアント間通信の設定

tls-auth ta.key 0

comp-lzo

status /var/log/openvpn-status.log

log /var/log/openvpn.log
log-append /var/log/openvpn.log

 

3.OpenVPNの起動

[root@centos8-test server]# systemctl start openvpn-server@server

[root@centos8-test server]# systemctl enable openvpn-server@server

 

4.firewalldの設定

[root@centos8-test server]# firewall-cmd --add-port=1194/udp --permanent

[root@centos8-test server]# firewall-cmd --reload

 

 クライアント側で必要な設定ファイル

・ca.key

・ta.key

・client1.crt

・client1.key

centos8に便利な外部リポジトリを追加する

[root@centos8-test ~]# dnf install -y epel-release

 

[root@centos8-test ~]# vi /etc/yum.repos.d/epel.repo

 [epel]
  name=Extra Packages for Enterprise Linux $releasever -

  $basearch

  #baseurl=https://download.fedoraproject.org/

  pub/epel/$releasever/Everything/

  $basearchmetalink=https://mirrors.fedoraproject.org/

  metalink?repo=epel-$releasever&arch=$basearch&infra=

  $infra&content=$contentdir
  enabled=1
  priority=10 ←追加
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

 

[root@centos8-test ~]# vi /etc/yum.repos.d/elrepo.repo

 [elrepo]
  name=ELRepo.org Community Enterprise Linux Repository - el8
  baseurl=http://elrepo.org/linux/elrepo/el8/$basearch/
  http://mirrors.coreix.net/elrepo/elrepo/el8/$basearch/
  http://jur-linux.org/download/elrepo/elrepo/el8/$basearch/
  http://repos.lax-noc.com/elrepo/elrepo/el8/$basearch/
  mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el8
  enabled=1
  priority=10 ←追加
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
  protect=0

 

[root@centos8-test ~]# dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

 

[root@centos8-test ~]# vi /etc/yum.repos.d/remi-safe.repo

 [remi-safe]
  name=Safe Remi's RPM repository for Enterprise Linux 8 - $basearch
  #baseurl=http://rpms.remirepo.net/enterprise/8/safe/$basearch/
  #mirrorlist=https://rpms.remirepo.net/enterprise/8/safe/$basearch/httpsmirror
  mirrorlist=http://cdn.remirepo.net/enterprise/8/safe/$basearch/mirror
  enabled=1
  priority=10 ←追加
  gpgcheck=1
  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8

 

参考サイト

CentOS 8 : 初期設定 : リポジトリを追加する : Server World

centos8にsambaをインストール・設定

[root@centos8-test ~]# dnf install -y samba

 

dnfコマンドを使ってパッケージをインストール

 

 sambaの設定ファイルの編集

 (sambaの設定ファイルは /etc/samba/smb.conf)

 

[root@centos8-test ~]# vi /etc/samba/smb.conf

 

 [global]
  workgroup = WORKGROUP
  security = user


  map to guest = bad user

  printing = cups
  printcap name = cups
  load printers = yes
  cups options = raw

 
  unix charset = UTF-8
  dos charset = CP932

 

 [share]
  #共有フォルダの場所
  path = /home/share
  #マイネットワークに表示の有無
  browseable = yes
  #書き込み許可
  writable = yes
  #ゲストユーザのログイン許可
  guest ok = yes
  #読込みの許可
  read only = no

 

samba設定ファイル編集後、

共有フォルダを作成

[root@centos8-test ~]# mkdir /home/share

 

作成したフォルダのアクセス権を変更

[root@centos8-test ~]# chmod -R 0777 /home/share

 

作成したフォルダのユーザー:グループを変更

[root@centos8-test ~]# chown nobody:nobody /home/share

 

SELinuxの無効化 ※しない方がいい。

[root@centos8-test ~]# setenforce 0

 

firewallを有効にしている場合は、サービスの追加

[root@centos8-test ~]# firewall-cmd --add-service=samba --permanent

[root@centos8-test ~]# firewall-cmd --reload

 

windows側で確認

エクスプローラーで[\\centos8のipアドレス]で検索

f:id:Tryota:20200617223629p:plain

 

centos8インストール時の画面サイズ変更

centos8インストール時に画面サイズが強制的に変更される現象があったため、
備忘録として記事を書きます。

virtualbox使用

ダウンロードサイトからosを拾ってくる。

Download CentOS

 

virtualboxインスタンス作成し、実行。

 

この時に、tabキーを押す。

すると、編集モードに移行するので、

"resolution=〇〇×〇" として

画面サイズを変更する。

 

※ "=" → "^" 

  "×" → "x(アルファベットのエックス)"

 

f:id:Tryota:20200617215028p:plain