Sunday, January 6, 2019

CentOS - Manual IP

During CentOS installation demonstration, we set the Server to get a DHCP Address. Normally Servers have a static IP Address that doesn't change, so other applications can easily communicate. 

We will provide two examples, where we can setup a static IP Address during and after installation. 

During the setup we can go to Network & Host Name and then press Configure... 


On the Ethernet TAB we can change the connection name, speed, duplex, but in order to change the IPv4 Address, we have to go to IPv4 Settings. 




There we can simply press Add and set the address / mask and default gateway. 
Our Server will use 10.10.10.202/24 address with 10.10.10.254 mask. 



We can save our changes and then go back and enable the interface. 



After installation, we can change the IP Address, using the Network Manager tool. 


[root@CentOS /]# nmtui

We will select Edit a connection



We will specify which connection we are changing - here we have only one NIC. 



We will change the  IPv4 configuration to manual. 



And specify the IPv4 settings as before - the GUI looks very similar with the OS installation one.  



We can press ok to apply our changes. 




Windows Applications - DHCP - Tips

On a previous post we have installed and did a basic configuration on a Windows DHCP Server. We will based on that post and add more options. 


DHCP Reservations

Let's say that we building a Server and we will let it get an IP Address from DHCP. We can ensure that this machine will always get the same IP Address if we create DHCP reservations

In some screenshots you will see that the Scope has a red down arrow, which means that the scope is disabled / deactivates, but this doesn't affect our settings, we can enabled it back in order to server our clients. 

Let's check our DHCP reservations. If we expand our scope we can see the reservations field. 


We can simply right click and create a new reservation. There we have to specify an IP Address and a MAC Address and which protocols to use DHCP / BootP (legacy). The MAC Address format must be XX-XX-XX-XX-XX-XX else we will get a notification as below:





Now each reservation (host) has its own folder, where we can specify different options, for example different default gateway or DNS Server.  



DHCP Exclusions

Let's say that we want to exclude an IP Address from the DHCP pool, because we have given that address to our client statically. We will right click to our address pool and select New Exclusion Range... 


We will only exclude the 10.10.10.202 address, so the start and end IP will be the same. 



Conflict Detection

Let's say that we haven't added an exclusion, and we add a client machine with a static IP Address on the same scope as the DHCP one. Since the DHCP Server is not aware, it will release that IP address to another client and this is where the problems start. Both the statically and dynamically IP Address machine will have network connectivity issues.

There is a way to prevent such misconfigurations. If we go to the IPv4 properties under the DHCP Server, on the Advanced TAB we have the option to Increase "Conflict Detection Attempts" from the default 0 (zero) to a higher value. This is a very simple setting,where the DHCP Server send a PING request to an IP Address before offer it to the clients.

If the Server gets a reply, then it goes to the next available IP Address. We have specified attempts = 3, which means that the DHCP Server will ping an IP Address 3 times before offering it.   





Adding Applications on our Linux Servers - rConfig


rConfig is a great tool for managing network device configuration. It can capture various show commands, that we can use for backup purposes or comparing results  of between different versions of our configuration. 



There is also an interactive demo, if we want to get a first look on the interface




We can download rConfig, and follow the instructions on that link , but we will present the whole console output. You can follow the link to install CentOS on VirtualBox

Note: For the rConfig-CentOS VM, make sure that you use more than 8GB (default value) for the Disk, because you won't be able to even complete the installation. Since we use dynamic disks we can really set up a much higher value (30GB).


We can use the console to type the commands, or use an SSH client, such as mRemoteNG. We will us the  CentOS Server we created on a previous post - IP Address 10.10.10.202. 

I tried to use different colors to seperate Linux output (blue) and user input (red). 


You will see on the mySQL setup,  the installation is very basic and not secure, but we will simply focus on how to make rConfig working. 


First of all we have to go to the home folder where we will download our installer. 



[root@CentOS ~]# cd /home

We will use curl to download the application 

[root@CentOS home]# curl -O http://files.rconfig.com/downloads/scripts/install_rConfig.sh -A "Mozilla"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
100  1820  100  1820    0     0    287      0  0:00:06  0:00:06 --:--:--   377
100  1820  100  1820    0     0    287      0  0:00:06  0:00:06 --:--:--   476

We can confirm that the application has been downloaded

[root@CentOS home]# ls
install_rConfig.sh

Let's check the file permissions within that folder

[root@CentOS home]# ls -la
total 4
drwxr-xr-x.  2 root root   32 Jan  6 07:15 .
dr-xr-xr-x. 17 root root  224 Jan  6 06:48 ..
-rw-r--r--.  1 root root 1820 Jan  6 07:15 install_rConfig.sh

Using the +x option we will me able to execute the file. 

[root@CentOS home]# chmod +x install_rConfig.sh

We will follow the instructions in order to complete the first installation. I have included the full output from the console and highlighted the areas that need our feedback. 

[root@CentOS home]# ./install_rConfig.sh
Checking CentOS version...
##########################(100%)
Launching CentOS 7 installation script...
Status: Launching CentOS 7 installation script...

Starting rConfig installation...
Testing internet connectivity...
##########################(100%)
You are Online!

Installing wget...
##########################(100%)
Status: wget is installed!

Now installing the login script...
##########################(100%)
Status: Login Script installed

