2021年11月28日日曜日

D-STAR ゲートウェイをRaspberry Piで構築

Back


最近ではRasberry Piの性能は向上し、充分にD-STARリピータのゲートウェイPCとしての機能を果たせる位置に来ました。

そこで、CentOS版PCに続いてRaspberry Pi用 Pi OS版のゲートウェイソフト群が開発されました。今回はそのインストール手順について記載したいと思います。

尚、今回のrpi-dsgwdはICOM社製ではなくJARL D-STAR委員会製のゲートウェイサービスソフトウェアです。

  • rpi-dsgwd、rpi-xchange rpi-dprs rpi-dstatus rpi-multi-forward rpi-decho は安田OM(7M3TJZ)/ JARL D-STAR委員会の著作物です。 インストール及び設定に関する実務についてのみ今後の参考のために記載します。また手順に変更があれば随時、変更・追加致します。(公開 2022.04.01)
  • CentOS版のEcho Server開発に伴い名称が"decho"となりました。(最終更新 2022.05.05
  • 新ゲートウェイシステム・フローチャートはこちら ➡ TODO Virtual Center
  • この記事に関するご意見・お問い合わせはこちらへお願いします。  ➡ D*Star Network FORUM


=MEMO= D-STAR委員会とAuthor安田OMの許可を得て、当方が JL3ZBS A でテスト中のものを元に手順化しプレ公開いたしました。 DPRSの機能など一部確認中の機能もありますが、CentOSも数年後に廃止になることも有り、今から代替用としてテストしてみてはいかがでしょうか。 あくまでD-STAR委員会としては未発表ですので、JARLへの問い合わせはできませんのでよろしくお願い致します。

準備する物

  • Raspberry Pi 4B
  • 現在テストサイトではRaspberry Pi 3Bでテスト中ですが、dmonitorでの接続が集中すると性能不足になるかも知れません。
    このキット等も便利と思います。Pi4 B 4GB スターター キット V4 オンライン教材付

  • USBタイプLANアダプタ
  • Raspberry PiにはWiFiがインプリメントされていますので、工夫すればWiFi(wlan0)とLAN(eth0)で構築する事も可能とは思いますが、 ここでは、USBタイプLANアダプタを使用して、eth0とeth1で構成します。

  • microSDカード16GB~


  • 専用ACアダプター
  • Rasberry Pi 4 はかなりの電圧・電流を必要とします。少なくとも5V強/3A程度はないと常に「電圧不足です」のメッセージが表示されます。


PiOSのインストールと事前設定

  1. microSDにPi OSイメージを焼く


  2. =MEMO= 現時点では、Raspberry Pi3/4 のみ対象ですが実務的にはPi4をお薦めします。 なお、PiOSは64bit版のみ対応です。 又、リモートでのルータ設定などを想定してデスクトップ簡易版を使用しています。

    Raspberry PiOSサイトより右図のイメージライタをダウンロードしインストールします。
    CHOOE OS]で推奨(デスクトップのみ入っている)版 PiOSを選択、[CHOOSE STORAGE]でmicroSDカードのドライブを選択して開始すればダウンロードしながら書き込んでくれます。

  3. SSHが使用できるようmicroSDに細工します。

  4. Windowsマシンに挿したままmicroSDのドライブを開きます。[新規作成(X)]で[テキスト ドキュメント]を選択し、 内容は何も書かずファイル名を拡張子も含めて「ssh」(つまり拡張子無し)のファイルを作ります。 これで、Raspberry Piを立ち上げた時、すぐにSSHが利用可能です。


    =MEMO=
    同様にして、D-STAR委員会のパッケージでは、このドライブ内に有るフォルダ rpi-GW 内に各種設定ファイル(xx.conf)がインストールされますので、 前もって編集又はバックアップファイルを貼り付ける事が出来ます。(編集は後述)




