Senin, 16 Desember 2019

How to install Fail2Ban on CentOS 7

Most Linux servers offer an SSH login via Port 22 for remote administration purposes. This port is a well-known port, therefore, it is often attacked by brute force attacks. Fail2ban is a software that scans log files for brute force login attempts in real-time and bans the attackers with firewalld or iptables. Fail2ban recognizes unwanted access or security breach efforts to the server within the administrator set time frame and blocks the IP addresses which show signs of brute force attacks or dictionary attacks. This program works in the background and continuously scans the log files for unusual login patterns and security breach attempts.
This tutorial shows the installation and configuration of Fail2Ban with firewalld on CentOS 7.

Installing Fail2Ban

To install Fail2Ban on CentOS 7, we will have to install EPEL (Extra Packages for Enterprise Linux) repository first. EPEL contains additional packages for all CentOS versions, one of these additional packages is Fail2Ban.
The following commands must be executed after switching to the root user.
yum install epel-release
yum install fail2ban fail2ban-systemd
If you have SELinux installed, then update the SELinux policies:
yum update -y selinux-policy*

Configure settings for Fail2Ban

Once installed, we will have to configure and customize the software with a jail.local configuration file. The jail.local file overrides the jail.conf file and is used to make your custom configuration update safe.
Make a copy of the jail.conf file and save it with the name jail.local:
cp -pf /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
Open the jail.local file for editing in Nano with the following command.
nano /etc/fail2ban/jail.local
The file code may consist of many lines of codes which execute to prevent a ban on one or many IP addresses, set bantime duration, etc. A typical jail configuration file contains the following lines.
[DEFAULT]

#
# MISCELLANEOUS OPTIONS
#

# "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not
# ban a host which matches an address in this list. Several addresses can be
# defined using space separator.
ignoreip = 127.0.0.1/8

# External command that will take an tagged arguments to ignore, e.g. <ip>,
# and return true if the IP is to be ignored. False otherwise.
#
# ignorecommand = /path/to/command <ip>
ignorecommand =

# "bantime" is the number of seconds that a host is banned.
bantime = 600

# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 600

# "maxretry" is the number of failures before a host get banned.
maxretry = 5
Ignoreip is used to set the list of IPs which will not be banned. The list of IP addresses should be given with a space separator. This parameter is used to set your personal IP address (if you access the server from a fixed IP).
Bantime parameter is used to set the duration of seconds for which a host needs to be banned.
Findtime is the parameter which is used to check if a host must be banned or not. When the host generates maxrety in its last findtime, it is banned.
Maxretry is the parameter used to set the limit for the number of retry's by a host, upon exceeding this limit, the host is banned.

Add a jail file to protect SSH.

Create a new file with the Nano editor
nano /etc/fail2ban/jail.d/sshd.local
To the above file, add the following lines of code.
[sshd]
enabled = true
port = ssh
#action = firewallcmd-ipset
logpath = %(sshd_log)s
maxretry = 5
bantime = 86400
Parameter enabled is set to true, in order to provide protection, to deactivate protection, it is set to false. The filter parameter checks the sshd configuration file, located in the path /etc/fail2ban/filter.d/sshd.conf.
The parameter action is used to derive the IP address which needs to be banned using the filter available from /etc/fail2ban/action.d/firewallcmd-ipset.conf.
Port parameter may be changed to a new value such as port=1212, as is the case. When using port 22, there is no need to change this parameter.
Logpath provides the path where the log file is stored. This log file is scanned by Fail2Ban.
Maxretry is used to set the maximum limit for failed login entries.
Bantime parameter is used to set the duration of seconds for which a host needs to be banned.

Running Fail2Ban service

When you are not running the CentOS Firewall yet, then start it:
systemctl enable firewalld
systemctl start firewalld
Execute the following lines of command to run the protective Fail2Ban software on the server.
systemctl enable fail2ban
systemctl start fail2ban 

Tracking Failed login entries

