2019年1月20日日曜日

resolve.confの設定について(bind設定編)

resolve.confの設定について
namedserverの指定をローカルIPにしないと、内部で名前引きが出来なかったので
現時点で、以下にすること!!


[root@bind named]# vi /etc/resolv.conf 
==========resolv.conf=============
serach ドメイン名
nameserver 10.128.0.2(ローカルアドレス)

2019年1月19日土曜日

bind設定(レジストラ 編)

bindの設定も済んだので、無料のレジストラ にドメインの取得を行う。

https://my.freenom.com/

2019年1月14日月曜日

SASL PLAIN authentication failedの表示が消したい時の対策について(メモ)

以下ログの表示されている、SASL PLAIN authentication failedの表示が消したい時の対策について

====== /var/log/mailling ==============
warning: unknown[192.168.1.201]: SASL PLAIN authentication failed:
================================


◻️赤字を追記して、アクセス制限を行う。
(アクセス可能なネットワーク範囲を指定する。)

vi /etc/dovecot/conf.d/auth-system.conf.ext
===========/etc/dovecot/conf.d/auth-system.conf.ext=========
# Authentication for system users. Included from 10-auth.conf.
#
# <doc/wiki/PasswordDatabase.txt>
# <doc/wiki/UserDatabase.txt>

# PAM authentication. Preferred nowadays by most systems.
# PAM is typically used with either userdb passwd or userdb static.
# REMEMBER: You'll need /etc/pam.d/dovecot file created for PAM
# authentication to actually work. <doc/wiki/PasswordDatabase.PAM.txt>
passdb {
  driver = pam
  # [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
  # [cache_key=<key>] [<service name>]
  #args = dovecot
  override_fields = allow_nets=127.0.0.0/8,::1/128,fe80::/64,192.168.1.0/24

}

                .
                .
                .
             以下、省略
          .
                .
============================================================


postfixコンフィグ整理:メモ

main.cfに、以下のスパムメール対策を追記した場合,
以下のコマンド1を投入して、データベースの再構築をする必要がある
それを行わないと作成したメールアカウントから送受信をサーバー側で拒否される。


◻️/etc/postfix/access.dbファイルが開けないと警告が出てしまうので
以下のデータベースの作成を行う。


#local_recipient_maps =
#luser_relay = unknown_user@localhost
#disable_vrfy_command = yes



<コマンド1>

1)postfixの設定ファイルmain.cfに追記したsmtpd_client_restrictionsパラメタのcheck_client_access hash:/etc/postfix/accessのデータベースファイルがない為に警告がでているのでデータベースファイルを作成
2)smtpd_sender_restrictionsパラメタのcheck_sender_access hash:/etc/postfix/reject_senderもデータベースファイル(データベースファイルを作成する元のテキストファイルも)がないので作成


postmap /etc/postfix/access
touch /etc/postfix/reject_sender
postmap /etc/postfix/reject_sender



*****************/etc/postfix/main.cf*************************************

#_/_/_/_/_/_/  add settings  /_/_/_/_/_/#


###### MailBox ################
mailbox_size_limit = 204800000


###### SPAM Mail settings #####
smtpd_client_restrictions =
    check_client_access hash:/etc/postfix/access
    reject_rbl_client zen.spamhaus.org
    reject_non_fqdn_sender
    reject_unknown_sender_domain
smtpd_sender_restrictions =
        reject_rhsbl_sender zen.spamhaus.org
        reject_unknown_sender_domain

#local_recipient_maps =
#luser_relay = unknown_user@localhost
#disable_vrfy_command = yes



########## SMTP-Auth ##########

# Dovecot SASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
broken_sasl_auth_clients = yes


# SASL Authentication
smtpd_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd <--メールのリレー設定をしないなら追記不要(メモ1)
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_sasl_auth_enable = yes
smtp_sasl_tls_security_options = noanonymous


########## TLS/SSL ##########
smtpd_use_tls = yes
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/pki/tls/device.crt
smtpd_tls_key_file = /etc/pki/tls/device.key
smtpd_tls_CAfile = /etc/pki/tls/rootCA.pem
tls_random_source = dev:/dev/urandom

smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    reject_unauth_destination

***************************************************

postfix(スパムメール対策)について

Spamhaus.orgとはスパムメールを送信しているなど、スパムに荷担しているドメインやIPアドレスをリアルタイムに作成したリストを公開している組織です。


◻️追加している、postfixのコンフィグ(main.cf)を一部抜粋

**********/etc/postfix/main.cf********************
smtpd_client_restrictions =
    check_client_access hash:/etc/postfix/access
    reject_rbl_client zen.spamhaus.org
    reject_non_fqdn_sender
    reject_unknown_sender_domain
smtpd_sender_restrictions =
        reject_rhsbl_sender zen.spamhaus.org

        reject_unknown_sender_domain

*********************************************


メールサーバで利用されているメールアドレスを調べるために,ランダムにユーザ名を変更した沢山のメールを送りつけてくるケースもあるようです。
そこで、正しい送信者に対してメールアドレスの間違いを通知できないデメリットはありますが,unknown user が指定されたメールはメールサーバで廃棄することにしました。

◻️追加している、postfixのコンフィグ(main.cf)を一部抜粋

**********/etc/postfix/main.cf********************
local_recipient_maps =

luser_relay = unknown_user@localhost

**********************************************

2019年1月13日日曜日

postfix/dovecot(mail box)のついて

■postfix/dovecotのMailDirディレクトリ構造

<MailDir形式のディレクトリ配置>
● /home/<user>/Maildir/tmp ←一時ファイルの保存 
● /home/<user>/Maildir/new  ←新着メールの保存
● /home/<user>/Maildir/cur ←既読メールの保存


<memo>

メーラなどで「メールをサーバ上に残す」と言う設定を行うと「/home/<user>/Maildir/new」から「/home/<user>/Maildir/cur」に移動される。

「メールをサーバ上に残す」を設定しない場合、「/home/<user>/Maildir/new」から削除する動作を行う

2019年1月8日火曜日

証明書と中間証明書の生合成チェック

①②ともに同じ値であること。

$ openssl x509 -issuer_hash -noout -in [サーバ証明書].crt
8d28ae65   ->①
$ openssl x509 -subject_hash -noout -in [中間証明書].crt
8d28ae65  ->②

2019年1月3日木曜日

レジストラ(DNS)用語

◻️レジストリのデータベースへ権威ネームサーバを登録
前回BINDでDNSサーバを構築しました。その際にルートネームサーバへ、構築したDNSサーバ(権威ネームサーバ)を登録すべく設定しましたが、これだけでは名前解決はできません。他にも、ドメインを管理する「レジストリ」と呼ばれる組織にも、権威ネームサーバの情報を登録する必要があります。

◻️レジストリとレジストラ・登録代理業者の役割
DNSにおける「レジストリ」とは、登録されたドメイン名を一元管理する組織で、「comやjp」など「TLD(トップレベルドメイン)」ごとに存在します。レジストリには国ごとにルールの異なる「ccTLD(jpなど)」と、世界中で利用できる共通ルールの「gTLD(comやnetなど)」があります。具体例をいえば、jpドメインJPRScomドメインVeriSignが管理・運営しています。

レジストリ」はドメイン名とそれに属する情報のデータベースを管理し、専用のDNSサーバで情報を提供しています。名前解決をするには、このデータベースDNSサーバ(親の権威ネームサーバ)に、BINDで構築したDNSサーバ(子の権威ネームサーバ)の情報を登録する必要があります。

※レジストラとは、登録者からドメイン名の登録申請を受け付け、その登録データをレジストリのデータベースに登録する機関です。

2019年1月2日水曜日

rate-limitの設定(bind)

rate-limitの設定
アタック防止のため、optionsセクションに下記のrate-limitを追記しました。
1秒に5回以上問い合わせがあり、それが5秒以上続いた場合にブロックします。

rate-limit { responses-per-second
5; window 5; };

EFS(Dockerfile)の記載について注意

  Dockerfileにefsのマウントパス宛に、ファイルコピーを行うと ECSのサービス作成時に、コンテナのデプロイ失敗に(container run time error)になるので 別経由で、EFSにファイルをコピーした方が良い!! <Dockerfile> ...