PiOS立ち上げ時の各種設定

  1. 電源投入直後の初期設定

  2. Welcome to the Raspberry Pi Desktop!

    Before you start using it, there are a few thingw to set up.

    Press 'Next' to get started.

    If you are using a Bluetooth keyboard or mouse, put them into
    pairing mode and wait for them to connect.

    IP: 192.168.11.10


    Next

    この作業ではRasberry Piに接続したディスプレイが必要です。 ディスプレイが無い場合や、SSHで接続した場合などは次項の「セキュリティを高める作業」をご参照ください。
    Set County

    Enter the details of your location. This is used to set the
    language, time zone, keyboard and other international settings.
     Japan
    Country:
     Japanese
    Languge:
     Tokyo
    Timezone:
    ☐Use english languge  ☐Use US keyboard


    Press 'Next' when you have made your selection.



    Next
    Back


    通常、図のとおり日本のロケイルを選択します。もしJISではなくASCII(US)キーボードを使用している場合は[Use US keyboard]にチェックしてください。
    Create User

    You need to create a user account to log in to your Raspberry
    Pi.

    The username can only contain lower-case letters, digits and
    hyphens, and must start with a letter
    Enter username:
    Enter password:
    Confirm password:
    ☑Hide characters


    Press 'Next' to create your account.

    Next
    Back


    今まで標準であった piとraspberry のような想像しやすいものは避けてください。使用できる文字は英子文字、数字とハイフンのみで、必ず英子文字から開始してください。
    また、チェックを外すとパスワードが表示されます。

    ここで、アカウントを設定しない限り、SSH設定を/bootファルダにしても、他のマシンからは接続できないようです。
    Set Up Screen

    On some monitors, the desktop is larger than the screen and
    the edges are cut off. You can adjust this here.
    Reduce the size of the desktop on this monitor

    Press 'Next' when the screen looks correct.









    Next
    Back


    デスクトップの方が、モニターのサイズより大きく、端がカットされていると思われる場合はスライドスイッチを右へ動かし手見てください。 戻せば元どおりの表示に戻ります。
    Select your WiFi network from the list

    On some monitors, the desktop is larger than the screen and
    the edges are cut off. You can adjust this here
    Press 'Next' when the screen looks correct.

    Next
    Skip
    Back


    この枠内に、WiFiの一覧が表示されます。設定するときは希望の一行をクリックして[Next]とするのですが、今回はケーブル接続のみで構築していますので[Skip]してください。
    Update Software

    The operation system and applications will now be cheched
    and updated if necessary. This may involve a large download.

    Press 'Next' to check and update software, or 'Skip' to continue
    without checking.








    Next
    Skip
    Back


    [Next]をクリックするとアップデートが実行されます。立ち上げ後通常どおり apt update; apt upgrade する場合は[Skip]してください。
    Setup Complete

    Your Raspberry Pi is now et up and ready to go.


    Press 'Restart' to restart your Pi so the new settings will take
    effect.





    Restart
    Back


    リスタートすると設定した環境が反映されて立ちあがります。


  3. セキュリティを高める作業


  4. =MEMO= 64ビット版のPiOSイメージは下記のような設定を、前もって問い合わせに答える形でセットアップされます。
    立ち上げ後で変更したりするときにご利用ください。⇨ 「環境設定」へスキップ

    =MEMO= ログインID(pi)、パスワード(Raspberry)共に全く違う物に変更することを強くお勧めします。方法については こちら⇨ をご参照ください。


    $ sudo raspi-config
    

    先ずパスワードの変更をしてください。

    ┌─────┤ Raspberry Pi Software Configuration Tool (raspi-config)├────┐
    │                                                                              │
    │       1 System Options       Configure system settings                       │
    │       2 Display Options      Configure display settings                      │
    │       3 Interface Options    Configure connections to peripherals            │
    │       4 Performance Options  Configure performance settings                  │
    │       5 Localisation Options Configure language and regional settings        │
    │       6 Advanced Options     Configure advanced settings                     │
    │       8 Update               Update this tool to the latest version          │
    │       9 About raspi-config   Information about this configuration tool       │
    │                                                                              │
    │                                                                              │
    │                <Select>                          <Finish>                    │
    │                                                                              │
    └───────────────────────────────────────┘
    
    <Select>,<Finish>を[Tab]で選択するか[Enter]で選択[Esc]で戻る

    パスワード変更を[S3]で終えたら、ユーザログインが必要になるよう設定する為[S5]を選択して次の画面に進んでください。

    ┌─────┤ Raspberry Pi Software Configuration Tool (raspi-config)├────┐
    │                                                                              │
    │       S1 Wireless LAN      Enter SSID and passphrase                         │
    │       S2 Audio             Select audio out through HDMI or 3.5mm jack       │
    │       S3 Password          Change password for the 'pi' user                 │
    │       S4 Hostname          Set name for this computer on a network           │
    │       S5 Boot / Auto Login Select boot into desktop or to command line       │
    │       S6 Network at Boot   Select wait for network connection on boot        │
    │       S7 Splash Screen     Choose graphical splash screen or text boot       │
    │       S8 Power LED         Set behaviour of power LED                        │
    │                                                                              │
    │                                                                              │
    │                <Select>                          <Finish>                    │
    │                                                                              │
    └───────────────────────────────────────┘
    

    ┌─────┤ Raspberry Pi Software Configuration Tool (raspi-config)├────┐
    │                                                                              │
    │     B1 Console           Text console, requiring user to login               │
    │     B2 Console Autologin Text console, automatically logged in as 'pi' user  │
    │     B3 Desktop           Desktop GUI, requiring user to login                │
    │     B4 Desktop Autologin Desktop GUI, automatically logged in as 'pi' user   │
    │                                                                              │
    │                                                                              │
    │                <Select>                          <Finish>                    │
    │                                                                              │
    └───────────────────────────────────────┘
    
    デスクトップを最初からインストールしていないPiOSを使って居る場合は[B1]を選択します。


  5. メモリー領域の拡張

  6. 6番の拡張オプションよりmicroSDカードの領域を最大限に拡げます。
    ┌─────┤ Raspberry Pi Software Configuration Tool (raspi-config)├────┐
    │                                                                              │
    │       1 System Options       Configure system settings                       │
    │       2 Display Options      Configure display settings                      │
    │       3 Interface Options    Configure connections to peripherals            │
    │       4 Performance Options  Configure performance settings                  │
    │       5 Localisation Options Configure language and regional settings        │
    │       6 Advanced Options     Configure advanced settings                     │
    │       8 Update               Update this tool to the latest version          │
    │       9 About raspi-config   Information about this configuration tool       │
    │                                                                              │
    │                                                                              │
    │                <Select>                          <Finish>                    │
    │                                                                              │
    └───────────────────────────────────────┘
    

    ┌─────┤ Raspberry Pi Software Configuration Tool (raspi-config)├────┐
    │                                                                              │
    │    A1 Expand Filesystem       Ensures that all of the SD card is available   │
    │    A2 GL Driver               Enable/disable experimental desktop GL driver  │
    │    A3 Compositor              Enable/disable xcompmgr composition manager    │
    │    A4 Network Interface Names Enable/disable predictable network i/f names   │
    │    A5 Network Proxy Settings  Configure network proxy settings               │
    │    A8 Glamor                  Enable/Disable glamor graphics acceleration    │
    │    A9 Wayland                 Enable experimental Wayland backend            │
    │                                                                              │
    │                                                                              │
    │                                                                              │
    │                <Select>                          <Finish>                    │
    │                                                                              │
    └───────────────────────────────────────┘
    

    最後に<Finish>を選択した後(各設定の途中でも・・)、「再起動しますか?」のメッセージが出たら[OK]してください。

    拡張されたかの確認は次のコマンドで可能です。

    $ df -h
    



