Configure iSCSI Initiator (client) in CentOS / RHEL 6

To use RHEL/CentOS 6 system as an iSCSI initiator or client, you must have iscsi-initiator-utils package installed. You can verify that this is installed on your system using the rpm command, as shown in the following example:

$ rpm -qa | grep iscsi-initiator-utils

Install the package if its not already available on your system using yum.

# yum install iscsi-initiator-utils

Start the iscsi demaon and use chkconfig to enable it to start after reboot as well.

# service iscsi start
# chkconfig iscsi on

Once you have installed the required package and started the service you can start discovering the available targets. To Obtain a listing of available targets from a given host (please note that ipaddress listed below must be replaced with the resolvable hostname or IP address of the system providing the port if different than default):

# iscsiadm -m discovery -t st -p 192.168.10.10
192.168.10.10:3260,1 iqn.2010-03.com.example:tgtd

Continue reading “Configure iSCSI Initiator (client) in CentOS / RHEL 6” »

Share

Add Multipath and connect to XFS system

Device Mapper Multipathing (DM-Multipath) is a native multipathing in Linux, Device Mapper Multipathing (DM-Multipath) can be used for Redundancy and to Improve the Performance. It aggregates or combines the multiple I/O paths between Servers and Storage, so it creates a single device at the OS Level.

For example, Lets say a server with two HBA card attached to a storage controller with single ports on each HBA cards. One lun assigned to the single server via two wwn number of both cards. So OS detects two devices: /dev/sdb and /dev/sdc. Once we installed the Device Mapper Multipathing. DM-Multipath creates a single device with a unique WWID that reroutes I/O to those four underlying devices according to the multipath configuration. So when there is a failure with any of this I/O paths, Data can be accessible using the available I/O Path.

Install the  Device Mapper Multipath package.

Verify the device-mapper-multipath package has been installed or not.

[root@linux1 ~]# rpm -q device-mapper-multipath

If it is not installed, Install the Device Mapper Multipath package using yum to avoid dependencies issue. if yum is not configured, please refer the link Yum Configuration on Linux.

[root@linux1 ~]# yum -y install device-mapper-multipath

Basic Configuration of Linux Device Mapper Multipathing

Configuration file is /etc/multipath.conf file, take a backup of it. Edit the configuration file to ensure you have the following entries uncommented out. Continue reading “Add Multipath and connect to XFS system” »

Share

Stateful Load Balancer with iptables and NAT

Allow IP forwarding

(Note: if your testing this on the same box your doing this on it won’t work, you need at least 3 machines to test this out, virtual ones work nicely)

First we enable ipv4 forwarding or this will not work:

# echo "1" > /proc/sys/net/ipv4/ip_forward

XOR

# sysctl net.ipv4.ip_forward=1

next we add a filter that changes the packets destination ip and allows us to masquerade:

# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.0.0.3:80
# iptables -t nat -A POSTROUTING -j MASQUERADE

The above filter gets added to iptables PREROUTING chain. The packets first go through the filters in the PREROUTING chain before iptables decides where they go. The above filter says all packets input into eth0 that use tcp protocol and have a destination port 80 will have their destination address changed to 1.2.3.4 port 80. The DNAT target in this case is responsible for changing the packets Destination IP address. Variations of this might include mapping to a different port on the same machine or perhaps to another interface all together, that is how one could implement a simple stateful vlan (in theory). Continue reading “Stateful Load Balancer with iptables and NAT” »

Share

Assign range of IP addresses to an interface

For example, you need to assign the IP range 192.168.10.6 – 192.168.10.100 to your eth0 interface.

Create a range file in /etc/sysconfig/network-scripts/ifcfg-eth0-range0 as below

DEVICE=eth0
BOOTPROTO=static
IPADDR_START=192.168.10.6
IPADDR_END=192.168.10.100
NETMASK=255.255.255.0
CLONENUM_START=1
ONBOOT=yes
TYPE=Ethernet

CLONENUM_START is the number that will be assigned to the first IP alias interface (eth0:1 in this example).

If you need to add more ranges of IPs then just use a different file for eg. ifcfg-eth0-range1, for each one of the ranges. Make sure CLONENUM_START does not overwrite other aliases.

Once you have configured the range/s of IPs you just need to restart the network service in order to activate it

Share

Reset CentOS Root Lost or Forgotten Password

