Configuring Network Settings

Configuring Selinux

You’ll have to set Selinux mode to “disabled” by configuring the selinux file located in /etc/sysconfig directory.

Open the file and make changes:-

sudo vi /etc/sysconfig/selinux

Update the following line:-

SELINUX=disabled

Save the file and exit.

Reboot the machine.

sudo reboot

Disabling the Firewall

To disable the firewall on each host in your cluster, perform the following steps on each host.

For iptables, save the existing rule set:

sudo iptables-save > ~/firewall.rules

Disable the firewall:

RHEL 7 compatible:

sudo systemctl disable firewalld
sudo systemctl stop firewalld

Set Static Hostname and edit Network Configuration

sudo hostnamectl set-hostname datacouch.training.io --static

Now verify…

hostname -f

Create and edit a file /usr/sbin/hosts.sh and set it executable

sudo touch /usr/sbin/hosts.sh
sudo chmod 755 /usr/sbin/hosts.sh
sudo vi /usr/sbin/hosts.sh

Paste the below script in hosts.sh

#!/bin/sh
#
# Script to determine the FQDN of a node in GCP and update hosts file
#
sudo hostnamectl set-hostname datacouch.training.io --static
myhost=`hostname -f`
ipaddr=`ifconfig eth0 | grep "inet " | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | head -1`
echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts.latest
echo $ipaddr ' ' $myhost >> /etc/hosts.latest
mv /etc/hosts /etc/hosts.old
mv /etc/hosts.latest /etc/hosts

Edit rc.local to run the hosts.sh script at boot for CentOS 7+, rc.local is not set as executable by default!

sudo chmod +x /etc/rc.d/rc.local
sudo systemctl enable rc-local
sudo systemctl start rc-local

Add below command inside /etc/rc.d/rc.local

sudo sh /usr/sbin/hosts.sh

Last updated