SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
【Linux】#8 Mail
1
アジェンダ
0900~0905 今日出来るようになる事、自己紹介(チーム紹介)
システム構成説明
0905~0915 サーバへの疎通確認
0915~0930 Postfixインストール
0930~0945 Postfix初期設定
0945~1000 Dovecotインストール
1000~1015 メール受信テスト
1015~1030 メール送信テスト
参加いただきありがとうございます!!!
鈴木メモ
持ち物:スイッチ×4、PC×4、LAN線×8、
シリアルケーブル×4
今日出来るようになる事
メールサーバを構築できる
2
今日の流れ
1.環境確認
2.Postfixインストール
3.
4.
5.
これから実施
3
PC1
192.168.210.11
PC2
192.168.210.12
PC3
192.168.210.13
PC4
192.168.210.14
【Linux】#8 Mail構成図
DNSサーバ
192.168.210.195
Server1
192.168.210.111
Server2
192.168.210.112
Server3
192.168.210.113
Server4
192.168.210.114
4
【Linux】#8 Mail 設計一覧
1 2 3 4
PC 192.168.210.11 192.168.210.12 192.168.210.13 192.168.210.14
Server CentOS 192.168.210.111 192.168.210.112 192.168.210.113 192.168.210.114
ホスト名 Linux8-Mail1 Linux8-Mail2 Linux8-Mail3 Linux8-Mail4
Domain melonpan.udx.local anpan.udx.local currypan.udx.local croissant.udx.local
ユーザ名 connpassアカウント
(suzukito)
connpassアカウント connpassアカウント connpassアカウント
パスワード Me1onpan# Me1onpan# Me1onpan# Me1onpan#
5 【Linux】#8 PC1→メールサーバ1→DNS→メールサーバ2(送受信)
PC1
192.168.210.11
PC2
192.168.210.12
メール送信
送信元:pc1@melonpan.udx.local
宛先 :pc2@anpan.udx.local
server1(melonpan)
192.168.210.111
SMTP
server2(anpan)
192.168.210.112
送信OK
IMAP
メール確認
pc2@anpan.udx.local
にメールある?
DNS
anpan.udx.local ってどこ
IPアドレスを教えて!
「192.168.210.112」!!
SMTP
anpan.udx.local にメール送信
6
今日の流れ
1.環境確認
2.Postfixインストール
3.
4.
5.
これから実施
インターネット未接続環境でのdnf
 ソフトウェアのインストールにはCentOS8のパッケージ管理ソフトウェアである「dnf」を使用していきますが、デフォルトではインターネットからソフトウェアを取得す
ることになります。
 ここではインストールメディアからソフトウェアを取得する設定を行います。
 インストールメディアのISOイメージをCDROMドライブにセットしてあります。
