Get Public/External IP Address

There are some URLs which are able to return the public/external IP address of your machines.

Get the public/external IP via command line using http services (any one of the followings):
$ curl http://checkip.amazonaws.com
$ curl http://whatismyip.akamai.com

Get the public/external IP via command line using dns services (any one of the followings):
$ dig myip.opendns.com @resolver1.opendns.com +short
$ dig whoami.akamai.net @ns1-1.akamaitech.net +short

MySQL configurations on 1GB RAM Ubuntu

By default, standard MySQL configurations presume the hosting machine having at least 8GB RAM. If the MySQL hosting machine having RAM lower than 8GB, the MySQL configuration parameters must be adjust to prevent memory over use; otherwise, the MySQL service will go down or be crashed from time to time. Please refer to the following sample settings for /etc/mysql/my.cnf for a VPS machine only having 1GB memory.

$ cat /etc/mysql/my.cnf
 #
 The MySQL database server configuration file.
 #
 You can copy this to one of:
 - "/etc/mysql/my.cnf" to set global options,
 - "~/.my.cnf" to set user-specific options.
  
 One can use all long options that the program supports.
 Run program with --help to get a list of available options and with
 --print-defaults to see which it would actually understand and use.
 #
 For explanations see
 http://dev.mysql.com/doc/mysql/en/server-system-variables.html
 #
 * IMPORTANT: Additional settings that can override those from this file!
 The files must end with '.cnf', otherwise they'll be ignored.
 #
 [mysqld]
 innodb_buffer_pool_size=5M
 innodb_log_buffer_size=256K
 query_cache_size=0
 max_connections=10
 key_buffer_size=1M
 thread_cache_size=0
 host_cache_size=0
 innodb_ft_cache_size=1600000
 innodb_ft_total_cache_size=32000000
 per thread or per operation settings
 thread_stack=131072
 sort_buffer_size=32K
 read_buffer_size=8K
 read_rnd_buffer_size=8K
 max_heap_table_size=16K
 tmp_table_size=1K
 bulk_insert_buffer_size=0
 join_buffer_size=128
 net_buffer_length=1K
 innodb_sort_buffer_size=64K
 settings that relate to the binary log (if enabled)
 binlog_cache_size=4K
 binlog_stmt_cache_size=4K
 !includedir /etc/mysql/conf.d/
 !includedir /etc/mysql/mysql.conf.d/

fail2ban: Ubuntu Basic Configuration with UFW

Installation

# sudo apt-get install fail2ban

Prepare main configuration file

# sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

Edit the configuration file jail.local, the following parameters can be adjusted

bantime = 720m # How long to block an abusive IP
findtime = 120m # Time period to check the connections
maxretry = 3 # Within the above time period, block the abusive IP if the number of the abusive IP connections reaches the maxretry
banaction = ufw
banaction_allports = ufw
destemail = [email protected]
sender = [email protected]
ignoreip = 127.0.0.1/8 ::1 # Ignore these IP, Hosts, IP ranges during operation

Turn on jails by editing /etc/fail2ban/jail.d/defaults-debian.conf, sshd is enabled by default, here we turn on postfix jail as well

[sshd]
enabled = true
[postfix]
enabled = true

Adjust the filter mode in jail.local, here for example we adjust the postfix filter mode to aggressive for stricter filter

[postfix]
mode    = aggressive

Restart or reload fail2ban

# sudo service fail2ban restart
# sudo service fail2ban reload

Check fail2ban status

# sudo fail2ban-client status
# sudo fail2ban-client status sshd

Change Ubuntu server timezone

Check current timezone
# timedatectl
List all available timezones
# timedatectl list-timezones

Or you may limit the results by the following command:

# timedatectl list-timezones | grep [Your Region/Location]
Set the preferred timezone
# sudo timedatectl set-timezone [One of the available timezones]
Check whether timezone is correct
# timedatectl