2014年1月20日月曜日

[CentOS] Postfix (MTA: Mail transfer agent) インストール

  1. yum を使ってパッケージをインストールする
    # yum -y install postfix
  2. postfix の設定 (/etc/postfix/main.cf)
    • サーバーのホスト名を追加
      # INTERNET HOST AND DOMAIN NAMES
      #
      # The myhostname parameter specifies the internet hostname of this
      # mail system. The default is to use the fully-qualified domain name
      # from gethostname(). $myhostname is used as a default value for many
      # other configuration parameters.
      #
      #myhostname = host.domain.tld
      #myhostname = virtual.domain.tld
      myhostname = testserver.local ★
    • ドメイン名を追加
      # The mydomain parameter specifies the local internet domain name.
      # The default is to use $myhostname minus the first component.
      # $mydomain is used as a default value for many other configuration
      # parameters.
      #
      #mydomain = domain.tld
      mydomain = local ★
    • ローカルからメールを送る時に送信元メールアドレスの @ 以降に追加するドメイン名を指定
      # SENDING MAIL
      #
      # The myorigin parameter specifies the domain that locally-posted
      # mail appears to come from. The default is to append $myhostname,
      # which is fine for small sites.  If you run a domain with multiple
      # machines, you should (1) change this to $mydomain and (2) set up
      # a domain-wide alias database that aliases each user to
      # user@that.users.mailhost.
      #
      # For the sake of consistency between sender and recipient addresses,
      # myorigin also specifies the default domain name that is appended
      # to recipient addresses that have no @domain part.
      #
      myorigin = $myhostname ★
      #myorigin = $mydomain
    • メールボックス形式を Maildir にする
      # DELIVERY TO MAILBOX
      #
      # The home_mailbox parameter specifies the optional pathname of a
      # mailbox file relative to a user's home directory. The default
      # mailbox file is /var/spool/mail/user or /var/mail/user.  Specify
      # "Maildir/" for qmail-style delivery (the / is required).
      #
      #home_mailbox = Mailbox
      home_mailbox = Mail/ ★
    • 外部からのメール受信を許可する
      # The inet_interfaces parameter specifies the network interface
      # addresses that this mail system receives mail on.  By default,
      # the software claims all active interfaces on the machine. The
      # parameter also controls delivery of mail to user@[ip.address].
      #
      # See also the proxy_interfaces parameter, for network addresses that
      # are forwarded to us via a proxy or network address translator.
      #
      # Note: you need to stop/start Postfix when this parameter changes.
      #
      #inet_interfaces = all
      #inet_interfaces = $myhostname
      #inet_interfaces = $myhostname, localhost
      #inet_interfaces = localhost
      inet_interfaces = all ★
    • 自ドメイン宛メールを受信できるようにする
      # The mydestination parameter specifies the list of domains that this
      # machine considers itself the final destination for.
      #
      # These domains are routed to the delivery agent specified with the
      # local_transport parameter setting. By default, that is the UNIX
      # compatible delivery agent that lookups all recipients in /etc/passwd
      # and /etc/aliases or their equivalent.
      #
      # The default is $myhostname + localhost.$mydomain.  On a mail domain
      # gateway, you should also include $mydomain.
      #
      # Do not specify the names of virtual domains - those domains are
      # specified elsewhere (see VIRTUAL_README).
      #
      # Do not specify the names of domains that this machine is backup MX
      # host for. Specify those names via the relay_domains settings for
      # the SMTP server, or use permit_mx_backup if you are lazy (see
      # STANDARD_CONFIGURATION_README).
      #
      # The local machine is always the final destination for mail addressed
      # to user@[the.net.work.address] of an interface that the mail system
      # receives mail on (see the inet_interfaces parameter).
      #
      # Specify a list of host or domain names, /file/name or type:table
      # patterns, separated by commas and/or whitespace. A /file/name
      # pattern is replaced by its contents; a type:table is matched when
      # a name matches a lookup key (the right-hand side is ignored).
      # Continue long lines by starting the next line with whitespace.
      #
      # See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
      #
      #mydestination = $myhostname, localhost.$mydomain, localhost
      mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
      #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
      #       mail.$mydomain, www.$mydomain, ftp.$mydomain
  3. sendmail を停止する
    # /etc/rc.d/init.d/sendmail stop
    sm-client を停止中:                                        [  OK  ]
    sendmail を停止中:                                         [  OK  ]
    # chkconfig sendmail off
    # chkconfig --list sendmail
    sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off
  4. システムで使用するメールサーバー機能を sendmail から Postfix に切り替える
    # alternatives --config mta
    
    2 プログラムがあり 'mta' を提供します。
    
      選択       コマンド
    -----------------------------------------------
    *+ 1           /usr/sbin/sendmail.sendmail
       2           /usr/sbin/sendmail.postfix
    
    Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
  5. Postfix 起動
    # /etc/rc.d/init.d/postfix start
    postfix を起動中:                                          [  OK  ]
  6. Postfix を自動起動するように設定する
    # chkconfig postfix on
    # chkconfig --list postfix
    postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off

2014年1月12日日曜日

[CentOS] vsftpd インストール

  1. yum を使ってパッケージをインストールする
    # yum -y install vsftpd
  2. vsftpd の設定 (/etc/vsftpd/vsftpd.conf)
    • 変更前
      # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
      anonymous_enable=YES
    • 変更後 (anonymous ユーザーのログインを禁止する)
      # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
      anonymous_enable=NO
  3. vsfptd 起動
    # /etc/rc.d/init.d/vsftpd start
    vsftpd 用の vsftpd を起動中:                               [  OK  ]
  4. vsftpd を自動起動するように設定する
    # chkconfig --list vsftpd
    vsftpd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
    # chkconfig vsftpd on
    # chkconfig --list vsftpd
    vsftpd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
  5. 動作確認
    FTP クライアントソフトを使用してサーバーに FTP 接続できることを確認する

[CentOS] yum で proxy を使う

  1. /etc/yum.conf に以下を記載
    # proxy setting
    proxy=http://proxyserver.local:8080
    proxy_username=username
    proxy_password=password
  2. 動作確認
    # yum update