In the event your Linux box experiences disk or file system issues you may receive a “Give root password for maintenance” prompt upon reboot. If you have your root password you can login but in the event your using ‘slide’ or ‘sudo’ for wheel access or you’ve just mis-placed your root password – you’ll need to reset it.

To reset your root password:

  1. When the GRUB loader shows during boot press the spare bar to pause boot.
  2. Select your boot kernel.
  3. Type ‘e’ to edit the default kernel line.
  4. Type ‘e’ again on the line that starts with ‘kernel’.
  5. Add ‘init=/bin/bash’ to the end of the ‘kernel’ line then press enter.
  6. Type ‘b’ to boot the modified kernel parameters.
  7. Once you’re at the /bin/bash prompt you will need to remount the root file system as read/write in order to edit the passwd file:
    # mount -o remount,rw /
  8. Change your root password:
    # passwd root
  9. Remount the filesystem back to read only:
    # mount -o remount,ro /
  10. Reboot your server using CTR-ALT-DELETE.
  11. You will now be able to login with your new root password and carry out the maintenance.
Share

Install Cacti 1.1 on CentOS 7

Cacti is a free and open source network monitoring and graphing tool written in PHP. With the help of RRDtool (Round-Robin database tool), Cacti can be used to provide various useful features, including remote and local data collectors, graph templating, network discovery, device management automation, etc.

Prerequisites
A fresh CentOS 7 x64 server instance. Say its IP address is 1.2.3.4.
A sudo user.
The server instance has been updated to the latest stable status using the EPEL YUM repo.

Step 1: Setup an up to date LAMP stack
Before you can properly install and run Cacti, you need to setup a LAMP stack or an equivalent web operating environment.

The following will set up an up to date LAMP stack for Cacti, which consists of CentOS 7, Apache 2.4, MariaDB 10.2, and PHP 7.1

# Install Apache 2.4
sudo yum install httpd -y
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Continue reading “Install Cacti 1.1 on CentOS 7” »

Share

Mail Sync between 2 mailservers using Imapsync

Imapsync is an IMAP transfer tool used for copying emails from one IMAP server to another IMAP server. This article will help you to install imapsync on Ubuntu, Debian, and LinuxMint systems and transfer all your Mailboxes and emails between two IMAP servers.

Step 1 – Install Imapsync
Imapsync package is available under EPEL package repository. First make sure you have added EPEL on your system or install it first.

$ sudo yum install epel-release

Now, install imapsync package using following command. Continue reading “Mail Sync between 2 mailservers using Imapsync” »

Share

Linux Router- No NAT

I assume you have one public IP address for your WAN side, and a block for the LAN side, something like this:

ISP-----ROUTER ETH0/ROUTER ETH1------SWITCH------PCs

You NEED to have a public IP address for the WAN interface, ISP will route the subnet they have given you through this IP address. Simply you need to set the forwarding bit to 1

echo 1 > /proc/sys/net/ipv4/ip_forward

To make it persistent you need to edit /etc/sysctl.conf, find this line: Continue reading “Linux Router- No NAT” »

Share

Install iRedmail on a CentOS 6.8 server

We need to set a FQDN hostname before we set up the mail server. On CentOS Linux, hostname is set in two files: Hostname setting:

nano /etc/sysconfig/network

# Part of file: /etc/sysconfig/network

HOSTNAME=demo.iredmail.org

Hostname <=> IP address mapping: /etc/hosts. WARNING: Please list the FQDN hostname as the first item.

# Part of file: /etc/hosts

127.0.0.1 demo.iredmail.org demo localhost localhost.localdomain

Verify the FQDN hostname with command ‘hostname -f’. If you change the hostname, please reboot the server to make it work. Continue reading “Install iRedmail on a CentOS 6.8 server” »

Share

Install Mailtrain Bulk Mailer Application on CentOS 7

Requirements
Metabase requires at least 1GB of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Update Base System
Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Install Node.js
Node.js is required by Mailtrain as it is built using Nodemailer. Node.js is a very popular JavaScript runtime and Nodemailer is a module for Node.js applications to send emails.

Add Node.js 8.x repository:

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -

Install Node.js.

yum -y install nodejs

Install MariaDB
To store Mailtrain database we will need to install MariaDB. MariaDB is a fork of MySQL
Install MariaDB repository into your system. Continue reading “Install Mailtrain Bulk Mailer Application on CentOS 7” »

Share