ToiVietBlog - Trong bài viết trước, bạn đã chuẩn bị xong một server để cài đặt Zimbra. Bây giờ, chúng ta sẽ tiếp tục cài đặt NTP và DNS cho máy chủ mail.
Cài đặt và thiết lập dịch vụ NTP cho server mail Zimbra
Có một dịch vụ mà rất nhiều người thường bỏ qua khi cài đặt đó là NTP. Mặc dù khi cài đặt OS CentOS 7 thì nó sẽ hỏi bạn chọn time zone cho máy chủ.
Tuy nhiên, khi chọn time zone khi cài đặt OS không phải lúc nào cũng hoạt động đúng như bạn mong muốn.
Bạn gõ lệnh dưới đây để cài đặt gói NTP.
[[email protected] ~]# yum install ntp -y
Tiếp theo, bạn kích hoạt và khởi động dịch vụ NTP.
[[email protected] ~]# systemctl enable ntpd && systemctl start ntpd
Bây giờ bạn có thể kiểm tra xem dịch vụ đã hoạt động hay chưa với lệnh dưới đây.
[email protected] ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *time.vng.vn 133.243.238.164 2 u 718 1024 377 12.599 0.500 1.271
Cài đặt và thiết lập DNS cho server mail Zimbra
Tôi đã gặp khá nhiều lỗi khi cài đặt Zimbra, hầu hết đều liên quan đến vấn đề DNS.
Trong Zimbra, nó có một thành phần tên là Zimbra-DNSCache. Gói thành phần này sẽ cài đặt DNS local trên máy chủ MTA. Điều này giúp cho truy vấn DNS ra internet được nhanh hơn.
Tuy nhiên, khi chúng ta cài đặt Zimbra single server, MTA cũng nằm trên đó. Bởi vì vậy, khi cài Zimbra thì chúng ta cần phải cài đặt DNS server và nó sẽ nằm ngay trên server Zimbra.

Bạn gõ lệnh dưới để cài đặt DNS.
[email protected] ~]# yum install bind bind-utils -y
Cấu hình /etc/named.conf
Tiếp theo, bạn chỉnh sửa tập tin /etc/named.conf
như dưới đây.
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // // See the BIND Administrator's Reference Manual (ARM) for details about the // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html options { listen-on port 53 { 127.0.0.1; 192.168.100.10; }; listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; recursing-file "/var/named/data/named.recursing"; secroots-file "/var/named/data/named.secroots"; allow-query { localhost; 192.168.100.10; }; /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; dnssec-enable yes; dnssec-validation yes; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; forwarders { 8.8.8.8; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "toivietblog.com" { type master; file "toivietblog.com.zone"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
Vui lòng để ý đến các dòng sau trong file /etc/named.conf
.
listen-on port 53 { 127.0.0.1; 192.168.100.10; };
: bạn thêm địa chỉ IP của máy chủ mail vào dòng này.allow-query { localhost; 192.168.100.10; };
: thêm địa chỉ IP của máy chủ mail vào dòng này.forwarders { 8.8.8.8; };
: thêm dòng này vào cuối block options.- Bạn thêm zone cho domain của bạn.
zone "toivietblog.com" { type master; file "toivietblog.com.zone"; };
Tạo tập tin domain zone
Bây giờ, bạn tạo tập tin zone cho domain của bạn, sử dụng lệnh dưới.
[[email protected] ~]# nano /var/named/toivietblog.com.zone
Sau đó, bạn thêm nội dung sau vào tập tin và lưu lại. Lưu ý rằng bạn cần thay đổi các thông tin cho phù hợp với máy chủ và domain của bạn.
; ; BIND data file for local loopback interface ; $TTL 86400 @ IN SOA ns1.toivietblog.com. root.toivietblog.com. ( 10118 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; ; name servers - NS records @ IN NS ns1.toivietblog.com. @ MX 10 mail.toivietblog.com. ; name servers - A records ns1 IN A 192.168.100.10 mail IN A 192.168.100.10
Khởi động dịch vụ DNS và kiểm tra bản ghi
Bạn sử dụng lệnh dưới đây để kích hoạt và khởi động dịch DNS.
[[email protected] ~]# systemctl enable named && systemctl start named
Bây giờ, bạn có thể kiểm tra việc phân giải bản ghi DNS bằng 2 lệnh dưới đây.
[[email protected] ~]# dig -t A mail.toivietblog.com [[email protected] ~]# dig -t MX toivietblog.com
Hoặc với lệnh này.
[[email protected] ~]# dig toivietblog any
Kết luận
Trong bài viết này thì mình đã hướng dẫn bạn cài đặt 2 dịch vụ pre-install cho máy chủ mail Zimbra. Mặc dù 2 dịch vụ không trực tiếp cung cấp dịch vụ mail nhưng lại có ảnh hưởng trực tiếp tới dịch vụ mail. Với NTP thì có thể gây ra lỗi sai giờ gửi-nhận mail. Với DNS thì có thể gây ra lỗi không thể gửi-nhận mail do sai domain. Vì vậy, bạn hãy làm đúng các bước này nhé.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.