環境設定

  1. ホスト名の変更

  2. $ sudo su -
    

    スーパーユーザ(管理者)になります。

    # nano /etc/hosts
    # nano /etc/hostname
    

    いずれのファイルもraspberryになっている部分をdstargwなど分かりやすいホスト名に変更してください。その他は(改行なども含めて)一切変更しないでください。


  3. SSHで使用するポートを変更する
  4. # nano /etc/ssh/sshd_config
    
      GNU nano 5.4                 /etc/ssh/sshd_config
      :
    #Port 22
       ↓
    Port 22222
    

    コメントアウトを外し、ポート番号を変更する(22222は一例)


  5. VNCで管理する場合の画面サイズを設定して置く

  6. # nano /boot/config.txt
    
      GNU nano 5.4                 /boot/config.txt
    # uncomment to force a console size. By default it will be display's size minus
    # overscan.
    framebuffer_width=1280
    framebuffer_height=960
    

    1280x720 1280x1024 1600x1200 など見やすいサイズに指定しておきます。

  7. IPアドレスを指定された固定アドレスに設定します。

  8. # nano /etc/dhcpcd.conf
    
      GNU nano 5.4                 /etc/dhcpcd.conf
        :
        :  
    ### eth0(Internet側) eth1(Controler側)のIPアドレス指定
    interface eth0
    static ip_address=10.0.xx.xx/8			#指定された固定アドレス
    static routers=10.0.yy.yy			#ルータのLAN側アドレス
    static domain_name_servers=10.0.yy.yy		#ルータのLAN側アドレス
      
    interface eth1
    static ip_address=172.16.0.20/24		#Gatewayやname serverは不要
      

  9. 最後にPiOSの更新を行って再起動します。

  10. # apt update && apt upgrade -y
    # reboot
    


