Configure the PTR record on the DNS server

It was necessary to somehow configure the Reverse DNS zone for the mail server, since some servers did not want to receive mail from it.

Let’s assume our domain mail.example.com located on the IP address 192.168.1.100, and 192.168.1.1 – the server of the Internet provider.

You can check from Windows with commands (where 192.168.1.100 for example is the address of our mail server, and 192.168.1.1 DNS on which the request is sent):

nslookup mail.example.com
nslookup 192.168.1.100
nslookup 192.168.1.100 192.168.1.1

In response, the first command will be 192.168.1.100, and in response the second one is nothing (it should be mail.example.com), since the PTR record is not configured in DNS.

From Linux, you can check:

dig -x 192.168.1.100

At the registrar of domain names in DNS we will add the NS-server of the Internet provider ns1.example.com 192.168.1.1.

On the provider’s server (on the test I use Bind9 on Ubuntu Server), open the DNS configuration file for example in the nano editor (CTRL+X for exit, y/x and Enter for saving or canceling changes):

sudo nano /etc/bind/named.conf

And add the following lines:

zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/1.168.192.in-addr.arpa";
};

The first line indicates which zone we will manage, the second type – the main one (this DNS will manage it), the third one – in which file the configuration for this zone will be registered.

Open a new file for zone settings:

sudo nano /etc/bind/1.168.192.in-addr.arpa

And add to it:

$TTL 3600
@          IN SOA ns1.example.com. admin.example.com. (
              2016112301       ; Serial
              21600             ; refresh
              3600              ; retry
              3600000           ; expire
              86400 )           ; minimum

        IN  NS ns1.hosting.com.
        IN  NS ns2.hosting.com.

$ORIGIN 1.168.192.in-addr.arpa.
100      IN PTR  mail.example.com.

admin.example.com – the contact address of the person responsible for the zone, the @ symbol is not indicated.
Serial – this is the serial number of the zone file version, it should change to the big side with each change, it is usually written in the form of the year month the number is the number of the change, according to it other DNS determine that it is necessary to update the information.
Refresh – the time interval in seconds through which the secondary server will check whether the information needs to be updated.
Retry – the time interval in seconds through which the secondary server will retry calls on failure.
Expire – the time interval in seconds through which the secondary server will consider the information it has obsolete.
Minimum – the interval of information lifetime on caching servers.
ns1.hosting.com and ns2.hosting.com this is the DNS of this domain.
The number 100 in the last line means the end of IP address 192.168.1, similarly you can specify entries for other domains, for example 101 IN PTR … for 192.168.1.101, etc.

Restart the DNS server to apply the changes.
Bind9 can be commanded by:

sudo /etc/init.d/bind9 restart

Done.

See also:
Configuring Reverse DNS (PTR) in Hetzner

Installing and using ioping

ioping – a simple tool for monitoring disk I/O delays in real time, similar to ping showing network latency.

You can install in Ubuntu / Debian using the command:

sudo apt-get install ioping

Here is an example of a run with 10 requests for a delay test to the / tmp directory:

ioping -c 10 /tmp

An example of a query with an interval of 0.2ms and an increased query size:

ioping -i 0.2 -c 10 -s 1M -S 5M /tmp

Test to disk:

ioping -R /dev/sda
ioping -RL /dev/sda

I’ll describe the possible startup options:
-c count (stop after the specified number of requests)
-w deadline (stop after the specified amount of time)
-p period (display raw statistics after each specified number of requests)
-P period (display raw statistics after each specified number of seconds)
-i interval (the interval between requests in seconds)
-s size (request size (4k))
-S size (size of the working set)
-k (after the command is finished, leave (do not delete) the working file ioping.tmp)
-L (sequential operations instead of random ones, this will also set the query size to 256k (like -s 256k))
-A (asynchronous I/O)
-C (cached I/O)
-D (straight I/O)
-B (do not display execution information, it will only appear when the command is finished in raw format)
-q (do not display execution information, it will be displayed only when the command completes)
-h (display help)
-v (view version)

How to enable SMTP without SSL on port 25 in iRedMail / Postfix

To allow the sending of messages on the mail server without encryption via port 25, you need to open the Postfix configuration file, for example, in the nano editor (in which Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/postfix/main.cf

And uncomment two lines:

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous

And leave the commented line:

#smtpd_tls_auth_only=yes

Reload Postfix to apply the changes:

sudo service postfix restart

After that it will be possible to send messages via SMTP through port 25 without SSL, and as usual through 587 with SSL.

See also:
Allow insecure connections to POP3 / IMAP iRedMail

How to fix error “host NAME greeted me with my own hostname NAME”

I noticed once on one server that Postfix does not always send mail, the logs had the following error:

warning: host NAME[192.168.5.5]:25 greeted me with my own hostname NAME

After seeing the host name:

hostname -f

Found that it is not correct and coincides with that on which the mail is sent!

Changed the host name to the correct one in the following files (in the nano editor Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/hostname
sudo nano /etc/postfix/main.cf
sudo nano /etc/hosts

Done, after that the error did not appear and the mail was successfully delivered.

Redmine Backup

Create a script (in the text editor nano Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/cron.daily/redmine

Sample script content:

#!/bin/sh
/usr/bin/mysqldump -u root -p<password> redmine_default | gzip > /path/to/backups/redmine_db_`date +%y_%m_%d`.gz
rsync -a /var/lib/redmine/default/files /path/to/backups/files

Let’s make the script executable:

chmod +x /etc/cron.daily/redmine

In the script, you can also add the command to delete old files or directories so that the disk does not overflow, see my article – Script to delete old files

See also other my articles about backup – Backup

How to fix error “dhcpd self-test failed. Please fix the config file”

I noticed once in the syslog:

dhcpd self-test failed. Please fix the config file

Isc-dhcp-server was installed on the server.

To check the correctness of the configuration file, use the command:

dhcpd -t
dhcpd -t -cf /dir/dhcpd.conf
/usr/sbin/dhcpd -t

The command should tell which line the error is, but noted that if it is not critical, it may not.
The key “t” executes the configuration test, and “cf” allows you to specify the path to the configuration file if it is not standard.

In my case, in the configuration file /etc/dhcp/dhcpd.conf, someone made a typo, in the line below (there was an extra letter):

authorivtative;

Because of this, an error occurred, but despite the error dhcp worked.
Although there were also some critical errors, such as an incorrectly written mac address, DHCP did not start because of this error.