Updating SELINUX File...
##########################(100%)
Status: SELINUX Updated

Updating Sudoers File...
##########################(100%)
Status: Sudoers Updated

Disabling Firewall...
##########################(100%)
Status: Firewall (firewalld) Disabled 

Installing Repos...
##########################(100%)
Status: Repos installed installed...

Installing required packages... This will take a few moments....
################          (60%)
All settings correct for using Composer
Downloading...

Composer (version 1.8.0) successfully installed to: /home/composer.phar
Use it: php composer.phar
##########################(100%)
Status: Required packages installed...

Starting required services...
##########################(100%)
Status: Required services started...

Checking for PHP...
##########################(100%)
Status: PHP 7.2.12 is installed!

Checking for Apache...
##########################(100%)
Status:  Apache/2.4.6 (CentOS) is installed!

Checking for MYSQL...
##########################(100%)
Status: MySQL 5.6.42 is installed!

Setting up VSFTPD...
##########################(100%)

Do you want to allow Root access to FTP... (y/n)? y

Do you want to enter your own NTP Server (default is time.nist.gov)?  (y/n)? y
Please enter NTP Server Name or IP: uk.pool.ntp.org

Status: VSFTPD is configured!
Configure NTP...
##########################(100%)
Status: NTP Service is configured!

Getting Post-Reboot Script...
##########################(100%)
Status: Post-Reboot file retrieved!

rConfig system installation is almost complete...

Your final task will be to setup MySQL.

Once the MySQL Setup wizard is complete, Please reboot your server and then run the post installation script /home/centos7_postReboot.sh 
The MySQL setup wizard will now launch

..............................................


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] n
 ... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!


All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...
<<<< End - Checking CentOS version... >>>>

We will reboot our system to install the post-boot installation. 

[root@CentOS home]# reboot

After rebooting, our SSH session will be disconnected, but we can easily reconnect. 



Now we get a welcome rConfig notification



Now we can run the post-Reboot script: /home/centos7_postReboot.sh



We can see that the installation has been completed and we are advised to connect to https://CentOS/install link, https://10.10.10.202/install in our case.



Our browser of course won't accept this self-signed certificate, but we can skip this warning. 


We can see the the pre-installation check shown success state 


We can accept the license agreement


On the DB section, we will use the  root user, but no password, as we have specified on the installation. Database Server is ourselves, so 127.0.0.1, and DBName: rConfig

Now we will need a new DB, so we will insert Database Name: rConfig and we will also press install database under Database configuration settings. 

We can verify settings.  


At the last page we get the final checks.  





We are advised to delete the /install directory on the /home/rconfig/www folder


[root@CentOS home]# sudo rm -rf /home/rconfig/www/install

and change the owner of the rconfig folder (we can use ls -la to verify as shown below)

[root@CentOS home]# chown -R apache /home/rconfig



Now we can login to https://CentOS/login.php or in our case https://10.10.10.202/login.php

Username: admin / Password:admin





Create a Linux Environment - Server OS - Intro & CentOS

Linux OS is ideal for Lab Environments and of course real world scenarios. I am always trying to replace a service that is installed on a Windows machine, with a Linux one. Using the Windows GUI most of the times is easier and less time consuming, but with Linux the pros are more. I won't get into a lot of details, but first of all, most Linux OS comes with no cost, so we don't have to run Windows trials or buy licenses. The OS footprint is much smaller, which means less OS updates and as a result a more stable OS.

We will use CentOS, I would say it is the free version of Red Hat, the most popular Linux Distro. We will login to the main page and download the Minimal ISO, that contains the minimum packages requires to run CentOS. The current version is 18.10 (January 2019)



Now we will create our VM. One we specify CentOS on the VM name, Oracle VirtualBox will auto generate the type: Linux and the Version: Red Hat (64-bit). As we mentioned CentOS is the community version of Red Hat. 

If you want to review the VM Wizard installation check a previous post







Note: Specifically for the rConfig-CentOS VM, make sure that you use more than 8GB (default value) for the Disk, because you won't be able to even complete the installation. Since we use dynamic disks we can really set up a much higher value (30GB).For other VMs 8GB can be more than enough. Of course we can manually expand the disk if needed.





Note: I had some issues with the mouse integration when I tried to install CentOS. THe solution is to go to the VM Settings, System > Motherboard TAB and then change Pointing Device from PS/2 Mouse to USB Tablet 



After powering up the VM, we have the option to run the VM from the Virtual Optical Disk, or Install the OS. We will go with the installation. 





We can select Network & Host Name to change the Server name and the network settings. The installation Destination section give us a warning. We simply have to specify in which disk we need to install CentOS and if we want to partition that disk first. 



We will enable the interface and leave the default (DHCP option). As you can see our guest VM got an IP Address from our DHCP Server. 


We can easily set up a static IP Address, as shown on another post. 



Now we are ready to begin the installation. 



During the installation we can specify the root password and also additional users. 



The root password wizard can detect if the password is secure. 





After the installation, we can reboot our system and run the Linux OS. 



To login to the console the username is root (or we can use another user if we have specified one). 



The easiest way is to connect using SSH, instead of using the console. We can use Putty, or mRemoteNG.




Okta Workflows - Send Customised Email

Simiar to the previous flows, where we sent a Slack message to users assigned to a new app, we can send a Welcome Email message. This mess...