アプリケーションのインストール


=MEMO= 最新版のリポジトリーでは、この項で述べるインストールに関して自動で実行するコマンドラインが公開されています。 今回の64ビット版からエコーサーバーが標準装備されました。
 $ sudo curl http://app.d-star.info/debian/bullseye64/rpi-GW/gw_setup | bash
このコマンドを実行した方は、3.各アプリケーションの環境設定へスキップしてください。

  1. aptインストールできるようにリポジトリを構成

  2. $ cd /etc/apt/sources.list.d
    $ sudo wget http://app.d-star.info/debian/bullseye64/rpi-GW/jarl-GW.list
    
    $ cd /var/tmp
    $ sudo wget http://app.d-star.info/debian/bullseye64/rpi-GW/jarl-pkg.key
    $ sudo apt-key add jarl-pkg.key
    $ cd
    

    この時、すでにjarl-GW.listが存在すると wgetする度に、jarl-GW(1).list, jarl-GW(2).list・・・のように上書きしないようにダウンロードされるので、 最新の状態にするためには jarl-GW.listのすべてのバージョンを削除して新たにダウンロードするか、番号の大きい物をjarl-GW.listにリネームしてください。


  3. インストールの実行

  4. $ sudo apt clean
    $ sudo apt update
    $ sudo apt install -y rpi-dsgwd rpi-dprs rpi-xchange rpi-dstatus rpi-multi-forward rpi-decho
    


  5. 各アプリケーションの環境設定

  6. $  sudo nano /boot/rpi-GW/rpi-dsgwd.conf
    
      GNU nano 5.4                 /boot/rpi-GW/rpi-dsgwd.conf
    #
    # rpi-dsgwd.conf
    # Configuration file for D-STAR GW-Server Daemon
    # (C) 2021 JARL D-STAR Committee Satoshi Yasuda, 7m3tjz
    #
    
    # --- Setting the following two parameters is mandatory. ---
    # Zone Repeater's Infomation
    ZR_CALLSIGN=[Repeater Callsign(モジュールA,B無し)]
    ZR_ADDR=127.0.0.1
    
    # --- Caution! Use the following parameters as they are. ---
    # --- Only when you need any customization,              ---
    # ---        please change the following parameters.     ---
    # Zone Repeater's Infomation
    ZR_PORT=20011
    ZR_SRCPORT=20100
    GW_ZRPORT=20010
    
    ZR_ETHIFNAME=lo
    
    # DNS Server
    DNS_ADDR=8.8.8.8                #グーグル汎用DNS. 本来はDEFAULT_GWと同じ10.0.x.x
                                    #ですがネットワーク環境が変わっても訂正の必要が有りません。
    
    # GateWay
    GW_ETHIFNAME=eth0
    DEFAULT_GW=10.0.x.x             #ルータのLAN側アドレスです。
    #GW_LOGINT=300
    GW_VCPORT=40000
    #GW_VCSRCPORT=40002
    GW_DTPORT=40001
    #GW_ZRPORT=20000
    
    # Kanri Server
    MGSV_ADDR=trust.d-star.info
    #MGSV_ADDR=d-prs01.d-star.info
    MGSV_PORT=30001
    MGSV_LOGADDR=trust.d-star.info
    MGSV_LOGPORT=30000
    
    # GW connection
    #CON_WAIT_INTERVAL=2
    #CON_REFRESH_INTERVAL=1
    #CON_MAX_GW=50
    
    # LOG Infomation
    LOG_GWREG=1
    LOG_INVOICE=1
    LOG_INDATA=1
    LOG_OUTVOICE=1
    LOG_OUTDATA=1
    LOG_OUTNET=1
    LOG_GWVOICE=1
    LOG_GWDATA=1
    LOG_USERERR=1
    LOG_HOLEPCH=1
    LOG_SOCKET=1
    
    # END dsgwd.conf
    

    $ sudo nano /boot/rpi-GW/rpi-xchange.conf
    

    xchangeとdprsにおけるリピータコールとモジュール名は指定不要になりました。

    また、これ以降の設定の内容でUPNP=0と有るのは、uPnPの機能は使用せず、手動でポートフォワードしているという意味です。 uPnPを使用する場合は、手動でのポートフォワードはせず、ルータのuPnPを有効にしてUPNP=1としてください。
      GNU nano 5.4                 /boot/rpi-GW/rpi-xchange.conf
    #
    #       Version V02.00 or later
    #       Satoshi Yasuda
    #       12 Aug. 2018
    #
    DEBUG=3
    ZR_NIC=eth1
    ZR_ADDR=172.16.0.1
    ZR_IN_PORT=20000
    ZR_OUT_PORT=20000
    GW_IN_PORT=20011
    GW_OUT_PORT=20010
    GW_NIC=lo
    MON_PORT=21000
    GW_ADDR=127.0.0.1
    
    FORWARD=127.0.0.1:50000:dprs
    FORWARD=127.0.0.1:50001:dstatus
    FORWARD=127.0.0.1:50002:multi_forward
    FORWARD=127.0.0.1:50003:decho
    
    HTTP_PORT=20201
    UPNP=0
    

    $  sudo nano /boot/rpi-GW/rpi-dprs.conf
    
      GNU nano 5.4                 /boot/rpi-GW/rpi-dprs.conf
    #
    #       Version V00.79 or later
    #       Satoshi Yasuda
    #       20 Aug. 2018
    #
    APRS_SERVER=d-prs.d-star.info:14580
    #APRS_SERVER=d-prs.d-star.info:8080:SUBMIT
    RADIO_ID=D
    SEND_INTERVAL=60
    AUTO_RELINK=1
    RETRY_COUNT=0
    BEACON_LAT=35.xxxx                 #リピータの緯度・経度を小数点表示で
    BEACON_LONG=136.xxxx
    BEACON_COMMENT=D-STAR -> APRS
    BEACON_INTERVAL=0
    #TRUST_SERVER=133.130.72.162:30001
    DEBUG=1
    MON_PORT=50000
    ACCEPT_TYPE=MIX
    

    $ sudo nano /boot/rpi-GW/rpi-dstatus.conf
    
      GNU nano 5.4                 /boot/rpi-GW/rpi-dstatus.conf
    #
    #       Version V00.79 or later
    #       Satoshi Yasuda
    #       10 Oct. 2015
    #
    DEBUG=1
    MON_PORT=50001
    STATUS=status.d-star.info:21050
    

    $ sudo nano /boot/rpi-GW/rpi-multi_forward.conf
    
      GNU nano 5.4                 /boot/rpi-GW/rpi-multi_forward.conf
    #
    #       Version V00.79 or later
    #       Satoshi Yasuda
    #       10 Oct. 2015
    #
    FORWARD_PORT=50002
    MULTI_CONNECT_PORT=51000
    STATUS=status.d-star.info:21051
    

    $ sudo nano /boot/rpi-GW/rpi-decho.conf
    
      GNU nano 5.4                 /boot/rpi-GW/rpi-decho.conf
    #
    #       Version V00.01 or later
    #       Satoshi Yasuda
    #       2022/04/29
    #
    FORWARD_PORT=50003
    ECHO_SERVER=JL3ZBS A:JL3ZBS Z  #各リピータコールサインに変更してください。
    ECHO_POSITION_SEND_INTERVAL=600
    
    
    エコーサーバのZについてはシステムで使用しているSGなどを使用しないでください。

    ログファイルに関する設定

    dsgwd.log に関しては出力に関して少し設定が必要です。

    $ sudo nano /etc/rsyslog.conf
    
      GNU nano 5.4                 /etc/rsyslog.conf
          :
         :  末尾に追加  
    #
    # rpi-dsgwd.log
    #
    local0.*					/var/log/rpi-dsgwd.log
    
    $ sudo touch /var/log/rpi-dsgwd.log
    

    最初はログファイルが存在しないので、空のファイルを作成して書き込み準備をします。

    他のログファイルは、設定無しで /var/log 内に書き出されます。

    それぞれのプログラムを自動起動に設定

    すべてのプログラムを自動起動に設定し、一度リブートします。
    $ sudo systemctl enable rpi-dsgwd.service rpi-xchange.service rpi-dprs.service rpi-dstatus.service rpi-multi_forward.service rpi-decho.service
    $ sudo reboot
    

    再度立ち上がったら、次のコマンドで起動しているか確認します。起動していないものは表示されません。
    $ ps aux | grep rpi
    
    これで、すべての設定が完了しました。 しばらくすると、Hole Punch Listに表示されれば運用可能となります。

    Back




    73
    J E 3 H C Z / TODO@REF047C XLX047B

0 件のコメント:

コメントを投稿