7
手順9
[root@suzukto ~]# mkdir␣/media/CentOS
[root@suzukto ~]# mount␣–o␣ro␣/dev/cdrom␣/media/CentOS/
[root@suzukto ~]# alias␣dnf=‘dnf␣--disablerepo=¥*␣--enablerepo=c8-media-BaseOS,c8-media-AppStream’
手順10 確認
[root@suzukto ~]# df
ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置
devtmpfs 905304 0 905304 0% /dev
tmpfs 934792 0 934792 0% /dev/shm
tmpfs 934792 9832 924960 2% /run
tmpfs 934792 0 934792 0% /sys/fs/cgroup
/dev/mapper/cl-root 13420544 4243772 9176772 32% /
/dev/sda2 999320 191708 738800 21% /boot
/dev/sda1 613184 6908 606276 2% /boot/efi
tmpfs 186956 1180 185776 1% /run/user/42
tmpfs 186956 4672 182284 3% /run/user/0
/dev/sr0 8037456 8037456 0 100% /media/CentOS
[root@suzukto ~]#
手順11 確認
[root@suzukto ~]# alias
alias cp='cp -i'
alias dnf=‘dnf --disablerepo=¥* --enablerepo=c8-media-BaseOS,c8-media-
AppStream’ ←確認
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
[root@suzukto ~]#
alias␣dnf=‘dnf␣--disablerepo=¥*␣--enablerepo=media-baseos,media-appstream'
設定ファイルは cat␣/etc/yum.repos.d/CentOS-Stream-Media.repo
8
手順1 Postfix、NetCatインストール
手順2 インストール後のバージョン確認
手順3 ユーザ作成時にメールボックスが作成されるようにスケルトンユーザを作成する
手順4 postfixのバックアップファイルを取得する
手順5 ホスト名の変更
Postfix1 インストール
[root@suzukito yum.repos.d]#dnf␣-y␣install␣postfix␣nc
完了しました!
[root@Linux8-Mail1 ~]#
[root@Linux8-Mail1 ~]# postconf␣|␣grep␣mail_version
mail_version = 3.5.8
milter_macro_v = $mail_name $mail_version
[root@Linux8-Mail1 ~]# nc␣-v
Ncat: Version 7.70 ( https://nmap.org/ncat )
Ncat: You must specify a host to connect to. QUITTING.
[root@Linux8-Mail1 ~]#
[root@Linux8-Mail1 ~]# mkdir␣-p␣/etc/skel/Maildir/{new,cur,tmp}
[root@Linux8-Mail1 ~]# sudo␣chmod␣-R␣700␣/etc/skel/Maildir/
[root@Linux8-Mail1 ~]# cp –p /etc/postdix/main.cf /etc/postdix/main.cf.bak
mailとversionの間はアンダーバー
[root@Linux8-Mail1 ~]#hostnamectl set-hostname Linux8-Mail1
9
手順6 postfix設定 「:行数」で対象の行に移動(ジャンプできます)
Postfix2 設定ファイルの編集
[root@Linux8-Mail1 ~]# vi /etc/postfix/main.cf
94 myhostname = Linux8-Mail1
102 mydomain = melonpan.udx.local
118 myorigin = $mydomain
132 inet_interfaces = all
133 #inet_interfaces = $myhostname
134 #inet_interfaces = $myhostname, localhost
135 #inet_interfaces = localhost
183 #mydestination = $myhostname, localhost.$mydomain, localhost
184 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
283 mynetworks = 192.168.210.0/24
438 home_mailbox = Maildir/
445 mail_spool_directory = /var/spool/mail
593 smtpd_banner = $myhostname $mydomain ESMTP
740 #SMTP-Auth
741 #smtpd_sasl_type = dovecot
742 #smtpd_sasl_path = private/auth
743 #smtpd_sasl_auth_enable = yes
744 #smtpd_sasl_security_options = noanonymous
745 #smtpd_sasl_local_domain = $myhostname
746 #smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject
95行目 「#」を削除して、サーバ名を設定
102行目 「#」を削除して、ドメイン名を設定
118行目 「#」を削除ドメイン名をメールの@以降
132行目「#」削除 SMTP接続をするインターフェース
135行目「#」追加
183 「#」追加、184「#」削除 メールを受け取るドメイン名
438行目「#」削除 1つのメール、1つのファイル
445行目「#」削除
593行目 バナー情報にドメイン名を追加
740行目以降 追記
後からDovecotで利用します
283 「#」削除 ローカルネットワークを追記
10
手順6 設定ファイルの差分確認
Postfix3 設定ファイル差分確認
[root@Linux8-Mail1 ~]# diff /etc/postfix/main.cf /etc/postfix/main.cf.bak
95c95
< myhostname = Linux8-Mail1
---
> #myhostname = virtual.domain.tld
102c102
< mydomain = melonpan.udx.local
---
> #mydomain = domain.tld
118c118
< myorigin = $mydomain
---
> #myorigin = $mydomain
132c132
< inet_interfaces = all
---
> #inet_interfaces = all
135c135
< #inet_interfaces = localhost
---
> inet_interfaces = localhost
---
> inet_protocols = all
183,184c183,184
< #mydestination = $myhostname, localhost.$mydomain, localhost
< mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
---
> mydestination = $myhostname, localhost.$mydomain, localhost
> #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
283c283
< mynetworks = 192.168.210.0/24
---
> #mynetworks = 168.100.189.0/28, 127.0.0.0/8
438c438
< home_mailbox = Maildir/
---
> #home_mailbox = Maildir/
445c445
< mail_spool_directory = /var/spool/mail
---
> #mail_spool_directory = /var/spool/mail
593c593
< smtpd_banner = $myhostname $mydomain ESMTP
---
>
<
< #SMTP-Auth
< smtpd_sasl_type = dovecot
< smtpd_sasl_path = private/auth
< smtpd_sasl_local_domain = $myhostname
< smtpd_sasl_security_options = noanonymous
< #broken_sasl_auth_clients = yes
< smtpd_sasl_auth_enable = yes
< smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination,
permit_sasl_authenticated, reject
<
[root@Linux8-Mail1 ~]#
11
手順5 メールボックスを作成する
「suzukito」の部分はご自分のconnpassアカウントでお願いします
手順6 メールボックスにメールファイルが配置できるかを検証する
ncコマンドを利用する。
Postfix4 メールボックスの作成、コマンドからメール送信(疎通確認)
[root@Linux8-Mail1 admin]# useradd␣suzukito
[root@Linux8-Mail1 admin]# ls␣-al␣/home/suzukito/Maildir
合計 0
drwx------. 5 suzukito suzukito 39 5月 28 02:15 .
drwx------. 3 suzukito suzukito 77 5月 28 02:15 ..
drwx------. 2 suzukito suzukito 6 5月 28 02:15 cur
drwx------. 2 suzukito suzukito 6 5月 28 02:15 new
drwx------. 2 suzukito suzukito 6 5月 28 02:15 tmp
[root@Linux8-Mail1 admin]#
[root@Linux8-Mail1 admin]#passwd␣suzukito
ユーザー suzukito のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: すべての認証トークンが正しく更新できました。
[root@Linux8-Mail1 admin]#
[root@Linux8-Mail1 admin]#systemctl enable –now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service →
/usr/lib/systemd/system/postfix.service.
[root@Linux8-Mail1 ~]# nc localhost 25
220 Linux8-Mail1 melonpan.udx.local ESMTP
EHLO Linux8-Mail1
250-Linux8-Mail1
250-PIPELINING
250-SIZE 10485760
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
MAIL FROM: koike-yuriko@metro.tokyo.jp
250 2.1.0 Ok
RCPT TO:suzukito@melonpan.udx.local
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject:助成金交付通知
50万円の助成金支給します”
.
250 2.0.0 Ok: queued as 6CB5693DDC
quit
221 2.0.0 Bye
^C
[root@Linux8-Mail1 ~]#
25番ポートにアクセス
EHLO に続いてホスト名を入力
MAIL FROM: に続いて送信者メールアドレスを入力
MAIL FROM: に続いて
宛先メールアドレスを入力
DATAメソッド後に
本文入力ができるようになる 都知事からに言われたい事を入力
「Ctrl」+ C
Subject: メールタイトル
本文を記載
.(ピリオドで終了)
Me1onpan#
12
手順7 メールボックスにファイルがあるかを確認する
「suzukito」の部分はご自分のconnpassアカウントでお願いします。 newフォルダは未読メールが入ります。
手順8 メールファイルを確認する
Postfox5 メールボックスのファイル確認、メールの中身確認
[root@Linux8-Mail1 new]# ls␣-al␣/home/suzukito/Maildir/new
合計 8
drwx------. 2 suzukito suzukito 106 5月 28 06:00 .
drwx------. 5 suzukito suzukito 39 5月 28 02:15 ..
-rw-------. 1 suzukito suzukito 472 5月 28 06:00 1622196051.Vfd00I93c11M210868.Linux8-Mail1
-rw-------. 1 suzukito suzukito 431 5月 28 06:00 1622196056.Vfd00I93c0eM490971.Linux8-Mail1
[root@Linux8-Mail1 new]#
[root@Linux8-Mail1 ~]# cat␣/home/suzukito/Maildir/new/1622461899.Vfd00I93ddfM316582.Linux8-Mail1
Return-Path: <koike-yuriko@metro.tokyo.jp>
X-Original-To: suzukito@melonpan.udx.local
Delivered-To: suzukito@melonpan.udx.local
Received: from Linux8-Mail1 (localhost [127.0.0.1])
by Linux8-Mail1 (Postfix) with ESMTP id A5A5B93DDC
for <suzukito@melonpan.udx.local>; Mon, 31 May 2021 07:50:52 -0400 (EDT)
Message-Id: <20210531115114.A5A5B93DDC@Linux8-Mail1>
Date: Mon, 31 May 2021 07:50:52 -0400 (EDT)
From: koike-yuriko@metro.tokyo.jp
"助成金支給します"
[root@Linux8-Mail1 ~]#
13
今日の流れ
1.環境確認
2.Postfixインストール
3.Dovecotインストール
4.
5.
これから実施
14
POPとは(PostOfficeProtocol)110
IMAPとは(InternetMessageAccessProtocol)143
メールサーバを悪用されないように、SMTP認証を利用、SASL(Simple Authentication and Security Layer)機能を追加
Dovecot1 Dovecotとは、メール受信(POP/IMAP)
設定ファイル 説明 この後
/etc/dovecot/dovecot.conf メイン設定ファイル 修正する
/etc/dovecot/conf.d/10-auth.conf ユーザ認証設定ファイル 修正する
/etc/dovecot/conf.d/10-logging.conf ログ設定ファイル しない
/etc/dovecot/conf.d/10-mail.conf メール配送設定ファイル 修正する
/etc/dovecot/conf.d/10-master.conf 基本動作設定ファイル 修正する
/etc/dovecot/conf.d/10-ssl.conf SSL/TLS設定ファイル 修正する
15
手順1 Dovecotインストール
手順2 インストール後のバージョン確認、Postfixの認証確認
手順3 設定ファイル編集(1つめ)
手順4 差分確認
Dovecot2 インストール、メイン設定ファイル
[root@Linux8-Mail1 new]# dnf install dovecot
(省略)
完了しました!
[root@Linux8-Mail2 ~]#
[root@Linux8-Mail1 ~]# cp –p /etc/dovecot/dovecot.conf /etc/dovecot/dovecont.conf.bak
[root@Linux8-Mail1 ~]# vi /etc/dovecot/dovecot.conf
24 protocols = imap
30 listen = *
[root@Linux8-Mail1 ~]# dovecot --version
2.3.8 (9df20d2db)
[root@Linux8-Mail1 ~]#
[root@Linux8-Mail1 ~]# postconf -a
cyrus
dovecot
[root@Linux8-Mail1 new]#
[root@Linux8-Mail2 ~]# diff /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bak
Dovecotのsmtp認証を利用出来る
ようになった
24行目「#」削除、imapのみに
30行目「#」削除、「,::」を削除 ipv4のみに
24c24
< protocols = imap
---
> #protocols = imap pop3 lmtp submission
30c30
< listen = *
---
> #listen = *, ::
[root@Linux8-Mail2 ~]#
16
手順5 Dovecot設定ファイル編集(2つめ)
手順6 Dovecot設定ファイル編集(2つめ)差分確認
手順7 Dovecotの設定ファイル編集(3つめ)
手順8 Dovecotの設定ファイル編集(3つめ)差分確認
Dovecot3 ユーザ認証設定、メール配送設定の編集
[root@Linux8-Mail1 ~]# cp –p /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.bak
[root@Linux8-Mail1 ~]# vi /etc/dovecot/conf.d/10-auth.conf
10 disable_plaintext_auth = no
100 auth_mechanisms = plain login
[root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.bak
[root@Linux8-Mail1 new]# cp –p /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.bak
[root@Linux8-Mail1 new]# vi /etc/dovecot/conf.d/10-mail.conf
30 mail_location = maildir:~/Maildir
[root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.bak
30c30
< mail_location = maildir:~/Maildir
---
> #mail_location =
[root@Linux8-Mail1 ~]#
10行目 平文(プレーンテキスト)認証を許可
100行目 plain:平文による認証(RFC4616)
login:平文による認証(標準仕様無し) 10c10
< disable_plaintext_auth = no
---
> #disable_plaintext_auth = yes
100c100
< auth_mechanisms = plain login
---
> auth_mechanisms = plain
[root@Linux8-Mail1 ~]#
30行目 ユーザのホームディレクトリに
1メール1ファイルで配送
17
手順9 Dovecot設定ファイルの編集(4つめ)
手順10 Dovecot設定ファイルの編集(4つめ)差分確認
手順11 Dovecot設定ファイルの編集(5つめ)
手順12 Dovecot設定ファイルの編集(5つめ)
Dovecot4 基本設定(権限設定)、SSL/TLS設定
[root@Linux8-Mail1 new] cp -p /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak
[root@Linux8-Mail1 new]# vi /etc/dovecot/conf.d/10-master.conf
106 # Postfix smtp-auth
107 unix_listener /var/spool/postfix/private/auth {
108 mode = 0666
109 user = postfix
110 group = postfix
111 }
[root@Linux8-Mail1 new] diff /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak
107行目、108行目 「#」削除
109行目 user = postfix 追加
110行目 group = postfix 追加
107,111c107,109
< unix_listener /var/spool/postfix/private/auth {
< mode = 0666
< user = postfix
< group = postfix
< }
---
> #unix_listener /var/spool/postfix/private/auth {
> # mode = 0666
> #}
[root@Linux8-Mail1 new] cp -p /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.bak
[root@Linux8-Mail1 ]# vi /etc/dovecot/conf.d/10-ssl.conf
8 ssl = yes
[root@Linux8-Mail1 new]#
[root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.bak
8行目 必須から変更
8c8
< ssl = yes
---
> ssl = required
[root@Linux8-Mail1 ~]#
18
手順13 PostfixとDovecotの連携設定
手順14 設定の再読み込み
Dovecot5 post-fixとDovecotの連携、設定ファイル再読み込み
[root@Linux8-Mail1 ~]# vi /etc/postfix/main.cf
740 #SMTP-Auth
741 smtpd_sasl_type = dovecot
742 smtpd_sasl_path = private/auth
743 smtpd_sasl_auth_enable =yes
744 smtpd_sasl_security_options = noanonymous
745 smtpd_sasl_local_domain = $myhostname
746 smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
[root@Linux8-Mail1 new]# systemctl restart postfix
[root@Linux8-Mail1 new]# systemctl status postfix
[root@Linux8-Mail1 new]# systemctl restart dovecot
[root@Linux8-Mail1 new]# systemctl status dovecot
19
今日の流れ
1.環境確認
2.Postfixインストール
3.Dovecotインストール
4.クライアント設定
5.
これから実施
20
手順1 クライアントPCに「melonpan.udx.local」の場所を教えます。
コマンドプロンプトにて、powershell -NoProfile -ExecutionPolicy unrestricted -Command "start notepad C:¥Windows¥System32¥drivers¥etc¥hosts -verb runas"
もしくは、メモ帳を管理者として実行して、「 C:¥Windows¥System32¥drivers¥etc¥hosts 」を開く
手順2 「192.168.210.111」melonpan.udx.local を登録します
メールクライアントで確認(HOSTS登録)
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.210.26 melonpan.udx.local
手順3 pingで確認します
ping melonpan.udx.local でIPアドレスを確認
21
手順4 ThunderBirdインストール
新規インストールの場合「アカウントのセットアップ」→「メール」
既存に追加の場合「ツール」→「アカウント設定」
「アカウントの操作」→「メールアカウントを追加」
メールクライアントで確認(ThunderBird)1
手順5
あなたのお名前:鈴木 徹(任意)
メールアドレス:suzukito@melonpan.udx.local
パスワード :Me1onpan#
「続ける」をクリック
手順6
「完了」をクリック
22
手順7 「セキュリティ例外を承認」をクリック 手順8 助成金が交付されました
メールクライアントで確認(ThunderBird)2
23
今日の流れ
1.環境確認
2.Postfixインストール
3.Dovecotインストール
4.クライアント設定
5.DNS設定、メール送信
これから実施
24
手順A 参加者全員で、だれがDNSレコードを追加登録するか合意する
手順B DNSサーバ(192.168.210.195)にログインする
手順C ゾーンファイルにDNSレコードを追加する。
手順D bindサービスを再起動する
メール送信1 DNSレコード登録する(1人のみ)
じゃんけん?
[root@Linux8-Mail2 systemd]# ssh 192.168.210.195
The authenticity of host '192.168.210.195 (192.168.210.195)' can't be established.
ECDSA key fingerprint is SHA256:OFLn5EZzlb+QpQMDrCTuMsmVoGqCKpPUSTM6FOFDJG4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.210.195' (ECDSA) to the list of known hosts.
root@192.168.210.195's password:
Last login: Thu Jun 3 11:46:54 2021 from 192.168.210.12
[root@Linux8-DNS ~]#
Me1onpan#
プロンプトが「Linux8-DNS」に変更し事を確認
1 $ORIGIN udx.local.
2 $TTL 86400
3 udx.local. IN SOA ns.udx.local. suzukito.udx.local. (
4
5 2021060201 ;Serial
6 3600 ;Refresh
7 1800 ;Retry
8 604800 ;Expire
9 86400 ;Minimum TTL
10 )
11 udx.local. IN NS ns.udx.local.
12 udx.local. IN MX 10 melonpan.udx.local.
13 udx.local. IN MX 20 anpan.udx.local.
14 udx.local. IN MX 30 currypan.udx.local.
15 udx.local. IN MX 40 croissant.udx.local.
16
17 ns.udx.local. IN A 192.168.210.195
18
19 melonpan.udx.local. IN A 192.168.210.26
20 anpan.udx.local. IN A 192.168.210.23
21 currypan.udx.local. IN A 192.168.210.22
22 croissant.udx.local. IN A 192.168.210.21
/var/named/udx.local.zone
[root@Linux8-DNS ~]#vi /var/named/udx.local.zone
ホスト名の最後に「.」ピリオドを
[root@Linux8-DNS ~]#systemctl restart named
[root@Linux8-DNS ~]#systemctl status named
25
手順1 DNSサーバを指定する
手順2 dig、hosts コマンドをインストールする
手順3 ホスト名でpingが疎通出来るかを確認する
ping NGの場合は、GATEWAYを確認
手順4 dig ホスト名
メール送信2 DNSサーバを指定する(全員)
[root@Linux8-Mail1 ~]# nmcli conn show ens192 | grep ipv4.dns:
ipv4.dns: --
[root@Linux8-Mail1 ~]# nmcli conn mod ens192 +ipv4.dns 192.168.210.195
[root@Linux8-Mail1 ~]# nmcli conn down ens192; nmcli conn up ens192
[root@Linux8-Mail1 ~]# nmcli conn show ens192 | grep ipv4.dns:
ipv4.dns: 192.168.210.195
[root@Linux8-Mail1 ~]#
[root@Linux8-Mail1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192 | grep DNS
DNS1=192.168.210.195
[root@Linux8-Mail1 ~]#
[root@Linux8-Mail1 ~]# dnf install bind-utils
[root@Linux8-Mail1 ]# dig melonpna.udx.local
; <<>> DiG 9.11.26-RedHat-9.11.26-3.el8 <<>> melonpna.udx.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to
DNS
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55392
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 31aee03dfc528dbcac8fce4760b8553215a7779e0ecb332a (good)
;; QUESTION SECTION:
;melonpna.udx.local. IN A
;; AUTHORITY SECTION:
udx.local. 86400 IN SOA ns.udx.local. suzukito.udx.local.
2021060201 3600 1800 604800 86400
;; Query time: 0 msec
;; SERVER: 192.168.210.195#53(192.168.210.195)
;; WHEN: 木 6月 03 00:06:10 EDT 2021
;; MSG SIZE rcvd: 123
[root@Linux8-Mail1 network-scripts]#
[root@Linux8-Mail1 network-scripts]# ping anpan.udx.local
PING anpan.udx.local (192.168.210.23) 56(84) bytes of data.
64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=1 ttl=64 time=0.154 ms
64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=2 ttl=64 time=0.116 ms
64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=3 ttl=64 time=0.127 ms
64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=4 ttl=64 time=0.122 ms
64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=5 ttl=64 time=0.118 ms
26
手順1 「作成」→ 宛先、件名、本文を入力 → 「送信」
手順2 「送信」クリック後に、「セキュリティ例外を承認」をクリック → もう一度「送信」
メール送信3 クライアントからメール送付(自分以外の全員へ)
届いた事を確認
おしまい
27
手順1 /etc/named.conf
参考:DNSサーバ設定
[root@Linux8-DNS ~]# vi /etc/named.conf
1 //
2 // named.conf
3 //
4 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
5 // server as a caching only nameserver (as a localhost DNS resolver only).
6 //
7 // See /usr/share/doc/bind*/sample/ for example named configuration files.
8 //
9 acl udx-local{
10 192.168.210.0/24;
11 };
12
13 options {
14 listen-on port 53 { 192.168.210.195; 127.0.0.1; };
15 listen-on-v6 port 53 { none; };
16 directory "/var/named";
17 version "Linux#8 DNS Server";
18 dump-file "/var/named/data/cache_dump.db";
19 statistics-file "/var/named/data/named_stats.txt";
20 memstatistics-file "/var/named/data/named_mem_stats.txt";
21 secroots-file "/var/named/data/named.secroots";
22 recursing-file "/var/named/data/named.recursing";
23 allow-query { localhost; udx-local;};
24
25 /*
26 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
27 - If you are building a RECURSIVE (caching) DNS server, you need to enable
28 recursion.
29 - If your recursive DNS server has a public IP address, you MUST enable access
30 control to limit queries to your legitimate users. Failing to do so will
31 cause your server to become part of large scale DNS amplification
32 attacks. Implementing BCP38 within your network would greatly
33 reduce such attack surface
34 */
35 recursion yes;
36
37 dnssec-enable yes;
38 dnssec-validation yes;
39
40 managed-keys-directory "/var/named/dynamic";
41
42 pid-file "/run/named/named.pid";
43 session-keyfile "/run/named/session.key";
44
45 /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */
46 include "/etc/crypto-policies/back-ends/bind.config";
47 };
48
49 logging {
50 channel default_debug {
51 file "data/named.run";
52 severity dynamic;
53 };
54 };
55
56 zone "." IN {
57 type hint;
58 file "named.ca";
59 };
60
61 include "/etc/named.rfc1912.zones";
62 include "/etc/named.root.key";
63
64 zone "udx.local" IN {
65 type master;
66 file "udx.local.zone";
67 };
68 zone "210.168.192.in-addr.arpa" IN {
69 type master;
70 file "210.168.192.zone";
71 };
1 $ORIGIN udx.local.
2 $TTL 86400
3 udx.local. IN SOA ns.udx.local. suzukito.udx.local. (
4
5 2021060201 ;Serial
6 3600 ;Refresh
7 1800 ;Retry
8 604800 ;Expire
9 86400 ;Minimum TTL
10 )
11 udx.local. IN NS ns.udx.local.
12 udx.local. IN MX 10 melonpan.udx.local.
13 udx.local. IN MX 20 anpan.udx.local.
14 udx.local. IN MX 30 currypan.udx.local.
15 udx.local. IN MX 40 croissant.udx.local.
16
17 ns.udx.local. IN A 192.168.210.195
18
19 melonpan.udx.local. IN A 192.168.210.26
20 anpan.udx.local. IN A 192.168.210.23
21 currypan.udx.local. IN A 192.168.210.22
22 croissant.udx.local. IN A 192.168.210.21
1 $TTL 86400
2 @ IN SOA udx.local. suzukito.udx.local. (
3 2021060201 ;Serial
4 3600 ;Refresh
5 1800 ;Retry
6 604800 ;Expire
7 86400 ;Minumum TTL
8 )
9 IN NS ns.udx.local.
/var/named/udx.local.zone
/var/named/210.168.192.zone
28
認証を統合するとしたら
メールのアンチウイルス
バックアップリストア
メールボックスの容量制限
メール送信のサイズ制限
メーリングリスト
chroot
通信の暗号化
証明書
企業向けにするには、、、
29 【Linux】#8 認証を統合した場合1
PC1
192.168.210.11
https://milestone-of-se.nesuke.com/nw-basic/grasp-nw/mail/
PC2
192.168.210.12
メール送信
送信元:
pc1@melonpan.udx.local
宛先 :pc2@anpan.udx.local
server1(melonpan)
192.168.210.111
SMTP
LDAP
SMTP-Auth認証
ID:pc1@melonpan.udx.local
パスワード:Me1onpan#
であってますか?
正解!!
DNS
anpan.udx.local ってどこ
IPアドレスを教えて!
「192.168.210.112」!!
server2(anpan)
192.168.210.112
SMTP
anpan.udx.local にメール送信
送信OK
30 【Linux】#認証を統合した場合2
PC1
192.168.210.11
https://milestone-of-se.nesuke.com/nw-basic/grasp-nw/mail/
PC2
192.168.210.12
server1(melonpan)
192.168.210.111
SMTP
LDAP
SMTP-Auth認証
ID:pc2@anpan.udx.local
パスワード:anpan#
であってますか?
正解!!
server2(anpan)
192.168.210.112
メール確認
pc2@anpan.udx.local
にメールある?

Contenu connexe

En vedette

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

En vedette (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

Linux#8 mail

  • 1. 【Linux】#8 Mail 1 アジェンダ 0900~0905 今日出来るようになる事、自己紹介(チーム紹介) システム構成説明 0905~0915 サーバへの疎通確認 0915~0930 Postfixインストール 0930~0945 Postfix初期設定 0945~1000 Dovecotインストール 1000~1015 メール受信テスト 1015~1030 メール送信テスト 参加いただきありがとうございます!!! 鈴木メモ 持ち物:スイッチ×4、PC×4、LAN線×8、 シリアルケーブル×4 今日出来るようになる事 メールサーバを構築できる
  • 4. 4 【Linux】#8 Mail 設計一覧 1 2 3 4 PC 192.168.210.11 192.168.210.12 192.168.210.13 192.168.210.14 Server CentOS 192.168.210.111 192.168.210.112 192.168.210.113 192.168.210.114 ホスト名 Linux8-Mail1 Linux8-Mail2 Linux8-Mail3 Linux8-Mail4 Domain melonpan.udx.local anpan.udx.local currypan.udx.local croissant.udx.local ユーザ名 connpassアカウント (suzukito) connpassアカウント connpassアカウント connpassアカウント パスワード Me1onpan# Me1onpan# Me1onpan# Me1onpan#
  • 5. 5 【Linux】#8 PC1→メールサーバ1→DNS→メールサーバ2(送受信) PC1 192.168.210.11 PC2 192.168.210.12 メール送信 送信元:pc1@melonpan.udx.local 宛先 :pc2@anpan.udx.local server1(melonpan) 192.168.210.111 SMTP server2(anpan) 192.168.210.112 送信OK IMAP メール確認 pc2@anpan.udx.local にメールある? DNS anpan.udx.local ってどこ IPアドレスを教えて! 「192.168.210.112」!! SMTP anpan.udx.local にメール送信
  • 7. インターネット未接続環境でのdnf  ソフトウェアのインストールにはCentOS8のパッケージ管理ソフトウェアである「dnf」を使用していきますが、デフォルトではインターネットからソフトウェアを取得す ることになります。  ここではインストールメディアからソフトウェアを取得する設定を行います。  インストールメディアのISOイメージをCDROMドライブにセットしてあります。 7 手順9 [root@suzukto ~]# mkdir␣/media/CentOS [root@suzukto ~]# mount␣–o␣ro␣/dev/cdrom␣/media/CentOS/ [root@suzukto ~]# alias␣dnf=‘dnf␣--disablerepo=¥*␣--enablerepo=c8-media-BaseOS,c8-media-AppStream’ 手順10 確認 [root@suzukto ~]# df ファイルシス 1K-ブロック 使用 使用可 使用% マウント位置 devtmpfs 905304 0 905304 0% /dev tmpfs 934792 0 934792 0% /dev/shm tmpfs 934792 9832 924960 2% /run tmpfs 934792 0 934792 0% /sys/fs/cgroup /dev/mapper/cl-root 13420544 4243772 9176772 32% / /dev/sda2 999320 191708 738800 21% /boot /dev/sda1 613184 6908 606276 2% /boot/efi tmpfs 186956 1180 185776 1% /run/user/42 tmpfs 186956 4672 182284 3% /run/user/0 /dev/sr0 8037456 8037456 0 100% /media/CentOS [root@suzukto ~]# 手順11 確認 [root@suzukto ~]# alias alias cp='cp -i' alias dnf=‘dnf --disablerepo=¥* --enablerepo=c8-media-BaseOS,c8-media- AppStream’ ←確認 alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' [root@suzukto ~]# alias␣dnf=‘dnf␣--disablerepo=¥*␣--enablerepo=media-baseos,media-appstream' 設定ファイルは cat␣/etc/yum.repos.d/CentOS-Stream-Media.repo
  • 8. 8 手順1 Postfix、NetCatインストール 手順2 インストール後のバージョン確認 手順3 ユーザ作成時にメールボックスが作成されるようにスケルトンユーザを作成する 手順4 postfixのバックアップファイルを取得する 手順5 ホスト名の変更 Postfix1 インストール [root@suzukito yum.repos.d]#dnf␣-y␣install␣postfix␣nc 完了しました! [root@Linux8-Mail1 ~]# [root@Linux8-Mail1 ~]# postconf␣|␣grep␣mail_version mail_version = 3.5.8 milter_macro_v = $mail_name $mail_version [root@Linux8-Mail1 ~]# nc␣-v Ncat: Version 7.70 ( https://nmap.org/ncat ) Ncat: You must specify a host to connect to. QUITTING. [root@Linux8-Mail1 ~]# [root@Linux8-Mail1 ~]# mkdir␣-p␣/etc/skel/Maildir/{new,cur,tmp} [root@Linux8-Mail1 ~]# sudo␣chmod␣-R␣700␣/etc/skel/Maildir/ [root@Linux8-Mail1 ~]# cp –p /etc/postdix/main.cf /etc/postdix/main.cf.bak mailとversionの間はアンダーバー [root@Linux8-Mail1 ~]#hostnamectl set-hostname Linux8-Mail1
  • 9. 9 手順6 postfix設定 「:行数」で対象の行に移動(ジャンプできます) Postfix2 設定ファイルの編集 [root@Linux8-Mail1 ~]# vi /etc/postfix/main.cf 94 myhostname = Linux8-Mail1 102 mydomain = melonpan.udx.local 118 myorigin = $mydomain 132 inet_interfaces = all 133 #inet_interfaces = $myhostname 134 #inet_interfaces = $myhostname, localhost 135 #inet_interfaces = localhost 183 #mydestination = $myhostname, localhost.$mydomain, localhost 184 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 283 mynetworks = 192.168.210.0/24 438 home_mailbox = Maildir/ 445 mail_spool_directory = /var/spool/mail 593 smtpd_banner = $myhostname $mydomain ESMTP 740 #SMTP-Auth 741 #smtpd_sasl_type = dovecot 742 #smtpd_sasl_path = private/auth 743 #smtpd_sasl_auth_enable = yes 744 #smtpd_sasl_security_options = noanonymous 745 #smtpd_sasl_local_domain = $myhostname 746 #smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject 95行目 「#」を削除して、サーバ名を設定 102行目 「#」を削除して、ドメイン名を設定 118行目 「#」を削除ドメイン名をメールの@以降 132行目「#」削除 SMTP接続をするインターフェース 135行目「#」追加 183 「#」追加、184「#」削除 メールを受け取るドメイン名 438行目「#」削除 1つのメール、1つのファイル 445行目「#」削除 593行目 バナー情報にドメイン名を追加 740行目以降 追記 後からDovecotで利用します 283 「#」削除 ローカルネットワークを追記
  • 10. 10 手順6 設定ファイルの差分確認 Postfix3 設定ファイル差分確認 [root@Linux8-Mail1 ~]# diff /etc/postfix/main.cf /etc/postfix/main.cf.bak 95c95 < myhostname = Linux8-Mail1 --- > #myhostname = virtual.domain.tld 102c102 < mydomain = melonpan.udx.local --- > #mydomain = domain.tld 118c118 < myorigin = $mydomain --- > #myorigin = $mydomain 132c132 < inet_interfaces = all --- > #inet_interfaces = all 135c135 < #inet_interfaces = localhost --- > inet_interfaces = localhost --- > inet_protocols = all 183,184c183,184 < #mydestination = $myhostname, localhost.$mydomain, localhost < mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain --- > mydestination = $myhostname, localhost.$mydomain, localhost > #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 283c283 < mynetworks = 192.168.210.0/24 --- > #mynetworks = 168.100.189.0/28, 127.0.0.0/8 438c438 < home_mailbox = Maildir/ --- > #home_mailbox = Maildir/ 445c445 < mail_spool_directory = /var/spool/mail --- > #mail_spool_directory = /var/spool/mail 593c593 < smtpd_banner = $myhostname $mydomain ESMTP --- > < < #SMTP-Auth < smtpd_sasl_type = dovecot < smtpd_sasl_path = private/auth < smtpd_sasl_local_domain = $myhostname < smtpd_sasl_security_options = noanonymous < #broken_sasl_auth_clients = yes < smtpd_sasl_auth_enable = yes < smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject < [root@Linux8-Mail1 ~]#
  • 11. 11 手順5 メールボックスを作成する 「suzukito」の部分はご自分のconnpassアカウントでお願いします 手順6 メールボックスにメールファイルが配置できるかを検証する ncコマンドを利用する。 Postfix4 メールボックスの作成、コマンドからメール送信(疎通確認) [root@Linux8-Mail1 admin]# useradd␣suzukito [root@Linux8-Mail1 admin]# ls␣-al␣/home/suzukito/Maildir 合計 0 drwx------. 5 suzukito suzukito 39 5月 28 02:15 . drwx------. 3 suzukito suzukito 77 5月 28 02:15 .. drwx------. 2 suzukito suzukito 6 5月 28 02:15 cur drwx------. 2 suzukito suzukito 6 5月 28 02:15 new drwx------. 2 suzukito suzukito 6 5月 28 02:15 tmp [root@Linux8-Mail1 admin]# [root@Linux8-Mail1 admin]#passwd␣suzukito ユーザー suzukito のパスワードを変更。 新しいパスワード: 新しいパスワードを再入力してください: passwd: すべての認証トークンが正しく更新できました。 [root@Linux8-Mail1 admin]# [root@Linux8-Mail1 admin]#systemctl enable –now postfix Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service. [root@Linux8-Mail1 ~]# nc localhost 25 220 Linux8-Mail1 melonpan.udx.local ESMTP EHLO Linux8-Mail1 250-Linux8-Mail1 250-PIPELINING 250-SIZE 10485760 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250 SMTPUTF8 MAIL FROM: koike-yuriko@metro.tokyo.jp 250 2.1.0 Ok RCPT TO:suzukito@melonpan.udx.local 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> Subject:助成金交付通知 50万円の助成金支給します” . 250 2.0.0 Ok: queued as 6CB5693DDC quit 221 2.0.0 Bye ^C [root@Linux8-Mail1 ~]# 25番ポートにアクセス EHLO に続いてホスト名を入力 MAIL FROM: に続いて送信者メールアドレスを入力 MAIL FROM: に続いて 宛先メールアドレスを入力 DATAメソッド後に 本文入力ができるようになる 都知事からに言われたい事を入力 「Ctrl」+ C Subject: メールタイトル 本文を記載 .(ピリオドで終了) Me1onpan#
  • 12. 12 手順7 メールボックスにファイルがあるかを確認する 「suzukito」の部分はご自分のconnpassアカウントでお願いします。 newフォルダは未読メールが入ります。 手順8 メールファイルを確認する Postfox5 メールボックスのファイル確認、メールの中身確認 [root@Linux8-Mail1 new]# ls␣-al␣/home/suzukito/Maildir/new 合計 8 drwx------. 2 suzukito suzukito 106 5月 28 06:00 . drwx------. 5 suzukito suzukito 39 5月 28 02:15 .. -rw-------. 1 suzukito suzukito 472 5月 28 06:00 1622196051.Vfd00I93c11M210868.Linux8-Mail1 -rw-------. 1 suzukito suzukito 431 5月 28 06:00 1622196056.Vfd00I93c0eM490971.Linux8-Mail1 [root@Linux8-Mail1 new]# [root@Linux8-Mail1 ~]# cat␣/home/suzukito/Maildir/new/1622461899.Vfd00I93ddfM316582.Linux8-Mail1 Return-Path: <koike-yuriko@metro.tokyo.jp> X-Original-To: suzukito@melonpan.udx.local Delivered-To: suzukito@melonpan.udx.local Received: from Linux8-Mail1 (localhost [127.0.0.1]) by Linux8-Mail1 (Postfix) with ESMTP id A5A5B93DDC for <suzukito@melonpan.udx.local>; Mon, 31 May 2021 07:50:52 -0400 (EDT) Message-Id: <20210531115114.A5A5B93DDC@Linux8-Mail1> Date: Mon, 31 May 2021 07:50:52 -0400 (EDT) From: koike-yuriko@metro.tokyo.jp "助成金支給します" [root@Linux8-Mail1 ~]#
  • 14. 14 POPとは(PostOfficeProtocol)110 IMAPとは(InternetMessageAccessProtocol)143 メールサーバを悪用されないように、SMTP認証を利用、SASL(Simple Authentication and Security Layer)機能を追加 Dovecot1 Dovecotとは、メール受信(POP/IMAP) 設定ファイル 説明 この後 /etc/dovecot/dovecot.conf メイン設定ファイル 修正する /etc/dovecot/conf.d/10-auth.conf ユーザ認証設定ファイル 修正する /etc/dovecot/conf.d/10-logging.conf ログ設定ファイル しない /etc/dovecot/conf.d/10-mail.conf メール配送設定ファイル 修正する /etc/dovecot/conf.d/10-master.conf 基本動作設定ファイル 修正する /etc/dovecot/conf.d/10-ssl.conf SSL/TLS設定ファイル 修正する
  • 15. 15 手順1 Dovecotインストール 手順2 インストール後のバージョン確認、Postfixの認証確認 手順3 設定ファイル編集(1つめ) 手順4 差分確認 Dovecot2 インストール、メイン設定ファイル [root@Linux8-Mail1 new]# dnf install dovecot (省略) 完了しました! [root@Linux8-Mail2 ~]# [root@Linux8-Mail1 ~]# cp –p /etc/dovecot/dovecot.conf /etc/dovecot/dovecont.conf.bak [root@Linux8-Mail1 ~]# vi /etc/dovecot/dovecot.conf 24 protocols = imap 30 listen = * [root@Linux8-Mail1 ~]# dovecot --version 2.3.8 (9df20d2db) [root@Linux8-Mail1 ~]# [root@Linux8-Mail1 ~]# postconf -a cyrus dovecot [root@Linux8-Mail1 new]# [root@Linux8-Mail2 ~]# diff /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bak Dovecotのsmtp認証を利用出来る ようになった 24行目「#」削除、imapのみに 30行目「#」削除、「,::」を削除 ipv4のみに 24c24 < protocols = imap --- > #protocols = imap pop3 lmtp submission 30c30 < listen = * --- > #listen = *, :: [root@Linux8-Mail2 ~]#
  • 16. 16 手順5 Dovecot設定ファイル編集(2つめ) 手順6 Dovecot設定ファイル編集(2つめ)差分確認 手順7 Dovecotの設定ファイル編集(3つめ) 手順8 Dovecotの設定ファイル編集(3つめ)差分確認 Dovecot3 ユーザ認証設定、メール配送設定の編集 [root@Linux8-Mail1 ~]# cp –p /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.bak [root@Linux8-Mail1 ~]# vi /etc/dovecot/conf.d/10-auth.conf 10 disable_plaintext_auth = no 100 auth_mechanisms = plain login [root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf.bak [root@Linux8-Mail1 new]# cp –p /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.bak [root@Linux8-Mail1 new]# vi /etc/dovecot/conf.d/10-mail.conf 30 mail_location = maildir:~/Maildir [root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.bak 30c30 < mail_location = maildir:~/Maildir --- > #mail_location = [root@Linux8-Mail1 ~]# 10行目 平文(プレーンテキスト)認証を許可 100行目 plain:平文による認証(RFC4616) login:平文による認証(標準仕様無し) 10c10 < disable_plaintext_auth = no --- > #disable_plaintext_auth = yes 100c100 < auth_mechanisms = plain login --- > auth_mechanisms = plain [root@Linux8-Mail1 ~]# 30行目 ユーザのホームディレクトリに 1メール1ファイルで配送
  • 17. 17 手順9 Dovecot設定ファイルの編集(4つめ) 手順10 Dovecot設定ファイルの編集(4つめ)差分確認 手順11 Dovecot設定ファイルの編集(5つめ) 手順12 Dovecot設定ファイルの編集(5つめ) Dovecot4 基本設定(権限設定)、SSL/TLS設定 [root@Linux8-Mail1 new] cp -p /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak [root@Linux8-Mail1 new]# vi /etc/dovecot/conf.d/10-master.conf 106 # Postfix smtp-auth 107 unix_listener /var/spool/postfix/private/auth { 108 mode = 0666 109 user = postfix 110 group = postfix 111 } [root@Linux8-Mail1 new] diff /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak 107行目、108行目 「#」削除 109行目 user = postfix 追加 110行目 group = postfix 追加 107,111c107,109 < unix_listener /var/spool/postfix/private/auth { < mode = 0666 < user = postfix < group = postfix < } --- > #unix_listener /var/spool/postfix/private/auth { > # mode = 0666 > #} [root@Linux8-Mail1 new] cp -p /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.bak [root@Linux8-Mail1 ]# vi /etc/dovecot/conf.d/10-ssl.conf 8 ssl = yes [root@Linux8-Mail1 new]# [root@Linux8-Mail1 ~]# diff /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.bak 8行目 必須から変更 8c8 < ssl = yes --- > ssl = required [root@Linux8-Mail1 ~]#
  • 18. 18 手順13 PostfixとDovecotの連携設定 手順14 設定の再読み込み Dovecot5 post-fixとDovecotの連携、設定ファイル再読み込み [root@Linux8-Mail1 ~]# vi /etc/postfix/main.cf 740 #SMTP-Auth 741 smtpd_sasl_type = dovecot 742 smtpd_sasl_path = private/auth 743 smtpd_sasl_auth_enable =yes 744 smtpd_sasl_security_options = noanonymous 745 smtpd_sasl_local_domain = $myhostname 746 smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject [root@Linux8-Mail1 new]# systemctl restart postfix [root@Linux8-Mail1 new]# systemctl status postfix [root@Linux8-Mail1 new]# systemctl restart dovecot [root@Linux8-Mail1 new]# systemctl status dovecot
  • 20. 20 手順1 クライアントPCに「melonpan.udx.local」の場所を教えます。 コマンドプロンプトにて、powershell -NoProfile -ExecutionPolicy unrestricted -Command "start notepad C:¥Windows¥System32¥drivers¥etc¥hosts -verb runas" もしくは、メモ帳を管理者として実行して、「 C:¥Windows¥System32¥drivers¥etc¥hosts 」を開く 手順2 「192.168.210.111」melonpan.udx.local を登録します メールクライアントで確認(HOSTS登録) # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 192.168.210.26 melonpan.udx.local 手順3 pingで確認します ping melonpan.udx.local でIPアドレスを確認
  • 22. 22 手順7 「セキュリティ例外を承認」をクリック 手順8 助成金が交付されました メールクライアントで確認(ThunderBird)2
  • 24. 24 手順A 参加者全員で、だれがDNSレコードを追加登録するか合意する 手順B DNSサーバ(192.168.210.195)にログインする 手順C ゾーンファイルにDNSレコードを追加する。 手順D bindサービスを再起動する メール送信1 DNSレコード登録する(1人のみ) じゃんけん? [root@Linux8-Mail2 systemd]# ssh 192.168.210.195 The authenticity of host '192.168.210.195 (192.168.210.195)' can't be established. ECDSA key fingerprint is SHA256:OFLn5EZzlb+QpQMDrCTuMsmVoGqCKpPUSTM6FOFDJG4. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '192.168.210.195' (ECDSA) to the list of known hosts. root@192.168.210.195's password: Last login: Thu Jun 3 11:46:54 2021 from 192.168.210.12 [root@Linux8-DNS ~]# Me1onpan# プロンプトが「Linux8-DNS」に変更し事を確認 1 $ORIGIN udx.local. 2 $TTL 86400 3 udx.local. IN SOA ns.udx.local. suzukito.udx.local. ( 4 5 2021060201 ;Serial 6 3600 ;Refresh 7 1800 ;Retry 8 604800 ;Expire 9 86400 ;Minimum TTL 10 ) 11 udx.local. IN NS ns.udx.local. 12 udx.local. IN MX 10 melonpan.udx.local. 13 udx.local. IN MX 20 anpan.udx.local. 14 udx.local. IN MX 30 currypan.udx.local. 15 udx.local. IN MX 40 croissant.udx.local. 16 17 ns.udx.local. IN A 192.168.210.195 18 19 melonpan.udx.local. IN A 192.168.210.26 20 anpan.udx.local. IN A 192.168.210.23 21 currypan.udx.local. IN A 192.168.210.22 22 croissant.udx.local. IN A 192.168.210.21 /var/named/udx.local.zone [root@Linux8-DNS ~]#vi /var/named/udx.local.zone ホスト名の最後に「.」ピリオドを [root@Linux8-DNS ~]#systemctl restart named [root@Linux8-DNS ~]#systemctl status named
  • 25. 25 手順1 DNSサーバを指定する 手順2 dig、hosts コマンドをインストールする 手順3 ホスト名でpingが疎通出来るかを確認する ping NGの場合は、GATEWAYを確認 手順4 dig ホスト名 メール送信2 DNSサーバを指定する(全員) [root@Linux8-Mail1 ~]# nmcli conn show ens192 | grep ipv4.dns: ipv4.dns: -- [root@Linux8-Mail1 ~]# nmcli conn mod ens192 +ipv4.dns 192.168.210.195 [root@Linux8-Mail1 ~]# nmcli conn down ens192; nmcli conn up ens192 [root@Linux8-Mail1 ~]# nmcli conn show ens192 | grep ipv4.dns: ipv4.dns: 192.168.210.195 [root@Linux8-Mail1 ~]# [root@Linux8-Mail1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192 | grep DNS DNS1=192.168.210.195 [root@Linux8-Mail1 ~]# [root@Linux8-Mail1 ~]# dnf install bind-utils [root@Linux8-Mail1 ]# dig melonpna.udx.local ; <<>> DiG 9.11.26-RedHat-9.11.26-3.el8 <<>> melonpna.udx.local ;; global options: +cmd ;; Got answer: ;; WARNING: .local is reserved for Multicast DNS ;; You are currently testing what happens when an mDNS query is leaked to DNS ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55392 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ; COOKIE: 31aee03dfc528dbcac8fce4760b8553215a7779e0ecb332a (good) ;; QUESTION SECTION: ;melonpna.udx.local. IN A ;; AUTHORITY SECTION: udx.local. 86400 IN SOA ns.udx.local. suzukito.udx.local. 2021060201 3600 1800 604800 86400 ;; Query time: 0 msec ;; SERVER: 192.168.210.195#53(192.168.210.195) ;; WHEN: 木 6月 03 00:06:10 EDT 2021 ;; MSG SIZE rcvd: 123 [root@Linux8-Mail1 network-scripts]# [root@Linux8-Mail1 network-scripts]# ping anpan.udx.local PING anpan.udx.local (192.168.210.23) 56(84) bytes of data. 64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=1 ttl=64 time=0.154 ms 64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=2 ttl=64 time=0.116 ms 64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=3 ttl=64 time=0.127 ms 64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=4 ttl=64 time=0.122 ms 64 bytes from 192.168.210.23 (192.168.210.23): icmp_seq=5 ttl=64 time=0.118 ms
  • 26. 26 手順1 「作成」→ 宛先、件名、本文を入力 → 「送信」 手順2 「送信」クリック後に、「セキュリティ例外を承認」をクリック → もう一度「送信」 メール送信3 クライアントからメール送付(自分以外の全員へ) 届いた事を確認 おしまい
  • 27. 27 手順1 /etc/named.conf 参考:DNSサーバ設定 [root@Linux8-DNS ~]# vi /etc/named.conf 1 // 2 // named.conf 3 // 4 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS 5 // server as a caching only nameserver (as a localhost DNS resolver only). 6 // 7 // See /usr/share/doc/bind*/sample/ for example named configuration files. 8 // 9 acl udx-local{ 10 192.168.210.0/24; 11 }; 12 13 options { 14 listen-on port 53 { 192.168.210.195; 127.0.0.1; }; 15 listen-on-v6 port 53 { none; }; 16 directory "/var/named"; 17 version "Linux#8 DNS Server"; 18 dump-file "/var/named/data/cache_dump.db"; 19 statistics-file "/var/named/data/named_stats.txt"; 20 memstatistics-file "/var/named/data/named_mem_stats.txt"; 21 secroots-file "/var/named/data/named.secroots"; 22 recursing-file "/var/named/data/named.recursing"; 23 allow-query { localhost; udx-local;}; 24 25 /* 26 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. 27 - If you are building a RECURSIVE (caching) DNS server, you need to enable 28 recursion. 29 - If your recursive DNS server has a public IP address, you MUST enable access 30 control to limit queries to your legitimate users. Failing to do so will 31 cause your server to become part of large scale DNS amplification 32 attacks. Implementing BCP38 within your network would greatly 33 reduce such attack surface 34 */ 35 recursion yes; 36 37 dnssec-enable yes; 38 dnssec-validation yes; 39 40 managed-keys-directory "/var/named/dynamic"; 41 42 pid-file "/run/named/named.pid"; 43 session-keyfile "/run/named/session.key"; 44 45 /* https://fedoraproject.org/wiki/Changes/CryptoPolicy */ 46 include "/etc/crypto-policies/back-ends/bind.config"; 47 }; 48 49 logging { 50 channel default_debug { 51 file "data/named.run"; 52 severity dynamic; 53 }; 54 }; 55 56 zone "." IN { 57 type hint; 58 file "named.ca"; 59 }; 60 61 include "/etc/named.rfc1912.zones"; 62 include "/etc/named.root.key"; 63 64 zone "udx.local" IN { 65 type master; 66 file "udx.local.zone"; 67 }; 68 zone "210.168.192.in-addr.arpa" IN { 69 type master; 70 file "210.168.192.zone"; 71 }; 1 $ORIGIN udx.local. 2 $TTL 86400 3 udx.local. IN SOA ns.udx.local. suzukito.udx.local. ( 4 5 2021060201 ;Serial 6 3600 ;Refresh 7 1800 ;Retry 8 604800 ;Expire 9 86400 ;Minimum TTL 10 ) 11 udx.local. IN NS ns.udx.local. 12 udx.local. IN MX 10 melonpan.udx.local. 13 udx.local. IN MX 20 anpan.udx.local. 14 udx.local. IN MX 30 currypan.udx.local. 15 udx.local. IN MX 40 croissant.udx.local. 16 17 ns.udx.local. IN A 192.168.210.195 18 19 melonpan.udx.local. IN A 192.168.210.26 20 anpan.udx.local. IN A 192.168.210.23 21 currypan.udx.local. IN A 192.168.210.22 22 croissant.udx.local. IN A 192.168.210.21 1 $TTL 86400 2 @ IN SOA udx.local. suzukito.udx.local. ( 3 2021060201 ;Serial 4 3600 ;Refresh 5 1800 ;Retry 6 604800 ;Expire 7 86400 ;Minumum TTL 8 ) 9 IN NS ns.udx.local. /var/named/udx.local.zone /var/named/210.168.192.zone
  • 29. 29 【Linux】#8 認証を統合した場合1 PC1 192.168.210.11 https://milestone-of-se.nesuke.com/nw-basic/grasp-nw/mail/ PC2 192.168.210.12 メール送信 送信元: pc1@melonpan.udx.local 宛先 :pc2@anpan.udx.local server1(melonpan) 192.168.210.111 SMTP LDAP SMTP-Auth認証 ID:pc1@melonpan.udx.local パスワード:Me1onpan# であってますか? 正解!! DNS anpan.udx.local ってどこ IPアドレスを教えて! 「192.168.210.112」!! server2(anpan) 192.168.210.112 SMTP anpan.udx.local にメール送信 送信OK