The following command is used to check whether there had been failed attempts to login to sever via ssh port.
cat /var/log/secure | grep 'Failed password'
Executing the above command will get a list of failed root password attempts from different IP addresses. The format of results will be similar to the one showed below:
Apr 4 17:05:12 htf sshd[4287]: Failed password for root from 108.61.157.25 port 23121 ssh2
Apr 4 17:05:15 htf sshd[3154]: Failed password for root from 108.61.157.25 port 14486 ssh2
Apr 4 17:05:16 htf sshd[3154]: Failed password for root from 108.61.157.25 port 24157 ssh2
Apr 4 17:05:18 htf sshd[3154]: Failed password for root from 108.61.157.25 port 24157 ssh2

Checking the banned IPs by Fail2Ban

The following command is used to get a list of banned IP addresses which were recognized as brute force threats.
iptables -L -n

Check the Fal2Ban Status

Use the following command to check the status of the Fail2Ban jails:
fail2ban-client status
The result should be similar to this:
[root@htf ]# fail2ban-client status
Status
|- Number of jail: 1
`- Jail list: sshd

Unbanning an IP address

In order to remove an IP address from the banned list, parameter IPADDRESS is set to appropriate IP which needs unbanning. The name "sshd" is the name of the jail, in this case the "sshd" jail that we configured above. The following command does the job.
fail2ban-client set sshd unbanip IPADDRESS

Kamis, 21 November 2019

clear dhcp server binding on Juniper (JunOS)

Syntax

content_copy zoom_out_map
clear dhcp server binding
<address>
<all>
<interface interface-name>
<interfaces-vlan>
<interfaces-wildcard>
<logical-system logical-system-name>
<routing-instance routing-instance-name>
<dual-stack>

Release Information

Command introduced in Junos OS Release 9.0.
Options interfaces-vlan and interfaces-wildcard added in Junos OS Release 12.1.
Command updated with dual-stack statement in Junos OS Release 17.3.

Description

Clear the binding state of a Dynamic Host Configuration Protocol (DHCP) client from the client table on the extended DHCP local server.
Note
If you delete the DHCP server configuration, DHCP server bindings might still remain. To ensure that DHCP bindings are removed, issue the clear dhcp server binding command before you delete the DHCP server configuration.

Options

address(Optional) Clear the binding state for the DHCP client, using one of the following entries:
  • ip-address—The specified IP address.
  • mac-address—The specified MAC address.
  • session-id—The specified session ID.
all(Optional) Clear the binding state for all DHCP clients.
interface interface-name(Optional) Clear the binding state for DHCP clients on the specified interface.
Note
This option clears all bindings whose initial login requests were received over the specified interface. Dynamic demux login requests are not received over the dynamic demux interface, but rather the underlying interface of the dynamic demux interface. To clear a specific dynamic demux interface, use the ip-address or mac-address options.
interfaces-vlan(Optional) Clear the binding state on the interface VLAN ID and S-VLAN ID.
interfaces-wildcard(Optional) Clear bindings on a set of interfaces. This option supports the use of the wildcard character (*).
logical-system logical-system-name(Optional) Clear the binding state for DHCP clients on the specified logical system.
routing-instance routing-instance-name(Optional) Clear the binding state for DHCP clients on the specified routing instance.
dual-stack(Optional) Remove either both arms or single arm of dual-stack.
Note
  • The dual-stack command is added in the syntax removes both arms of the dual-stack with a single command entry.
  • When the dual-stack command is not added in the syntax, the clear dhcpv6 server binding command clears only the family specific arm of the dual-stack.

Required Privilege Level

view

List of Sample Output

clear dhcp server binding <ip-address>
clear dhcp server binding all
clear dhcp server binding interface
clear dhcp server binding <interfaces-vlan>
clear dhcp server binding <interfaces-wildcard>
clear dhcp server binding dual-stack all

Output Fields

See show dhcp server binding for an explanation of output fields.

Sample Output

clear dhcp server binding <ip-address>
The following sample output displays the address bindings in the DHCP client table on the extended DHCP local server before and after the clear dhcp server binding command is issued.
user@host> show dhcp server binding
content_copy zoom_out_map
2 clients, (0 bound, 0 selecting, 0 renewing, 0 rebinding)

IP address       Hardware address   Type     Lease expires at
198.51.100.1      00:00:5e:00:53:01  active   2007-01-17 11:38:47 PST
198.51.100.3      00:00:5e:00:53:02  active   2007-01-17 11:38:41 PST

user@host> clear dhcp server binding 198.51.100.1
content_copy zoom_out_map
user@host> show dhcp server binding
content_copy zoom_out_map
1 clients, (0 bound, 0 selecting, 0 renewing, 0 rebinding)

IP address       Hardware address   Type     Lease expires at
198.51.100.3      00:00:5e:00:53:02  active   2007-01-17 11:38:41 PST

clear dhcp server binding all
The following command clears all DHCP local server bindings:
user@host> clear dhcp server binding all
content_copy zoom_out_map
clear dhcp server binding interface
The following command clears DHCP local server bindings on a specific interface:
user@host> clear dhcp server binding interface fe-0/0/2
content_copy zoom_out_map
clear dhcp server binding <interfaces-vlan>
The following command uses the interfaces-vlan option to clear all DHCP local server bindings on top of the underlying interface ae0, which clears DHCP bindings on all demux VLANs on top of ae0:
user@host> clear dhcp server binding ae0
content_copy zoom_out_map
clear dhcp server binding <interfaces-wildcard>
The following command uses the interfaces-wildcard option to clear all DHCP local server bindings over a specific interface:
user@host> clear dhcp server binding ge-1/0/0.*
content_copy zoom_out_map
clear dhcp server binding dual-stack all
The following command clears all the dual-stack local server bindings.
user@host> clear dhcp server binding dual-stack all

Selasa, 12 November 2019

Setting Mesin absensi Solution X103C

Untuk memulai setting awal pada mesin ansensi X103c ini silahkan menekan agak lama tombol M/OK, hingga muncul menu dengan icon User, Comm, System dan lain-lain.
Selanjutnya pilih menu User dengan tombol M/OK.
Silahkan membuat user baru misal:
No Id=1
Pwd silahkan isi dengan 4 angka, kemudian rulenya pilih Admin.
Silahkan simpan user baru ini.
Untuk selanjutnya saat anda masuk ke menu utama dengan menekan agak lama tombol M/OK maka akan ditanyakan username dan password ini.
Web server default ada di 192.168.1.201 dan silahkan login dengan username dan password yang baru saja dibuat tersebut.
Untuk mengganti IP Address dari device silahkan masuk ke menu Comm – Jaringan.
Untuk melakukan setting communication key yang akan dipakai dalam konektifitas silahkan masuk menu Comm – Keamanan

Rabu, 25 September 2019

Tips Blacklists dan Whitelists Zimbra

Pada artikel Tips Blacklists dan Whitelists Zimbra akan menjelaskan bagaimana cara yang mudah untuk kita melakukan blacklist maupun whitelist dari seluruh email yang masuk berdasarkan address atau domain. Whitelist sendiri artinya memperbolehkan atau mem-bypass dari seluruh filtering, baik email tersebut spam ataupun bukan spam. Sedangkan blacklist artinya melakukan penolakan email yang berasal dari email sender atau domain.

Zimbra 8.5 dan seterusnya

Pada versi 8.5 dan versi-versi seterusnya, ada perubahan pada tata letak konfigurasi. Pada versi ini konfigurasi dipindah ke /opt/zimbra/data/spamassassin/localrules
Buat file baru dengan nama sauser.cf pada directory tersebut dan isi file dengan format seperti berikut.

blacklist_from sales@traveloforange.com
whitelist_from bill@yahoo.net
blacklist_from *@emn-mysavingsnow.net

Jika sudah, restart service amavisd dengan menggunakan user zimbra.

zmamavisdctl restart