AlmaLinux 9 仮想マシンに構築したSamba ファイル共有 サーバが、Windowsクライアントから見つけてもらいやすくするべく、Linux版 WS-Discovery ツール wsdd を導入してみました。
いきさつ
Windows 10のある時期以降、SMBv1がデフォルトでは無効になったことに伴い、従来のNetBIOS Discoveryも使えなくなりました。
Windowsな世界では、SSDPやWS-Discovery( UDP3702 番ポートを使う 239.255.255.250 宛ブロードキャスト)によってネットワーク上の機器を見つける仕組みがあるのですが、Linuxで構築したファイル共有サーバが見つけてもらうには、こちらのLinux向けWS-Discoveryツール、 wsdd を自分でインストールする必要があります。
そこで、前回までにQNAP TVS-EC880のVirtualization Station上に構築した、AlmaLinux 9仮想マシンにインストールして、LAN内のWindowsクライアントからサーバ上のファイル共有を見つけてもらえるようにします。
1 2 3 4 5 6 |
# uname -a Linux fxsrv.local 5.14.0-70.17.1.el9_0.x86_64 #1 SMP PREEMPT Tue Jun 28 14:55:40 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux # rpm -q almalinux-release almalinux-release-9.0-4.el9.x86_64 # cat /etc/almalinux-release AlmaLinux release 9.0 (Emerald Puma) |
EPEL有効もwsddパッケージ見つからず
wsdd はEPELレポジトリに収録されているとのことなので、まずは epel-release パッケージをインストールして、EPELを有効にします。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# dnf install epel-release Last metadata expiration check: 0:01:11 ago on Mon 25 Jul 2022 12:27:12 PM HKT. Dependencies resolved. ======================================================================================================================= Package Architecture Version Repository Size ======================================================================================================================= Installing: epel-release noarch 9-2.el9 extras 17 k Transaction Summary ======================================================================================================================= Install 1 Package Total download size: 17 k Installed size: 23 k Is this ok [y/N]: y Downloading Packages: epel-release-9-2.el9.noarch.rpm 92 kB/s | 17 kB 00:00 ----------------------------------------------------------------------------------------------------------------------- Total 14 kB/s | 17 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : epel-release-9-2.el9.noarch 1/1 Running scriptlet: epel-release-9-2.el9.noarch 1/1 Verifying : epel-release-9-2.el9.noarch 1/1 Installed: epel-release-9-2.el9.noarch Complete! |
早速パッケージリストを更新してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# dnf update Extra Packages for Enterprise Linux 9 - x86_64 141 kB/s | 8.6 MB 01:02 Last metadata expiration check: 0:00:03 ago on Mon 25 Jul 2022 12:30:15 PM HKT. Dependencies resolved. ======================================================================================================================= Package Architecture Version Repository Size ======================================================================================================================= Upgrading: epel-release noarch 9-3.el9 epel 18 k Transaction Summary ======================================================================================================================= Upgrade 1 Package Total download size: 18 k Is this ok [y/N]: y Downloading Packages: epel-release-9-3.el9.noarch.rpm 50 kB/s | 18 kB 00:00 ----------------------------------------------------------------------------------------------------------------------- Total 12 kB/s | 18 kB 00:01 Extra Packages for Enterprise Linux 9 - x86_64 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x3228467C: Userid : "Fedora (epel9) <epel@fedoraproject.org>" Fingerprint: FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9 Is this ok [y/N]: y Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : epel-release-9-3.el9.noarch 1/2 Running scriptlet: epel-release-9-3.el9.noarch 1/2 Cleanup : epel-release-9-2.el9.noarch 2/2 Running scriptlet: epel-release-9-2.el9.noarch 2/2 Verifying : epel-release-9-3.el9.noarch 1/2 Verifying : epel-release-9-2.el9.noarch 2/2 Upgraded: epel-release-9-3.el9.noarch Complete! |
これで wsdd をインストールしようとするも、ヒットしません。
1 2 3 4 5 |
# dnf install wsdd No match for argument: wsdd Error: Unable to find a match: wsdd # dnf search wsdd No matches found. |
AlmaLinux 8系では、 dnf からパッケージインストールしている例がネット上で散見されるので、AlmaLinux 9特有の問題なのかも知れません。
wsdd公式に沿いマニュアルインストール
公式GitHubのGeneric Installation Instructions項を読むと、インストールと言っても単に、Pythonで記述された wsdd.py をダウンロードしてしかるべき場所へ配置すれば動くようなので、まずはダウンロード。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# wget https://github.com/christgau/wsdd/raw/master/src/wsdd.py --2022-07-25 14:26:18-- https://github.com/christgau/wsdd/raw/master/src/wsdd.py Resolving github.com (github.com)... 20.205.243.166 Connecting to github.com (github.com)|20.205.243.166|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://raw.githubusercontent.com/christgau/wsdd/master/src/wsdd.py [following] --2022-07-25 14:26:19-- https://raw.githubusercontent.com/christgau/wsdd/master/src/wsdd.py Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 70814 (69K) [text/plain] Saving to: ‘wsdd.py’ wsdd.py 100%[================================================>] 69.15K --.-KB/s in 0.003s 2022-07-25 14:26:20 (20.3 MB/s) - ‘wsdd.py’ saved [70814/70814] |
ダウンロードしたスクリプト wsdd.py に実行権限を付与し、 /usr/local/bin/ へ拡張子抜きの wsdd とリネームしつつ移動します。
1 2 3 4 |
# chmod +x ./wsdd.py # mv ./wsdd.py /usr/local/bin/wsdd # ls -l /usr/local/bin -rwxr-xr-x 1 root root 70814 Jul 25 14:26 wsdd |
サービスとして登録
wsdd をサービスとして登録するのに必要なファイルもひな型がGitHubにあるので、これを /etc/systemd/system/ へダウンロードします。
1 2 3 4 5 6 7 8 9 10 11 |
# cd /etc/systemd/system/ # wget https://raw.githubusercontent.com/christgau/wsdd/master/etc/systemd/wsdd.service --2022-07-25 14:42:37-- https://raw.githubusercontent.com/christgau/wsdd/master/etc/systemd/wsdd.service Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 824 [text/plain] Saving to: ‘wsdd.service’ wsdd.service 100%[================================================>] 824 --.-KB/s in 0s 2022-07-25 14:42:37 (55.0 MB/s) - ‘wsdd.service’ saved [824/824] # chmod +x wsdd.service |
wsdd の配置場所や起動時のドメイン文字列( WORKGROUP )を環境に合わせて、以下のように編集しました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[Unit] Description=Web Services Dynamic Discovery host daemon Documentation=man:wsdd(8) ; Start after the network has been configured After=network-online.target Wants=network-online.target ; It makes sense to have Samba running when wsdd starts, but is not required. ; Thus, the next to lines are disabled and use BindsTo only. ; One may also add any of these services to After for stronger binding. ;BindsTo=smb.service ;BindsTo=samba.service ConditionPathExists=/usr/local/bin [Service] Type=simple ;EnvironmentFile=/etc/default/wsdd ; The service is put into an empty runtime directory chroot, ; i.e. the runtime directory which usually resides under /run ExecStart=/usr/local/bin/wsdd --shortlog --chroot=/run/wsdd $WSDD_PARAMS -d WORKGROUP ExecStop=/usr/bin/kill -p $MAINPID DynamicUser=yes User=wsdd Group=wsdd RuntimeDirectory=wsdd AmbientCapabilities=CAP_SYS_CHROOT [Install] WantedBy=multi-user.target |
サービスを有効化して起動します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# systemctl enable --now wsdd Created symlink /etc/systemd/system/multi-user.target.wants/wsdd.service → /etc/systemd/system/wsdd.service. # systemctl status wsdd ● wsdd.service - Web Services Dynamic Discovery host daemon Loaded: loaded (/etc/systemd/system/wsdd.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2022-07-17 11:18:28 HKT; 2s ago Docs: man:wsdd(8) Main PID: 10652 (python3) Tasks: 1 (limit: 5908) Memory: 16.5M CPU: 106ms CGroup: /system.slice/wsdd.service └─10652 python3 /usr/local/bin/wsdd --shortlog --chroot=/run/wsdd -d WORKGROUP Jul 17 11:18:28 fxsrv.local systemd[1]: Started Web Services Dynamic Discovery host daemon. Jul 17 11:18:28 fxsrv.local wsdd[10652]: WARNING: no interface given, using all interfaces |
Windowsから効果確認
WS-Discoveryが有効になったことで、他のWindowsマシンから、エクスプローラのネットワーク検索において検出してもらえるようになりました。