<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>サーバー | きんちゃんのブログ</title>
	<atom:link href="https://kinchan.com/category/server/feed/" rel="self" type="application/rss+xml" />
	<link>https://kinchan.com</link>
	<description>自分が読みたい記事を発信したい</description>
	<lastBuildDate>Sun, 30 Oct 2022 06:17:07 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://kinchan.com/wp-content/uploads/2022/09/cropped-929CC739-5B8C-4ED6-B5BB-B23AD78B9DA1-32x32.gif</url>
	<title>サーバー | きんちゃんのブログ</title>
	<link>https://kinchan.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>FreeBSD で db5 -&gt; db18 にしたお話</title>
		<link>https://kinchan.com/freebsd-db5-db18/</link>
					<comments>https://kinchan.com/freebsd-db5-db18/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Sun, 30 Oct 2022 06:17:05 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=198</guid>

					<description><![CDATA[FreeBSD で db5 -&#62; db18 にしたお話。 FreeBSD の daily security run output に と警告が出ていたのですが、その内 ports/UPDATING にアップデート方 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img decoding="async" width="200" height="80" src="https://kinchan.com/wp-content/uploads/2022/10/AC50281F-F5E5-4395-9986-D6A74466EA2D.png" alt="" class="wp-image-148"/></figure>



<p>FreeBSD で db5 -&gt; db18 にしたお話。</p>



<p>FreeBSD の daily security run output に</p>



<pre class="wp-block-code"><code>Checking for packages with security vulnerabilities:
Database fetched: Sun Oct 30 03:18:04 JST 2022
db5-5.3.28_8: Tag: expiration_date Value: 2022-06-30
db5-5.3.28_8: Tag: deprecated Value: EOLd, potential security issues, maybe use db18 instead</code></pre>



<p>と警告が出ていたのですが、その内 ports/UPDATING にアップデート方法が載るだろうとほったらかしにしていました。本日 UPDATING を見ても特に記載がないので自力で db18 に移行方法を調べました。<br>db5 の依存関係を調べると私の環境では</p>



<pre class="wp-block-code"><code>ruby30-bdb
cyrus-sasl2</code></pre>



<p>が依存している事が分かりました。<br>で、/etc/make.conf に</p>



<pre class="wp-block-code"><code>DEFAULT_VERSIONS+= bdb=18</code></pre>



<p>と記述して、試しに</p>



<pre class="wp-block-code"><code>cd /usr/ports/security/cyrus-sasl2
make deinstall reinstall clean</code></pre>



<p>したのですが db18 依存になってくれません。<br><a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261523">適当にググったら</a></p>



<pre class="wp-block-code"><code>DEFAULT_VERSIONS+= bdb=18
WITH_BDB6_PERMITTED=yes</code></pre>



<p>との情報があったので試すと db18 依存になってくれました。<br>両方を再 make した後</p>



<pre class="wp-block-code"><code>pkg delete db5</code></pre>



<p>すると db5 だけ削除できました。<br>めでたし、めでたしw</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/freebsd-db5-db18/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ED25519 の勧め</title>
		<link>https://kinchan.com/ed25519-rsa-encrypt/</link>
					<comments>https://kinchan.com/ed25519-rsa-encrypt/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Tue, 25 Oct 2022 23:35:54 +0000</pubDate>
				<category><![CDATA[インターネット]]></category>
		<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=195</guid>

					<description><![CDATA[ED25519 の勧め ssh で接続してサーバー管理をする。サーバー管理の現場ではごく一般的に行われている風景だが普通の人から見ると暗いディスプレイの中に文字が飛び交う、映画なんかで出てくるコンピュータを操る悪いハッカ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="800" height="463" src="https://kinchan.com/wp-content/uploads/2022/10/23078229-800x463.png" alt="" class="wp-image-196" srcset="https://kinchan.com/wp-content/uploads/2022/10/23078229-800x463.png 800w, https://kinchan.com/wp-content/uploads/2022/10/23078229-500x289.png 500w, https://kinchan.com/wp-content/uploads/2022/10/23078229-300x174.png 300w, https://kinchan.com/wp-content/uploads/2022/10/23078229-768x444.png 768w, https://kinchan.com/wp-content/uploads/2022/10/23078229-1536x889.png 1536w, https://kinchan.com/wp-content/uploads/2022/10/23078229-120x68.png 120w, https://kinchan.com/wp-content/uploads/2022/10/23078229.png 1901w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<h2 class="wp-block-heading">ED25519 の勧め</h2>



<p>ssh で接続してサーバー管理をする。サーバー管理の現場ではごく一般的に行われている風景だが普通の人から見ると暗いディスプレイの中に文字が飛び交う、映画なんかで出てくるコンピュータを操る悪いハッカーそのものだろう。w<br>ssh 接続するにはその経路を暗号化する為の暗号方式が必要だ。現在の主流は rsa 2048 bit と言う暗号方式で、現在の最速スーパーコンピュータを使用しても現実的な時間で解析出来ないとされている。暗号の性能を示す指標として暗号強度と言うものがあるがこれは暗号化するためのキーが何通りあるかで示される。rsa 2048 bit は 112 bit の暗号強度を持つが、これは 2 の 112 乗のキーがあると言う意味になる。そのうちのの一つが正解の暗号キーとなる訳で、暗号強度を高めるにはすぐ想像がつく様に bit 数を増やせば良いのだが bit 数を増やすと暗号化・復号化の時間が増えるため実用性の観点から無闇矢鱈に増やせば良いと言うものではなくバランスを取らなければならない。暗号化にはそのやり方、アルゴリズムも重要だ。rsa 方式は大きな数字の素因数分解に効率的な方法が無いため基本的に総当たりでしか暗号キーを見つける事ができない事を利用しているのだが、開発が進められている量子コンピュータを使用すると効率的な素因数分解解析アルゴリズムが発見されており、量子コンピュータが実用化されると rsa 暗号は破られてしまう危険性が指摘されていてアメリカの NIST と言う研究機関が 2031 年以降は rsa 2048 bit の使用を禁止する声明を出している。そんな事もあって rsa 方式に代わる暗号アルゴリズムが幾つか提案されている。そのうちのひとつに暗号強度は 128 bit さらに暗号キーの大きさが rsa より短く、暗号化・復号化の時間も大差ないエドワーズ曲線デジタル署名アルゴリズム(EdDSA)の ED25519 がある。つまり、ED25519 がサポートされていれば置き換えない理由はあなたのやる気だけなのだ。という訳で皆さん ED25519 を使いましょう。ではでは</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/ed25519-rsa-encrypt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeBSD の勧め</title>
		<link>https://kinchan.com/freebsd-recommendations/</link>
					<comments>https://kinchan.com/freebsd-recommendations/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Fri, 21 Oct 2022 04:43:53 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[つぶやき]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=151</guid>

					<description><![CDATA[私が初めて FreeBSD を触ったのは FreeBSD 2.0 からだ。wiki を見ると FreeBSD 2.0 のリリースは1994年11月22日となっているのでもう30年弱のお付き合いとなる。Linux と言うチ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img decoding="async" width="200" height="80" src="https://kinchan.com/wp-content/uploads/2022/10/AC50281F-F5E5-4395-9986-D6A74466EA2D.png" alt="" class="wp-image-148"/></figure>



<p>私が初めて <a href="https://www.freebsd.org/ja/">FreeBSD</a> を触ったのは FreeBSD 2.0 からだ。<a href="https://ja.m.wikipedia.org/wiki/FreeBSD">wiki</a> を見ると FreeBSD 2.0 のリリースは1994年11月22日となっているのでもう30年弱のお付き合いとなる。Linux と言うチョイスも有ったのだが、現在と同様に多数のディストリビューターがありそれに迷うのを避けたのと、Unix の正統派 BSD like のオープンソースな事がポッと出の Linux に比べてこちらを選ぶのが通と言う思い込みがあった。当時勤めていた会社には 64kbps の専用線が引かれていたのだが(64kbps でも月１０万円近くしていた様に記憶している) FreeBSD をダウンロードするのに一晩かかった事を覚えている。右も左も分からないままメールサーバーを立ち上げ、会社のドメインを取って運用したのだが大変苦労した。それ以降 Linux に1−2年浮気した以外は FreeBSD で自分のサーバーを運用している。その頃は Linux と FreeBSD はライバル関係と言っても語弊はなかったのだが、<a href="https://w3techs.com/technologies/details/os-freebsd">最近の調査結果</a> を見ると、Web サーバーにおいて Unix が80%余りだが、FreeBSD のシェアは 0.2% と余りに寂しい状況だ。対して <a href="https://w3techs.com/technologies/details/os-linux">Linux は</a> 37% と比較するのもおこがましいのが現実である。とは言うものの、Apple の Mac OS は FreeBSD を土台に作られていたり、Sony PS シリーズ、Yahoo のメインサーバー、さくらインターネットのレンタルサーバーなども FreeBSD だったりして決して Linux に劣ることのない性能を持っている。そんな FreeBSD の魅力を私の視線から述べるとすると</p>



<ul class="wp-block-list"><li>保守的だが高負荷時にも安定した動作性能</li><li>ports 管理による柔軟なアプリ管理</li><li>カーネルと OS 全体が一体となって開発されている(極端に言うと Linux はカーネルに各ディストリビューターが勝手に機能を付け加えて OS として成立させている)</li></ul>



<p>あたりだろうか。uptime が3000日を超えている FreeBSD を見た事があるが、実際30年近く FreeBSD を触ってきた感想として少々手荒な事をしても FreeBSD は安定した動作が期待できる信頼感がある。ソースからコンパイルする port によるアプリ管理は細かいオプション制御が出来て私は重宝している。ただ、 FreeBSD は GUI 周りの整備が Linux に比べると差がある様に見える。単なる CUI 制御のサーバー性能比較では Linux に劣らぬどころか一部は優っていると思うのだが、やはり GUI でポチポチやれるのは一般受けが良いんだろうと想像している。まぁ、私の推察が正しいのかどうかは置いておいて、現実はシェア的には Linux の圧倒的勝利と行っても良いだろう。でも、世の中必ずニッチな勢力に目を向けてくれる人もいる。そこのあなた、一度 FreeBSD を触ってみませんか？ Linux との文化の違いを垣間見るだけでも結構面白いですよ。と、つぶやいてみますw。ではでは</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/freebsd-recommendations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Cloudflare Turnstile の勧め</title>
		<link>https://kinchan.com/cloudflare-turnstile-recaptcha-captcha/</link>
					<comments>https://kinchan.com/cloudflare-turnstile-recaptcha-captcha/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Wed, 19 Oct 2022 05:42:34 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=176</guid>

					<description><![CDATA[目次 CAPTCHACloudflare Turnstile CAPTCHA CAPTCHA と言われてすぐにそれが何か分かる人はそう多く無いだろうが、上の「私はロボットではありません」やひん曲がったあるいはノイズの入っ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="800" height="222" src="https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51-800x222.jpeg" alt="" class="wp-image-172" srcset="https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51-800x222.jpeg 800w, https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51-500x139.jpeg 500w, https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51-300x83.jpeg 300w, https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51-768x213.jpeg 768w, https://kinchan.com/wp-content/uploads/2022/10/3F58AA3C-EE40-43BA-8B7B-236EBF5C3A51.jpeg 1156w" sizes="(max-width: 800px) 100vw, 800px" /></figure>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">CAPTCHA</a></li><li><a href="#toc2" tabindex="0">Cloudflare Turnstile</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">CAPTCHA</span></h2>



<p><a href="https://ja.wikipedia.org/wiki/CAPTCHA">CAPTCHA</a> と言われてすぐにそれが何か分かる人はそう多く無いだろうが、上の「私はロボットではありません」やひん曲がったあるいはノイズの入った文字列の入力、信号機や横断歩道、バスの入ったパネルをチェックするなど、入力しているのが人間である事を認証するシステムを見たことのある人は多いだろう。CAPTCHA が使われ始めた初期の頃はほんのちょっと斜めになっていればコンピュータ(bot)は認識できなかったのが、AI 機械学習の進歩によりどんどん読める様になってきて、その為文字の加工具合やノイズの量が増えてきて人間にも判読できないまでになってきているんだそうだ。私も信号機のパネルを選ぶ時、ほんのちょっとだけ引っ掛かっているのは含めるのか否か、消火栓を選べと言われても国によって消火栓の形状が様々だったりして何度も繰り返しチェックを受けさせられてイライラした事が何度もある。Cloudflare によると CAPTCHA 認証に平均32秒かかっていて世界的にみると毎日500年間分の時間が無駄に費やされているんだとか。で、まぁ普通の人にはここまでの知識を「ふーん」で終わりにして、ちょっとした知識の見せびらかしや酒のつまみにすればいいんだけど、Wordpress でブログやホームページをやっている人はコメントやお問い合わせフォームに bot から spam を投稿される事への対策をする必要がある。うんで wordpress には最初から<a href="https://ja.wordpress.org/plugins/akismet/">Akismet Spam Protection</a> と言う対策プラグインが入っていてとても評判が良いのだがこれ無料で使う条件に営利を伴うサイトでない、アフェリエイトリンクを張っていないなどがある。つまり営利目的が含まれる場合は有料なのだ。私はケチなのでそんなの払いたく無い。でも spam 対策はしなければならないので出てくるのは無料で使える Google の <a href="https://www.google.com/recaptcha/about/">reCAPTCHA</a>でこれには v2 と v3 があり、皆さんがよくご覧になるのは上に表示されている v2 の「私はロボットではありません」だ。v3 では出ない。無料、Google 謹製である事、認証の難易度が高く無い初期の頃は使い勝手が良かったなどがおそらく理由で、2022年10月の段階では相当のシェアを持ちあちこちで見かける。勿論、Worpress 様にも多数のプラグインが用意されていてよりどりみどりだ。<br>そこへ2022年9月末に発表されたのが</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="600" height="128" src="https://kinchan.com/wp-content/uploads/2022/10/1FA67EC6-6821-47E7-8B45-5B0BB8DF8BF7.gif" alt="" class="wp-image-174"/></figure>



<h2 class="wp-block-heading"><span id="toc2">Cloudflare Turnstile</span></h2>



<p><a href="https://www.cloudflare.com/ja-jp/products/turnstile/">Cloudflare Turnstile</a> で、CAPTCHA に代わる認証方式としている。先に述べた様に Cloudflare によると、現在の CAPTCHA は認証に平均32秒かかっているのが Turnstile では1秒になるとのこと。これでいままでと認証精度が変わらないのなら大進歩だ。そしてすでに WordPress のプラグインも用意されている。<a href="https://wordpress.org/plugins/wppool-turnstile-captcha-spam-filter/?utm_source=email&amp;utm_medium=button&amp;utm_campaign=ect">Easy Cloudflare Turnstile</a> がそれだ。私がお勧めするのだから勿論無料だ。<a href="https://www.cloudflare.com/ja-jp/lp/turnstile/">ここ</a>から手順に従ってkeyを取得すればあっという間に WordPress に実装できる。導入動画が有ったのでリンクを貼っておく。</p>



<p><a href="https://www.youtube.com/watch?v=2jU2LhkiQQU" data-type="URL" data-id="https://www.youtube.com/watch?v=2jU2LhkiQQU">Turnstile 導入動画</a></p>



<p>2022年9月末発表なので実績が全然足りないが、この私のブログに早速導入した。皆さんも如何ですか？<br>何らかの原因で Tuenstile に人間判定してもらえなくてログインできなくなることがあるらしい。w<br>そのときは</p>



<pre class="wp-block-code"><code>Keep on mind, that in case of emergency, you can disable this plugin via FTP access, just rename the plugin folder.</code></pre>



<p>の指示に従い wp-content/plugins/ 下にある wppool-turnstile-captcha-spam-filter をリネームすればプラグインが無効になるそうだ。万一の為に覚えておこう。<br>ではでは</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/cloudflare-turnstile-recaptcha-captcha/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>gmail に於ける spf と転送の問題解決</title>
		<link>https://kinchan.com/gmail-spf-pop3-postsrsd-srs/</link>
					<comments>https://kinchan.com/gmail-spf-pop3-postsrsd-srs/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Mon, 17 Oct 2022 01:31:55 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=165</guid>

					<description><![CDATA[gmail に於ける spf と転送の問題解決 独自ドメインのメール管理に gmail を使用しています。まず独自ドメイン用のメールサーバーを立ち上げます。普通このメールサーバーに対しメールクライアントでアクセスしますが [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="400" height="400" src="https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010.png" alt="" class="wp-image-44" srcset="https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010.png 400w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-300x300.png 300w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-100x100.png 100w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-150x150.png 150w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-200x200.png 200w" sizes="(max-width: 400px) 100vw, 400px" /></figure>



<p>gmail に於ける spf と転送の問題解決</p>



<p>独自ドメインのメール管理に gmail を使用しています。まず独自ドメイン用のメールサーバーを立ち上げます。普通このメールサーバーに対しメールクライアントでアクセスしますが、私の場合 gmail のインタフェース、機能を使ってメール管理・運用をしたいので、メールサーバーからgmail にメールを転送して読み書き、保存をして、メールを出す時は gmail からメールサーバーを経由、リレーしています。<br>なんでこんなことをしているかと言うと、gmail の優れた UI 、迷惑メールフィルタなどを使いたいからです。<br>ここで問題となるのが、単に転送するだけでは gmail で spf エラーが出る事です。その為、最初は gmail にメールを持ってくるのに pop3 を使っていたんですが、gmail の pop3 って最長1時間に1回位の頻度でしかチェックしてくれません。私同様これを不便と思う人がいる様で chrome の拡張機能で</p>



<ul class="wp-block-list"><li><a href="https://chrome.google.com/webstore/detail/gmail-pop3-auto-refresh/dcgondciahimhomfomnnpocjflglcppa">Gmail POP3 Auto Refresh</a></li><li><a href="https://chrome.google.com/webstore/detail/gmail-pop-sync/jcohkdgajeablpholinambjfpfkfjgdi">Gmail POP Sync</a></li></ul>



<p>などがあり、1分間隔でメールチェックをしてくれます。<br>が、これは gmail サーバーに負荷を与えますし、イリーガルな感が拭えません。下手するとアカウント ban されるかもしれません(まぁ、大丈夫だと思うけど)。なので、転送しても spf エラーにならない方法を調べてみると</p>



<ul class="wp-block-list"><li><a href="https://salt.iajapan.org/wpmu/anti_spam/admin/operation/suggestion/spf-sugg_a03/">SPFと転送の相性問題に対する解決策の紹介</a></li></ul>



<p>に大変参考になる記事が見つかりました。<br>ここに記述されている</p>



<ul class="wp-block-list"><li>単純方式（SPFと転送の相性問題に対する解決案の2つの方式）</li><li>SRS（Sender Rewriting Scheme）</li></ul>



<p>それぞれについて postfix での解決方法を記述しておく。<br>最初の解決方法は、Envelope from の書き換えで、postfix の main.cf に</p>



<pre class="wp-block-code"><code>sender_canonical_classes = envelope_sender
sender_canonical_maps = regexp:/usr/local/etc/postfix/sender_canonical</code></pre>



<p>を加えて、sender_canonical に正規表現で</p>



<pre class="wp-block-code"><code>/@(&#91;a-zA-Z0-9_+\-\.]+)$/ @example.net</code></pre>



<p>などと記述して転送サーバーが spf 対応しているドメインに書き換える事で問題を解決する。<br>但し、参照した記事にあるとおりエラーメールなどを本当の発信者に返すことが出来ない。</p>



<p>そこで2番目の登場となる。これは</p>



<ul class="wp-block-list"><li><a href="https://ja.wikipedia.org/wiki/センダー・リライティング・スキーム">センダー・リライティング・スキーム（Sender Rewriting Scheme,SRS)</a></li></ul>



<p>を使用した技術で、上の単に spf の認証が通るドメインに書き換えるのではなく、spf の認証を通り尚且つ元の差出人の情報も保持したまま転送できる。postfix 用に</p>



<ul class="wp-block-list"><li><a href="https://github.com/roehling/postsrsd">postsrsd</a></li></ul>



<p>が開発されており私もこれを使用している。ソースを github からダウンロードして make して出来た postsrsd を /usr/local/sbin などに install(make install すると default でここに入る) して<br>postfix の main.cf に</p>



<pre class="wp-block-code"><code>sender_canonical_maps = tcp:localhost:10001
sender_canonical_classes = envelope_sender
recipient_canonical_maps = tcp:localhost:10002
recipient_canonical_classes= envelope_recipient,header_recipient</code></pre>



<p>を追加して、postsrsd を</p>



<pre class="wp-block-code"><code>postsrsd -D -u mailnull -p /var/run/postsrsd/postsrsd.pid -d mail.example.com -s /usr/local/etc/postsrsd.secret -f 10001 -r 10002 -t 1800</code></pre>



<p>などとして起動。postfix も reload ないし再起動すれば</p>



<pre class="wp-block-code"><code>Oct 16 16:12:44 mail postsrsd&#91;54963]: srs_forward: &lt;example@example.com> rewritten as &lt;SRS0=rQK4=2R=example.com=example@example.net></code></pre>



<p>の様に example.com -&gt; example.net に元の情報を維持しつつ且つ spf 認証を通るアドレスに変換される様になる。以上、ご参考になると幸いです。ではでは</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/gmail-spf-pop3-postsrsd-srs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>postfix + spf-engine + opendmarc + opendkim</title>
		<link>https://kinchan.com/postfix-spf-engine-opendmarc-opendkim/</link>
					<comments>https://kinchan.com/postfix-spf-engine-opendmarc-opendkim/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Sat, 15 Oct 2022 02:48:48 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=152</guid>

					<description><![CDATA[postfix + spf-engine + opendmarc + opendkim 定番の組み合わせに spf-engine https://launchpad.net/spf-engine を追加しました。spf- [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="400" height="400" src="https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010.png" alt="" class="wp-image-44" srcset="https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010.png 400w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-300x300.png 300w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-100x100.png 100w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-150x150.png 150w, https://kinchan.com/wp-content/uploads/2022/09/1466EFCA-4609-4C84-8413-56416D37A010-200x200.png 200w" sizes="(max-width: 400px) 100vw, 400px" /></figure>



<p>postfix + spf-engine + opendmarc + opendkim</p>



<p>定番の組み合わせに spf-engine <a href="https://launchpad.net/spf-engine">https://launchpad.net/spf-engine</a> を追加しました。spf-engine は以前よく使われていた pypolicyd-spf(開発終了) の後継であり更に spfmilter の機能も引き継いで現在も開発が続けられている spf ユーティリティです。<br>dmarc は spf か dkim のどちらかの認証に成功するとメールを pass を返します。<br>逆に言うと、spf, dkim 両方の認証に失敗した時 fail を返し、メールの受信者は送信者の dmarc 設定を参照、参考にしてそのメールの処遇を決めます。<br>実際に認証の可否を受け持つのは　dkim については opendkim が、spf-engine が無い場合は spf については opendmarc が担当します。その場合、dmarc は spf の認証について成功か失敗の二つしか返しません。そこでspf の認証についてより細かく制御する為に、spf 認証ユーティリティとして spf-engine を追加します。<br>spf-engine 以外にも spf ユーティリティとして以下の物が見つかりましたが</p>



<p><a href="https://metacpan.org/release/Mail-SPF">p5-Mail-SPF</a><br><a href="https://launchpad.net/postfix-policyd-spf-perl/">postfix-policyd-spf-perl</a></p>



<p>spf-engine が最終更新が2022年2月と一番新しく現在も開発が続けられていて、またかつて広く使用されていた pypolicyd-spf の後継であることなどから2022年10月の段階では一番高機能で信頼できるユーティリティと私は判断しました。</p>



<p>spf 認証結果についておさらいしておきましょう。</p>



<figure class="wp-block-table"><table><thead><tr><th>認証結果</th><th>意味</th></tr></thead><tbody><tr><td>none</td><td>SPFレコードが無い</td></tr><tr><td>Neutral</td><td>?all にマッチした</td></tr><tr><td>Pass</td><td>SPF認証に成功</td></tr><tr><td>Fail</td><td>SPF認証に失敗</td></tr><tr><td>Softfail</td><td>~all にマッチした</td></tr><tr><td>TempError</td><td>一時的な障害で認証失敗</td></tr><tr><td>PermError</td><td>SPFレコードが不正</td></tr></tbody></table><figcaption>spf 認証結果</figcaption></figure>



<p>spf-engine の主なパラメータとして次の様な物があります。</p>



<ul class="wp-block-list"><li>HELO/EHLO コマンドから得た from 送信ドメインについて spf 認証</li></ul>



<pre class="wp-block-code"><code>#  HELO check rejection policy. Options are:
#  HELO_reject = SPF_Not_Pass (default) - Reject if result not Pass/None/Tempfail.
#  HELO_reject = Softfail - Reject if result Softfail and Fail
#  HELO_reject = Fail - Reject on HELO Fail
#  HELO_reject = Null - Only reject HELO Fail for Null sender (SPF Classic)
#  HELO_reject = False - Never reject/defer on HELO, append header only. 
#  HELO_reject = No_Check - Never check HELO.</code></pre>



<ul class="wp-block-list"><li>SMTP の MAIL FROM (envelope From)の spf 認証</li></ul>



<pre class="wp-block-code"><code>#  Mail From rejection policy.  Options are:
#  Mail_From_reject = SPF_Not_Pass - Reject if result not Pass/None/Tempfail.
#  Mail_From_reject = Softfail - Reject if result Softfail and Fail
#  Mail_From_reject = Fail - Reject on Mail From Fail (default)
#  Mail_From_reject = False - Never reject/defer on Mail From, append header only
#  Mail_From_reject = No_Check - Never check Mail From/Return Path.</code></pre>



<ul class="wp-block-list"><li>spf レコードが不正の場合</li></ul>



<pre class="wp-block-code"><code>#  Policy for rejecting due to SPF PermError.  Options are:
#  PermError_reject = True
#  PermError_reject = False</code></pre>



<ul class="wp-block-list"><li>spf レコードが一時的に不正(dns サーバーが落ちているとかかな？)</li></ul>



<pre class="wp-block-code"><code>#  Policy for deferring messages due to SPF TempError.  Options are:
#  TempError_Defer = True
#  TempError_Defer = False</code></pre>



<p>その他、特定のドメインで Netural/Softfail が出た場合とか FQDN や IP アドレスでのホワイト・ブラックリストなど、dmarc では出来ない細かな spf 認証についての処理が出来ます。<br>実はよく使い方が分からない、理解出来ないパラメータもあります。w<br>自分のサーバーですので、万一正しいメールを弾いてしまっても自己責任と言う事で色々実験中ですのでその内おすすめ設定をアップできる様に頑張っている最中です。生暖かい目でご期待ください。<br>ではでは</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/postfix-spf-engine-opendmarc-opendkim/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>FreeBSD certbot error ImportError: cannot import name &#8216;x509&#8217; from &#8216;cryptography.hazmat.bindings._rust&#8217; (unknown location)</title>
		<link>https://kinchan.com/certbot-freebsd-error-cryptography/</link>
					<comments>https://kinchan.com/certbot-freebsd-error-cryptography/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Tue, 11 Oct 2022 00:36:44 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=131</guid>

					<description><![CDATA[FreeBSD certbot error ImportError: cannot import name &#8216;x509&#8217; from &#8216;cryptography.hazmat.bindi [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="400" height="160" src="https://kinchan.com/wp-content/uploads/2022/10/E98B4384-8E2B-4E71-BCCC-6F7C01DA460A.png" alt="" class="wp-image-149" srcset="https://kinchan.com/wp-content/uploads/2022/10/E98B4384-8E2B-4E71-BCCC-6F7C01DA460A.png 400w, https://kinchan.com/wp-content/uploads/2022/10/E98B4384-8E2B-4E71-BCCC-6F7C01DA460A-300x120.png 300w" sizes="(max-width: 400px) 100vw, 400px" /></figure>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>FreeBSD certbot error ImportError: cannot import name &#8216;x509&#8217; from &#8216;cryptography.hazmat.bindings._rust&#8217; (unknown location)</p></blockquote>



<p>FreeBSD で、2022/10/10 頃にアップデートされた py39-cryptography-38.0.1 が原因で certbot が動かなくなっています。一つ前の py39-cryptography-3.4.8 に戻せば動きます。<br>38.0.1 を削除してpkg install py39-cryptography とかすれば3.4.8 に戻せます。<br>portdowngrade-1.7 を使うのも良いでしょう。3.4.8 に戻したら取り敢えず</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>pkg lock py39-cryptography</p></blockquote>



<p>としておくのが吉かもしれない。</p>



<p><a href="https://community.letsencrypt.org/t/importerror-cannot-import-name-x509-from-cryptography-hazmat-bindings-rust/185882">Let&#8217;s encryptのコミュニティ</a></p>



<p>や</p>



<p><a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266937">FreeBSD のバグレポート</a></p>



<p>で既に論議されているので近い内に修正されると思われますが、毎日 cron で certbot renew している人もいるでしょうから情報として共有しておきます。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/certbot-freebsd-error-cryptography/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Conoha VPS 最大75％引きキャンペーンが熱い</title>
		<link>https://kinchan.com/conoha-vps-campaign-xserver/</link>
					<comments>https://kinchan.com/conoha-vps-campaign-xserver/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Mon, 10 Oct 2022 02:30:26 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=125</guid>

					<description><![CDATA[Conoha VPS が2022年11月7日迄の期間限定で最大75%引きのキャンペーンを開催しています。これはお得です。普段は最大23%割引だから割引率が大幅に上がっている。75%引きになるのは VPS割引きっぷ 36ヶ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p></p>


<p><a rel="nofollow" href="https://px.a8.net/svt/ejp?a8mat=3NH6K1+2HWH4I+50+4Z79DD"><br><img loading="lazy" decoding="async" src="https://www24.a8.net/svt/bgt?aid=220831345151&amp;wid=001&amp;eno=01&amp;mid=s00000000018030099000&amp;mc=1" alt="" width="336" height="280" border="0"></a><br><img loading="lazy" decoding="async" src="https://www16.a8.net/0.gif?a8mat=3NH6K1+2HWH4I+50+4Z79DD" alt="" width="1" height="1" border="0"></p>
<p>Conoha VPS が2022年11月7日迄の期間限定で最大75%引きのキャンペーンを開催しています。これはお得です。普段は最大23%割引だから割引率が大幅に上がっている。<br>75%引きになるのは VPS割引きっぷ 36ヶ月契約の</p>
<p>&#8211; 3 CPU 2GBRAM 100GBSSD の通常、月 1,848 円が 460 円<br>&#8211; 4 CPU 4GBRAM 100GBSSD の通常、月 3,608 円が 879 円</p>
<p>の場合だ。36ヶ月分の先払いが必要だが、思わずグラっとくる人も多いのでは無いだろうか？<br>36ヶ月契約でなくても良い。VPS割引きっぷ 3ヶ月契約でも</p>
<p>&#8211; 3 CPU 2GBRAM 100GBSSD の通常、月 1,848 円が 660 円<br>&#8211; 4 CPU 4GBRAM 100GBSSD の通常、月 3,608 円が 1,190 円</p>
<p>になる。1ヶ月しか使わなくても、3 CPU の場合は 660 x 3 = 1,980 円なので、通常の 1,848 円に 132 円上乗せすれば3ヶ月使える。4CPU に至っては 1,190 x 3 = 3,570 円だから3ヶ月契約をした方が安い事になる。</p>
<p>何故、こんな大盤振る舞いをしているのか。<br>これは想像なのだが、レンタルサーバー大手のエックスサーバーが 2922年9月に VPS に参入してきた事が影響しているのではないかと私は考えている。<a href="https://vps.xserver.ne.jp/">Xserver VPS </a>をご覧になるとわかるが、Xserver VPS はリリース記念キャンペーンをやっていてその価格が今回の&nbsp;Conoha VPS の割引価格と実に酷似している。つまり、Conoha がエックスサーバーに喧嘩をふっかけたのではないかと言うのが私の妄想ですw。<br>本当の理由は闇の中ですがユーザーにとっては嬉しい競争で、VPS を今使っている人も、これから使おうと思っている人も注目です。<br>私は 3CPU 2GB プランを来月11月の頭に契約するつもりです。みなさんも如何ですか？<br>なお、ここのバナーを経由して契約すると７００円のクーポンがプレゼントされますので宜しければお使いください。<br>ではでは</p>
<p><a rel="nofollow" href="https://px.a8.net/svt/ejp?a8mat=3NH6K1+2HWH4I+50+4Z79DD"><br>
<img loading="lazy" decoding="async" border="0" width="336" height="280" alt="" src="https://www27.a8.net/svt/bgt?aid=220831345151&amp;wid=001&amp;eno=01&amp;mid=s00000000018030099000&amp;mc=1"></a><br>
<img loading="lazy" decoding="async" border="0" width="1" height="1" src="https://www18.a8.net/0.gif?a8mat=3NH6K1+2HWH4I+50+4Z79DD" alt=""></p>]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/conoha-vps-campaign-xserver/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress のバックアップ・復元・移転を完璧に行うには</title>
		<link>https://kinchan.com/wordpress-backup-restore-migration-perfect/</link>
					<comments>https://kinchan.com/wordpress-backup-restore-migration-perfect/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Fri, 07 Oct 2022 04:36:19 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=111</guid>

					<description><![CDATA[WordPress でブログを始めて1週間もしないうちにサーバー移転すると言う無計画さに自分でも呆れています。バックアップを取って移転先に復元すれば良いんだろう？有名どころのバックアッププラグインがあるから簡単なんじゃ無 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><img loading="lazy" decoding="async" width="150" height="150" class="wp-image-113" style="width: 150px;" src="https://kinchan.com/wp-content/uploads/2022/10/20F16AAC-E2A9-4B2C-A6E1-055938DEF0A2.png" alt="" srcset="https://kinchan.com/wp-content/uploads/2022/10/20F16AAC-E2A9-4B2C-A6E1-055938DEF0A2.png 400w, https://kinchan.com/wp-content/uploads/2022/10/20F16AAC-E2A9-4B2C-A6E1-055938DEF0A2-300x300.png 300w, https://kinchan.com/wp-content/uploads/2022/10/20F16AAC-E2A9-4B2C-A6E1-055938DEF0A2-100x100.png 100w, https://kinchan.com/wp-content/uploads/2022/10/20F16AAC-E2A9-4B2C-A6E1-055938DEF0A2-150x150.png 150w" sizes="(max-width: 150px) 100vw, 150px" /></p>



<p>WordPress でブログを始めて1週間もしないうちにサーバー移転すると言う無計画さに自分でも呆れています。<br>バックアップを取って移転先に復元すれば良いんだろう？有名どころのバックアッププラグインがあるから簡単なんじゃ無いの？と思っていたんですが、それは元と移転先が同じURLを使う場合でした。<br>つまり、example.com で動いていた wordpress を移転先でも example.com で運用する場合ですね。これだと本当に updraftplus や all in one WP Migration などのダウンロード数が数百万のバックアップ、復元プラグインであまり考える事なく作業すれば良いです。私の場合もこうだったので updraftplus を使う事で何も悩む事無くサーバー移転は終了しました。<br>ここで辞めておけば幸せだったのですが、移行先のURLが違う場合、つまり example.com -&gt; example.net みたいな場合もついでに練習しておこうと思ったのが運の尽き。データベースの中にある example.com を example.net に変換しなければならないんですが、単純に置換すれば良い訳では無く色々と面倒くさい事が分かりました。<br>取り敢えず本家のマニュアル<a href="https://ja.wordpress.org/support/article/moving-wordpress/">WordPress の移行</a>を読む。<br>ここには3つのやり方が書いてあります。</p>



<ol class="wp-block-list"><li>移行した後、ダッシュボードにアクセス出来るならプラグインを使う。</li><li>コマンドラインで WordPress を制御できる wp-cli と言うツールを使う。<a href="https://make.wordpress.org/cli/2017/04/03/new-co-maintainer-alain-thanks-2017-sponsors/">wp-cliはwordpress公式</a>のツール。</li><li><a href="https://github.com/interconnectit/Search-Replace-DB">Search Replace DB</a>と言うツールを使う。</li></ol>



<p>ここで書いてある1のプラグインや3のツールは最終更新が2020年と最近は更新されていないし、wordpress 公式でも無い。2の wp-cli は wordpress 公式で現在も開発が続けられていることからこの中では一番信用できるツールではないかと私は推測しています。<br>次に先に書いた、all in one wp migration にはバックアップ時にデータベース内容の置換機能が付属している。migration と名乗っている事からURL変換を主な目的としているのだろうし、現在も頻繁に更新されていることからこちらも信用してよさそう。</p>



<p>と言う訳でどれ、実際にやってみようと結局は20回近くバックアップ復元の実験をした。<br>結果、私の結論としては次の二つが私の見る限り正常にバックアップ・復元(URL変更する)出来ており、今後自分が使用しようと思えるものであった。</p>



<p>まず、最初に URL 変換がない場合は</p>



<ol class="wp-block-list"><li>バックアップを取る。プラグインの updraftplus か all in one wp migration が良いだろう。</li><li>移転先で wordpress の初期セットアップを行い、どちらかのプラグインを導入して復元すればお終いである。場合によっては wp-config.php のデータベース名やユーザー名、パスワードの修正が必要かもしれない。</li></ol>



<p>まぁ、誰でもできる作業だと思う。問題は URL が変わる時だ。<br>私の最初のお勧めは updraftplus でバックアップして、そのまま移転先に復元してから wp-cli で</p>



<pre class="wp-block-code"><code>wp search-replace 'https://example.com' 'https://example.net'</code></pre>



<p>する事である。</p>



<p>2番目は、all in one wp migration でバックアップする時データベースの内容を置換してくれる機能を利用する方法だ。その後、移転先で復元すれば良い。これは wp-cli と言う ssh 接続してコマンドを叩くと言う知らない人が見たらハッカーもどきの作業に比べれば難易度は格段に低いから普通の人にはこちらがお勧めだと思う。</p>



<p>なお、all in one wp migrastion はファイルの容量が 512MB を超えると有料版が必要になるが、こいつでバックアップするのはデータベースだけにしておけば、私の例だが10記事で2MB 行かないくらいだったので大雑把に3000記事位までは大丈夫と思われ、事実上無制限に近い。他のはどうするんだって？移転先で all in one wp migration が動く最小限の構成で立ち上げ、rsync で元からどさっとコピーしておいてからリストアすれば良い。</p>



<p>ちょっと普通の人には難しいかもしれないけど普段 ssh でやっている人には簡単だと思う。<br>1日朝から晩までバックアップ・復元実験に費やしたがこれで wordpress 引っ越しを頼まれても多分できると思われる。<br>ではでは</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/wordpress-backup-restore-migration-perfect/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Postfix お勧め基本設定</title>
		<link>https://kinchan.com/postfix-setting/</link>
					<comments>https://kinchan.com/postfix-setting/#respond</comments>
		
		<dc:creator><![CDATA[kinchan]]></dc:creator>
		<pubDate>Wed, 05 Oct 2022 03:48:11 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<guid isPermaLink="false">https://kinchan.com/?p=96</guid>

					<description><![CDATA[目次 Postfixmain.cfmaster.cf 必要部分のみ Postfix ここ3日ほど、サーバー移転であれやこれやもがいていました。どうやら、目安が立ったところで前からやろうと思っていた各種設定の整理整頓を始め [&#8230;]]]></description>
										<content:encoded><![CDATA[<p></p><p><img loading="lazy" decoding="async" width="130" height="91" class="alignnone size-full wp-image-22" src="https://kinchan.com/wp-content/uploads/2022/09/C942D97B-2388-4162-B79F-A85ED3747428.png" alt=""></p>
<p></p>



  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-20" checked><label class="toc-title" for="toc-checkbox-20">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Postfix</a><ol><li><a href="#toc2" tabindex="0">main.cf</a></li><li><a href="#toc3" tabindex="0">master.cf 必要部分のみ</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Postfix</span></h2>



<p>ここ3日ほど、サーバー移転であれやこれやもがいていました。<br>どうやら、目安が立ったところで前からやろうと思っていた各種設定の整理整頓を始めます。<br>例えば Postfix。メールの送受信出来れば良かったのに、relay するから sasl 設定して、自己証明書で ssl して、SPF, dkim, dmarc も追加、let&#8217;s encrypt も入れて、ついでに spam 対策もやろうとかやっているうちにmain.cf がぐちゃぐちゃになってしまい、なんかちゃんと動いているからまぁ良いや、、、そのうちちゃんと綺麗に書き直そう、、、現在に至ると言うのが現状です。<br>今回のサーバー移転では移転先の環境を1からやったので　いやがおうにも(いやがうえにもが正しい言い方らしいw)整理する羽目になったのでした。って偉そうに言うほどのものでも無いけど、何をやっているかコメントを沢山入れたものをつくったので、恥ずかしげも無く公開する。<br>ちなみに私は Postfix の experimental release と言うそのまま直訳すると開発・実験版を使用している。<br>そんなもん、怖くて使えないって人も居るだろうが、中の人が言うには<a href="http://mirror.postfix.jp/postfix-release/index.html">&#8220;it runs on all of Wietse&#8217;s systems so it is production quality.&#8221;</a> 作者の Wietse さんシステムで動いていて、「製品品質」との事なのでと今までの経験上特にトラブルになったことも無いので結構安心して使っている。もしよろしければ皆様もどうぞ。</p>



<p>今回は let&#8217;s encrypt で証明書を取得済みを前提としている。また、今回は postfix の部分のみ、後日 opendkim, opendmarc, dovecot を別稿で追加するのでご了承頂きたい。</p>



<p>では私の main.cf と master.cf を次に。ご参考になったら幸いです。<br>では、今日はこの辺で失礼します。</p>



<h3 class="wp-block-heading"><span id="toc2">main.cf</span></h3>



<pre class="wp-block-code"><code>compatibility_level=3.8

# 信用するのはこのサーバーだけ mynetworks を設定すると無効になるので注意
# デフォルトだが書いておく
mynetworks_style = host

# 世界とメールのやりとりが出来る様に
inet_interfaces = all

# alias の在処
alias_database = hash:/etc/mail/aliases
alias_maps = hash:/etc/mail/aliases

# コマンド追加
allow_mail_to_commands = alias,forward,include

# myorigin はこのサーバから出るメールはなんと名乗るか。@の後の事
mydomain = example.com
myhostname = www.example.com
myorigin = example.com

# @の後がどんなメールだったら受け取るか
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

# メールの配送形式
home_mailbox = Maildir/

# デフォルトは postfix を使っている事を返すので分からない様にする
# 規約では bannerの最初は$myhostnameを記載しなければいけないので従う
smtpd_banner = $myhostname ESMTP

# メールアカウントチェック対策
# ユーザー存在確認されても答えない。
disable_vrfy_command = yes

# 接続後の挨拶（HELO）を強制
smtpd_helo_required = yes

# 誤作動防止とETRNコマンドも制限しておく
smtpd_delay_reject = yes
smtpd_etrn_restrictions =
        permit_mynetworks
        reject

# 自分の送信メールのヘッダからローカルIPを消す
header_checks= regexp:/usr/local/etc/postfix/header_checks
always_add_missing_headers = yes

# RCPT TO及びMAIL FROMで正しい文法を強制
strict_rfc821_envelopes = yes

# スパムの踏み台を防止（デフォルト）
allow_untrusted_routing = no

# 前もってコマンドを送ってくる無礼なやつは拒否！
smtpd_data_restrictions = 
    reject_unauth_pipelining

# 宛先不明は /dev/null
# デフォルトはそんな宛先無いよと言う返事を返すけど知らんぷりする。
# 管理者の意向次第だがこれを利用したスパムもある様なので私はこれで良いと思っている。
# 但し、typo したメール差出人は送ったのになーとなる事だけは覚えておこう。
local_recipient_maps =
luser_relay = unknown_user@localhost

# HELOコマンド受信時のホスト名による受信制限
# DNS に登録されていない、FQDNが解決できない、ホスト名の文法が不正の場合に拒否
smtpd_helo_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    reject_unknown_hostname
    reject_non_fqdn_hostname
    reject_invalid_hostname
    permit

# ドメインが解決できない、FQDNが解決できない場合に拒否
smtpd_sender_restrictions = 
    permit_mynetworks
    reject_unknown_sender_domain
    reject_non_fqdn_sender

# smtpd_recipient_restrictions = は古い書式
# ver2.10以降この記述でリレーの抜け穴を防止する
smtpd_relay_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    defer_unauth_destination

# sasl 認証
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $mydomain

# cyrus の場合はこちら
smtpd_sasl_type = cyrus
smtpd_sasl_path = smtpd

# dovecot の場合はこちら
#smtpd_sasl_type = dovecot
#smtpd_sasl_path = private/auth

# SMTP 配送のTLS 設定
smtp_tls_CAfile = /usr/local/etc/ssl/cert.pem
smtp_tls_key_file = /usr/local/etc/letsencrypt/live/example.com/privkey.pem
smtp_tls_cert_file = /usr/local/etc/letsencrypt/live/example.com/fullchain.pem
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtp_tls_protocols = &gt;=TLSv1.2
smtp_tls_mandatory_protocols = &gt;=TLSv1.2

# SMTP 受信のTLS 設定
smtpd_tls_CAfile = /usr/local/etc/ssl/cert.pem
smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_tls_key_file = /usr/local/etc/letsencrypt/live/example.com/privkey.pem
smtpd_tls_cert_file = /usr/local/etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_protocols = &gt;=TLSv1.2
smtpd_tls_mandatory_protocols = &gt;=TLSv1.2
smtpd_tls_mandatory_ciphers = medium

# 以下の暗号形式については mozilla さんにお任せ
# curl https://ssl-config.mozilla.org/ffdhe2048.txt &gt; /path/to/dhparam.pem
# not actually 1024 bits, this applies to all DHE &gt;= 1024 bits
smtpd_tls_dh1024_param_file = /usr/local/etc/postfix/dhparam.pem

tls_medium_cipherlist = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
tls_preempt_cipherlist = no


# opendkim と opendmarc
smtpd_milters =
        unix:/var/run/milteropendkim/milteropendkim.sock
        unix:/var/run/opendmarc/opendmarc.sock
non_smtpd_milters =
        unix:/var/run/milteropendkim/milteropendkim.sock
        unix:/var/run/opendmarc/opendmarc.sock</code></pre>



<h3 class="wp-block-heading"><span id="toc3">master.cf 必要部分のみ</span></h3>



<pre class="wp-block-code"><code>#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
# Choose one: enable submission for loopback clients only, or for any client.
#127.0.0.1:submission inet n -   n       -       -       smtpd
submission inet n       -       n       -       -       smtpd
#  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_tls_auth_only=yes
#  -o smtpd_reject_unlisted_recipient=no
#     Instead of specifying complex smtpd_&lt;xxx&gt;_restrictions here,
#     specify "smtpd_&lt;xxx&gt;_restrictions=$mua_&lt;xxx&gt;_restrictions"
#     here, and specify mua_&lt;xxx&gt;_restrictions in main.cf (where
#     "&lt;xxx&gt;" is "client", "helo", "sender", "relay", or "recipient").
#  -o smtpd_client_restrictions=
#  -o smtpd_helo_restrictions=
#  -o smtpd_sender_restrictions=
#  -o smtpd_relay_restrictions=
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://kinchan.com/postfix-setting/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
