Category Archives: Linux

Extend a logical volume in a virtual machine running Red Hat or Cent OS

Source: Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371) | VMware KB

By default installation, Linux virtual machine (Fedora, RHEL or CentOS) has two partitions, one for swapping, and the other one is a lv (Logic Volume) partition.

The LVM (Logic Volume Manager) partition mount as /, and cannot be resized by partition tools such as partition magic or gparted.

To extend the logical volume:

Note: These steps only apply to EXT3 file systems.

 

Caution: VMware recommends to take a complete backup of the virtual machine prior to making these changes.

  1. Power off the virtual machine.
  2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
  3. Power on the virtual machine.
  4. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:

    # fdisk -l

  5. Create a new primary partition:
    1. Run the command:

      # fdisk /dev/sda (depending the results of the step 4)

    2. Press p to print the partition table to identify the number of partitions. By default, there are 2: sda1 and sda2.
    3. Press n to create a new primary partition.
    4. Press p for primary.
    5. Press 3 for the partition number, depending on the output of the partition table print.
    6. Press Enter two times.
    7. Press t to change the system’s partition ID.
    8. Press 3 to select the newly creation partition.
    9. Type 8e to change the Hex Code of the partition for Linux LVM.
    10. Press w to write the changes to the partition table.
  6. Restart the virtual machine.
  7. Run this command to verify that the changes were saved to the partition table and that the new partition has an 8e type:

    # fdisk -l

  8. Run this command to convert the new partition to a physical volume:

    Note: The number for the sda can change depending on system setup. Use the sda number that was created in step 5.

    # pvcreate /dev/sda3

  9. Run this command to extend the physical volume:

    # vgextend VolGroup00 /dev/sda3

    Note: To determine which volume group to extend, use the command vgdisplay.

  10. Run this command to verify how many physical extents are available to the Volume Group:

    # vgdisplay VolGroup00 | grep “Free”

  11. Run the following command to extend the Logical Volume:

    # lvextend -L+#G /dev/VolGroup00/LogVol00

    Where # is the number of Free space in GB available as per the previous command. Use the full number output from Step 10 including any decimals.

    Note: To determine which logical volume to extend, use the command lvdisplay.

  12. Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

    # ext2online /dev/VolGroup00/LogVol00

    Notes:

    • Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
    • By default, Red Hat and CentOS 7 use the XFS file system you can grow the file system by running the xfs_growfs command.
  1. Run the following command to verify that the / filesystem has the new space available:

    # df -h /

How to add ISCSI disk to Ubuntu server from NetApp

General info

Target = storage system. In this case NetApp.

Initiator = the server. In this case Ubuntu Linux server.

Change iqn name = You must supply the iSCSI initiator node name when you set up igroups.

To make this process go smoothly, it is a good practice to write down the node name now. Before you record the node name, you might want to change it.

By default, a node name ends with a string of random numbers.

Changing this part of the name to something such as the host name can make the node name easier to use.

Note! You can only change the last portion of the iqn name: like change the name form iqn.2005-03.com.RedHat:012345 to iqn.2005-03.com.RedHat:Toaster.

On the Linux server

  1. Install open-iscsi
    1. sudo apt install open-iscsi
  2. Change iqn name to iqn format with the server name at the end
    1. sudo vi /etc/iscsi/initiatorname.iscsi
  3. Edit iscsi config file so that the server connects automatically to the Netapp after reboot.
    1. sudo vi /etc/iscsi/iscsid.conf
    2. change the folowing line to automatic:
    3. startup = automatic
  4. Restart the iscsi service
    1. sudo systemctl restart iscsid
  • go to Netapp steps. When done, comeback here.
  1. Rediscover the Netapp
    1. sudo iscsiadm -m discovery -t sendtargets -p 192.168.1.53
  2. Connect to the netapp
    1. sudo iscsiadm -m node –login
  3. Get the list of disks on the server and locate the new ISCSI disk
    1. dmesg | grep sd
  4. Create a new partition
    1. sudo fdisk /dev/sdb
    2. n (Add new partition).
    3. P (Primery partition).
    4. enter
    5. w (Write table to disk and exit).
  5. Format the file system and mount it to /srv
    1. sudo mkfs.ext4 /dev/sdb1
    2. sudo mount /dev/sdb1 /srv
  6. Add an entry to /etc/fstab file – to mount the iscsi drive during boot:
    1. /dev/sdb1 /srv        ext4    defaults,auto,_netdev 0 0
  7. Reboot the server and verify that the disk is automatically up.
    1. sudo reboot -h now
    2. df -h

 

  • If for some reason you want to disconnect from the Netapp which means to disconnect the ISCSI disk from the server, you can logout with:
    1. sudo iscsiadm -m node –logout
  • If for some reason you want to uninstall open-iscsi package from the server, you can do it with:
    1. service open-iscsi stop
    2. sudo apt-get remove –auto-remove open-iscsi
    3. sudo reboot
    4. sudo apt-get purge open-iscsi

On the Netapp storage

  1. Create new volume
  2. Create new qutree
  3. Create new LUN
  4. Create new initiator group
  5. Add the Linux server initiator name to the initiator group
    1. You can get the initiator name by going to the Linux server and look in the initiator config file: sudo cat /etc/iscsi/initiatorname.iscsi

Sources:

(iSCSI) How to configure iSCSI for Linux

https://help.ubuntu.com/lts/serverguide/iscsi-initiator.html#iscsi-initiator-install

http://installion.co.uk/ubuntu/trusty/main/o/open-iscsi/uninstall/index.html

https://www.howtogeek.com/106873/how-to-use-fdisk-to-manage-partitions-on-linux/

How to Monitor haproxy with Cacti

How to Monitor haproxy with Cacti

Install package

yum install net-snmp net-snmp-utils –y

Verify installation

rpm -qa | grep net-snmp*

net-snmp-agent-libs-5.7.2-24.el7.x86_64

net-snmp-5.7.2-24.el7.x86_64

net-snmp-libs-5.7.2-24.el7.x86_64

net-snmp-utils-5.7.2-24.el7.x86_64

Edit SNMP configuration file

vi /etc/snmp/snmpd.conf

rocommunity   ec1980

syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

view    systemview    included   .1.3.6.1.2.1.1

view    systemview    included   .1.3.6.1.2.1.25.1.1

access  notConfigGroup “”      any       noauth    exact  systemview none none

disablePerl false

perl do ‘/etc/snmp/haproxy.pl’;

Open firewall UDP port 161

firewall-cmd –permanent –add-port=161/udp

firewall-cmd –reload

firewall-cmd –list-all

systemctl stop firewalld

systemctl disable firewalld

Start SNMP service

systemctl start snmpd

systemctl enable snmpd

Edit haproxy configuration file # Global settings

vi /etc/haproxy/haproxy.cfg

#———————————————————————

# Global settings

#———————————————————————

global

 

    # to have these messages end up in /var/log/haproxy.log you will

    # need to:

.

.

.

.

 

#    stats socket /var/lib/haproxy/stats

stats socket /var/run/haproxy.stat mode 666

Download haproxy installation files from haproxy website to /tmp folder

cd /tmp/

wget http://www.haproxy.org/download/1.5/src/haproxy-1.5.16.tar.gz

tar zxvf haproxy-1.5.16.tar.gz

cd haproxy-1.5.16

cd contrib

cd netsnmp-perl

Copy haproxy.pl to snmp folder

 cp haproxy.pl /etc/snmp/

Install perl-Net-SNMP package

yum provides ‘*/Net/SNMP.pm’

yum install epel-release

yum install perl-Net-SNMP

Verify Installation

rpm -qa | grep net-snmp*

net-snmp-agent-libs-5.7.2-24.el7.x86_64

net-snmp-5.7.2-24.el7.x86_64

net-snmp-perl-5.7.2-24.el7.x86_64

net-snmp-libs-5.7.2-24.el7.x86_64

net-snmp-utils-5.7.2-24.el7.x86_64

Restart snmp service

systemctl restart snmp

Restart haproxy service

service haproxy restart

Validate haproxy perl script

perl /etc/snmp/haproxy.pl # even if this doesn’t work check that the query works.

Validate internal SNMP query works

snmpwalk -v 1 -c ec1980 -O e 127.0.0.1

snmpbulkwalk -c ec1980 -v2c 127.0.0.1 1.3.6.1.4.1.29385.106.2.0

Copy cacti XML files from haproxy installation files to cacti resource folders

C:\inetpub\wwwroot\cacti\resource\snmp_queries

cacti_data_query_haproxy_backends.xml

cacti_data_query_haproxy_frontends.xml

haproxy_backend.xml

haproxy_frontend.xml

haproxy_socket.xml

C:\inetpub\wwwroot\cacti\resource\script_queries

haproxy_backend.xml

haproxy_frontend.xml

haproxy_socket.xml

C:\inetpub\wwwroot\cacti\resource\script_server

haproxy_backend.xml

haproxy_frontend.xml

haproxy_socket.xml

Add data query and graphs

Finish!

How To Configure BIND as a Private Network DNS Server on CentOS 7

How To Configure BIND as a Private Network DNS Server on CentOS 7

Introduction

An important part of managing server configuration and infrastructure includes maintaining an easy way to look up network interfaces and IP addresses by name, by setting up a proper Domain Name System (DNS). Using fully qualified domain names (FQDNs), instead of IP addresses, to specify network addresses eases the configuration of services and applications, and increases the maintainability of configuration files. Setting up your own DNS for your private network is a great way to improve the management of your servers.

In this tutorial, we will go over how to set up an internal DNS server, using the BIND name server software (BIND9) on CentOS 7, that can be used by your Virtual Private Servers (VPS) to resolve private host names and private IP addresses. This provides a central way to manage your internal hostnames and private IP addresses, which is indispensable when your environment expands to more than a few hosts.

Prerequisites

To complete this tutorial, you will need the following:

  • Some servers that are running in the same datacenter and have private networking enabled
  • A new VPS to serve as the Primary DNS server, ns1
  • Optional: A new VPS to serve as a Secondary DNS server, ns2
  • Root access to all of the above.

Example Hosts

For example purposes, we will assume the following:

  • We have two existing VPS called “host1” and “host2”
  • Both VPS exist in the nyc3 datacenter
  • Both VPS have private networking enabled (and are on the 10.128.0.0/16 subnet)
  • Both VPS are somehow related to our web application that runs on “example.com”

With these assumptions, we decide that it makes sense to use a naming scheme that uses “nyc3.example.com” to refer to our private subnet or zone. Therefore, host1‘s private Fully-Qualified Domain Name (FQDN) will be “host1.nyc3.example.com”. Refer to the following table the relevant details:

Host Role Private FQDN Private IP Address
host1 Generic Host 1 host1.nyc3.example.com 10.128.100.101
host2 Generic Host 2 host2.nyc3.example.com 10.128.200.102

Note: Your existing setup will be different, but the example names and IP addresses will be used to demonstrate how to configure a DNS server to provide a functioning internal DNS. You should be able to easily adapt this setup to your own environment by replacing the host names and private IP addresses with your own. It is not necessary to use the region name of the datacenter in your naming scheme, but we use it here to denote that these hosts belong to a particular datacenter’s private network. If you utilize multiple datacenters, you can set up an internal DNS within each respective datacenter.

Our Goal

By the end of this tutorial, we will have a primary DNS server, ns1, and optionally a secondary DNS server,ns2, which will serve as a backup.

Here is a table with example names and IP addresses:

Host Role Private FQDN Private IP Address
ns1 Primary DNS Server ns1.nyc3.example.com 10.128.10.11
ns2 Secondary DNS Server ns2.nyc3.example.com 10.128.20.12

Let’s get started by installing our Primary DNS server, ns1.

Install BIND on DNS Servers

Note: Text that is highlighted in red is important! It will often be used to denote something that needs to be replaced with your own settings or that it should be modified or added to a configuration file. For example, if you see something like host1.nyc3.example.com, replace it with the FQDN of your own server. Likewise, if you see host1_private_IP, replace it with the private IP address of your own server.

On both DNS servers, ns1 and ns2, install BIND with yum:

  • sudo yum install bind bind-utils

Confirm the prompt by entering y.

Now that BIND is installed, let’s configure the primary DNS server.

Configure Primary DNS Server

BIND’s configuration consists of multiple files, which are included from the main configuration file,named.conf. These filenames begin with “named” because that is the name of the process that BIND runs. We will start with configuring the options file.

Configure Bind

BIND’s process is known as named. As such, many of the files refer to “named” instead of “BIND”.

On ns1, open the named.conf file for editing:

  • sudo vi /etc/named.conf

Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1ns2host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4

acl “trusted” {

10.128.10.11;    # ns1 – can be set to localhost

10.128.20.12;    # ns2

10.128.100.101;  # host1

10.128.200.102;  # host2

};

Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4

options {

listen-on port 53 { 127.0.0.1; 10.128.10.11; };

#        listen-on-v6 port 53 { ::1; };

Below those entries, change the allow-transfer directive to from “none” to ns2‘s private IP address. Also, change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-transfer { 10.128.20.12; };      # disable zone transfers by default

allow-query { trusted; };  # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4

include “/etc/named/named.conf.local”;

Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Configure Local File

On ns1, open the named.conf.local file for editing:

  • sudo vi /etc/named/named.conf.local

The file should be empty. Here, we will specify our forward and reverse zones.

Add the forward zone with the following lines (substitute the zone name with your own):

/etc/named/named.conf.local — 1 of 2

zone “nyc3.example.com” {

type master;

file “/etc/named/zones/db.nyc3.example.com”; # zone file path

};

Assuming that our private subnet is 10.128.0.0/16, add the reverse zone by with the following lines (note that our reverse zone name starts with “128.10” which is the octet reversal of “10.128”):

/etc/named/named.conf.local — 2 of 2

zone “128.10.in-addr.arpa” {

type master;

file “/etc/named/zones/db.10.128”;  # 10.128.0.0/16 subnet

};

If your servers span multiple private subnets but are in the same datacenter, be sure to specify an additional zone and zone file for each distinct subnet. When you are finished adding all of your desired zones, save and exit the named.conf.local file.

Now that our zones are specified in BIND, we need to create the corresponding forward and reverse zone files.

Create Forward Zone File

The forward zone file is where we define DNS records for forward DNS lookups. That is, when the DNS receives a name query, “host1.nyc3.example.com” for example, it will look in the forward zone file to resolve host1‘s corresponding private IP address.

Let’s create the directory where our zone files will reside. According to our named.conf.local configuration, that location should be /etc/named/zones:

  • sudo chmod 755 /etc/named
  • sudo mkdir /etc/named/zones

Now let’s edit our forward zone file:

  • sudo vi /etc/named/zones/db.example.com

First, you will want to add the SOA record. Replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.nyc3.example.com — 1 of 3

@       IN      SOA     ns1.nyc3.example.com. admin.nyc3.example.com. (

3         ; Serial

604800     ; Refresh

86400     ; Retry

2419200     ; Expire

604800 )   ; Negative Cache TTL

After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.nyc3.example.com — 2 of 3

; name servers – NS records

IN      NS      ns1.nyc3.example.com.

IN      NS      ns2.nyc3.example.com.

Then add the A records for your hosts that belong in this zone. This includes any server whose name we want to end with “.nyc3.example.com” (substitute the names and private IP addresses). Using our example names and private IP addresses, we will add A records for ns1ns2host1, and host2 like so:

/etc/named/zones/db.nyc3.example.com — 3 of 3

; name servers – A records

ns1.nyc3.example.com.          IN      A       10.128.10.11

ns2.nyc3.example.com.          IN      A       10.128.20.12

 

; 10.128.0.0/16 – A records

host1.nyc3.example.com.        IN      A      10.128.100.101

host2.nyc3.example.com.        IN      A      10.128.200.102

Save and exit the db.nyc3.example.com file.

Our final example forward zone file looks like the following:

/etc/named/zones/db.nyc3.example.com — complete

  • $TTL 604800
  • @ IN      SOA     nyc3.example.com. admin.nyc3.example.com. (
  • 3       ; Serial
  • 604800     ; Refresh
  • 86400     ; Retry
  • 2419200     ; Expire
  •     604800 )   ; Negative Cache TTL
  • ;
  • ; name servers – NS records
  • IN      NS      nyc3.example.com.
  • IN      NS      nyc3.example.com.
  • ; name servers – A records
  • nyc3.example.com. IN      A       10.128.10.11
  • nyc3.example.com. IN      A       10.128.20.12
  • ; 10.128.0.0/16 – A records
  • nyc3.example.com. IN      A      10.128.100.101
  • nyc3.example.com. IN      A      10.128.200.102

Now let’s move onto the reverse zone file(s).

Create Reverse Zone File(s)

Reverse zone file are where we define DNS PTR records for reverse DNS lookups. That is, when the DNS receives a query by IP address, “10.128.100.101” for example, it will look in the reverse zone file(s) to resolve the corresponding FQDN, “host1.nyc3.example.com” in this case.

On ns1, for each reverse zone specified in the named.conf.local file, create a reverse zone file.

Edit the reverse zone file that corresponds to the reverse zone(s) defined in named.conf.local:

  • sudo vi /etc/named/zones/db.128

In the same manner as the forward zone file, replace the highlighted ns1 FQDN with your own FQDN, then replace the second “nyc3.example.com” with your own domain. Every time you edit a zone file, you should increment the serial value before you restart the named process–we will increment it to “3”. It should look something like this:

/etc/named/zones/db.10.128 — 1 of 3

@       IN      SOA     ns1.nyc3.example.com. admin.nyc3.example.com. (

3         ; Serial

604800         ; Refresh

86400         ; Retry

2419200         ; Expire

604800 )       ; Negative Cache TTL

After that, add your nameserver records with the following lines (replace the names with your own). Note that the second column specifies that these are “NS” records:

/etc/named/zones/db.10.128 — 2 of 3

; name servers – NS records

IN      NS      ns1.nyc3.example.com.

IN      NS      ns2.nyc3.example.com.

Then add PTR records for all of your servers whose IP addresses are on the subnet of the zone file that you are editing. In our example, this includes all of our hosts because they are all on the 10.128.0.0/16 subnet. Note that the first column consists of the last two octets of your servers’ private IP addresses in reversed order. Be sure to substitute names and private IP addresses to match your servers:

/etc/named/zones/db.10.128 — 3 of 3

; PTR Records

11.10   IN      PTR     ns1.nyc3.example.com.    ; 10.128.10.11

12.20   IN      PTR     ns2.nyc3.example.com.    ; 10.128.20.12

101.100 IN      PTR     host1.nyc3.example.com.  ; 10.128.100.101

102.200 IN      PTR     host2.nyc3.example.com.  ; 10.128.200.102

Save and exit the reverse zone file (repeat this section if you need to add more reverse zone files).

Our final example reverse zone file looks like the following:

/etc/named/zones/db.10.128 — complete

  • $TTL 604800
  • @ IN      SOA     example.com. admin.nyc3.example.com. (
  • 3         ; Serial
  • 604800         ; Refresh
  • 86400         ; Retry
  • 2419200         ; Expire
  • 604800 )       ; Negative Cache TTL
  • ; name servers
  • IN      NS      nyc3.example.com.
  • IN      NS      nyc3.example.com.
  • ; PTR Records
  • 10 IN      PTR     ns1.nyc3.example.com.    ; 10.128.10.11
  • 20 IN      PTR     ns2.nyc3.example.com.    ; 10.128.20.12
  • 100 IN PTR     host1.nyc3.example.com.  ; 10.128.100.101
  • 200 IN PTR     host2.nyc3.example.com.  ; 10.128.200.102

Check BIND Configuration Syntax

Run the following command to check the syntax of the named.conf* files:

  • sudo named-checkconf

If your named configuration files have no syntax errors, you will return to your shell prompt and see no error messages. If there are problems with your configuration files, review the error message and the Configure Primary DNS Server section, then try named-checkconf again.

The named-checkzone command can be used to check the correctness of your zone files. Its first argument specifies a zone name, and the second argument specifies the corresponding zone file, which are both defined in named.conf.local.

For example, to check the “nyc3.example.com” forward zone configuration, run the following command (change the names to match your forward zone and file):

  • sudo named-checkzone example.com /etc/named/zones/db.nyc3.example.com

And to check the “128.10.in-addr.arpa” reverse zone configuration, run the following command (change the numbers to match your reverse zone and file):

  • sudo named-checkzone 10.in-addr.arpa /etc/named/zones/db.10.128

When all of your configuration and zone files have no errors in them, you should be ready to restart the BIND service.

Start BIND

Start BIND:

  • sudo systemctl start named

Now you will want to enable it, so it will start on boot:

  • sudo systemctl enable named

Your primary DNS server is now setup and ready to respond to DNS queries. Let’s move on to creating the secondary DNS server.

Configure Secondary DNS Server

In most environments, it is a good idea to set up a secondary DNS server that will respond to requests if the primary becomes unavailable. Luckily, the secondary DNS server is much easier to configure.

On ns2, edit the named.conf file:

  • sudo vi /etc/named.conf

Note: If you prefer to skip these instructions, you can copy ns1‘s named.conf file and modify it to listen onns2‘s private IP address, and not allow transfers.
Above the existing options block, create a new ACL block called “trusted”. This is where we will define list of clients that we will allow recursive DNS queries from (i.e. your servers that are in the same datacenter as ns1). Using our example private IP addresses, we will add ns1ns2host1, and host2 to our list of trusted clients:

/etc/named.conf — 1 of 4

acl “trusted” {

10.128.10.11;    # ns1 – can be set to localhost

10.128.20.12;    # ns2

10.128.100.101;  # host1

10.128.200.102;  # host2

};

Now that we have our list of trusted DNS clients, we will want to edit the options block. Add the private IP address of ns1 to the listen-on port 53 directive, and comment out the listen-on-v6 line:

/etc/named.conf — 2 of 4

options {

listen-on port 53 { 127.0.0.1; 10.128.20.12; };

#        listen-on-v6 port 53 { ::1; };

Change allow-query directive from “localhost” to “trusted”:

/etc/named.conf — 3 of 4

options {

allow-query { trusted; }; # allows queries from “trusted” clients

At the end of the file, add the following line:

/etc/named.conf — 4 of 4

include “/etc/named/named.conf.local”;

Now save and exit named.conf. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.

Next, we will configure the local file, to specify our DNS zones.

Save and exit named.conf.

Now edit the named.conf.local file:

  • sudo chmod 755 /etc/named
  • sudo vi /etc/named/named.conf.local

Define slave zones that correspond to the master zones on the primary DNS server. Note that the type is “slave”, the file does not contain a path, and there is a masters directive which should be set to the primary DNS server’s private IP. If you defined multiple reverse zones in the primary DNS server, make sure to add them all here:

/etc/named/named.conf.local

  • zone “example.com” {
  • type slave;
  • file “slaves/db.example.com”;
  • masters { 128.10.11; };  # ns1 private IP
  • };
  • zone “10.in-addr.arpa” {
  • type slave;
  • file “slaves/db.128”;
  • masters { 128.10.11; };  # ns1 private IP
  • };

Now save and exit named.conf.local.

Run the following command to check the validity of your configuration files:

  • sudo named-checkconf

Once that checks out, start BIND:

  • sudo systemctl start named

Enable BIND to start on boot:

sudo systemctl enable named

Now you have primary and secondary DNS servers for private network name and IP address resolution. Now you must configure your servers to use your private DNS servers.

Configure DNS Clients

Before all of your servers in the “trusted” ACL can query your DNS servers, you must configure each of them to use ns1 and ns2 as nameservers. This process varies depending on OS, but for most Linux distributions it involves adding your name servers to the /etc/resolv.conf file.

CentOS Clients

On CentOS, RedHat, and Fedora Linux VPS, simply edit the resolv.conf file:

  • sudo vi /etc/resolv.conf

Then add the following lines to the TOP of the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolv.conf

search nyc3.example.com  # your private domain

nameserver 10.128.10.11  # ns1 private IP address

nameserver 10.128.20.12  # ns2 private IP address

Now save and exit. Your client is now configured to use your DNS servers.

Ubuntu Clients

On Ubuntu and Debian Linux VPS, you can edit the head file, which is prepended to resolv.conf on boot:

  • sudo vi /etc/resolvconf/resolv.conf.d/head

Add the following lines to the file (substitute your private domain, and ns1 and ns2 private IP addresses):

/etc/resolvconf/resolv.conf.d/head

search nyc3.example.com  # your private domain

nameserver 10.128.10.11  # ns1 private IP address

nameserver 10.128.20.12  # ns2 private IP address

Now run resolvconf to generate a new resolv.conf file:

  • sudo resolvconf -u

Your client is now configured to use your DNS servers.

Test Clients

Use nslookup—included in the “bind-utils” package—to test if your clients can query your name servers. You should be able to do this on all of the clients that you have configured and are in the “trusted” ACL.

Forward Lookup

For example, we can perform a forward lookup to retrieve the IP address of host1.nyc3.example.com by running the following command:

  • nslookup host1

Querying “host1” expands to “host1.nyc3.example.com because of the search option is set to your private subdomain, and DNS queries will attempt to look on that subdomain before looking for the host elsewhere. The output of the command above would look like the following:

Output:

Server:     10.128.10.11

Address:    10.128.10.11#53

 

Name:   host1.nyc3.example.com

Address: 10.128.100.101

Reverse Lookup

To test the reverse lookup, query the DNS server with host1‘s private IP address:

  • nslookup 10.128.100.101

You should see output that looks like the following:

Output:

Server:     10.128.10.11

Address:    10.128.10.11#53

 

11.10.128.10.in-addr.arpa   name = host1.nyc3.example.com.

If all of the names and IP addresses resolve to the correct values, that means that your zone files are configured properly. If you receive unexpected values, be sure to review the zone files on your primary DNS server (e.g. db.nyc3.example.com and db.10.128).

Congratulations! Your internal DNS servers are now set up properly! Now we will cover maintaining your zone records.

Maintaining DNS Records

Now that you have a working internal DNS, you need to maintain your DNS records so they accurately reflect your server environment.

Adding Host to DNS

Whenever you add a host to your environment (in the same datacenter), you will want to add it to DNS. Here is a list of steps that you need to take:

Primary Nameserver

  • Forward zone file: Add an “A” record for the new host, increment the value of “Serial”
  • Reverse zone file: Add a “PTR” record for the new host, increment the value of “Serial”
  • Add your new host’s private IP address to the “trusted” ACL (conf.options)

Then reload BIND:

  • sudo systemctl reload named

Secondary Nameserver

  • Add your new host’s private IP address to the “trusted” ACL (conf.options)

Then reload BIND:

  • sudo systemctl reload named

Configure New Host to Use Your DNS

  • Configure resolv.conf to use your DNS servers
  • Test using nslookup

Removing Host from DNS

If you remove a host from your environment or want to just take it out of DNS, just remove all the things that were added when you added the server to DNS (i.e. the reverse of the steps above).

Conclusion

Now you may refer to your servers’ private network interfaces by name, rather than by IP address. This makes configuration of services and applications easier because you no longer have to remember the private IP addresses, and the files will be easier to read and understand. Also, now you can change your configurations to point to a new servers in a single place, your primary DNS server, instead of having to edit a variety of distributed configuration files, which eases maintenance.

Once you have your internal DNS set up, and your configuration files are using private FQDNs to specify network connections, it is critical that your DNS servers are properly maintained. If they both become unavailable, your services and applications that rely on them will cease to function properly. This is why it is recommended to set up your DNS with at least one secondary server, and to maintain working backups of all of them.

Source: How To Configure BIND as a Private Network DNS Server on CentOS 7 | DigitalOcean

how to Assign Multiple IP Addresses to One Single Network Interface in Linux

The concept of creating or configuring multiple IP addresses on a single network interface is called IP aliasing. IP aliasing is very useful for setting up

Source: Create Multiple IP Addresses to One Single Network Interface

Assign Multiple IP Addresses to One Single Network Interface

  1. The device network (NIC) files located in “/etc/sysconfig/network-scripts/” directory.
  2. Navigate to the directory and do “ls -l” to list all devices.

                cd /etc/sysconfig/network-scripts/

ls –l

[root@******** network-scripts]# ls -l

total 236

-rw-r–r–. 1 root root   394 Nov  5 13:13 ifcfg-ens192

  1. Copy existing parameters of interface “ifcfg- ens192” in virtual interfaces called ifcfg- ens192:0, ifcfg- ens192:1 and ifcfg- ens192:2.

cp ifcfg- ifcfg-ens192 ifcfg- ifcfg-ens192:0

                                cp ifcfg- ens192 ifcfg- ens192:1

                                cp ifcfg- ens192 ifcfg- ens192:2

  1. edit each file and rename the DEVICE name to its corresponding alias and change the IPADDR address.

For example:

DEVICE=” ens192 ” replace with ens192:0

BOOTPROTO=static

ONBOOT=yes

TYPE=”Ethernet”

IPADDR=172.16.16.125 replace with the new virtual IP.

NETMASK=255.255.255.224

GATEWAY=172.16.16.100

HWADDR=00:0C:29:28:FD:4C

  1. Once, you’ve made all changes, save all your changes and restart/start the network service for the changes to reflect.

[root@*************]# /etc/init.d/network restart

How to Assign Multiple IP Address Range

  1. if you would like to create a range of Multiple IP Addresses to a particular interface called “ifcfg-eth0“.

cd /etc/sysconfig/network-scripts/

cp -p ifcfg-eth0 ifcfg-eth0-range0

  1. Now open “ifcfg-eth0-range0” file and add “IPADDR_START” and “IPADDR_END” IP address range as shown below.

[root@***********]# vi ifcfg-eth0-range0

 

#DEVICE=”eth0″

#BOOTPROTO=none

#NM_CONTROLLED=”yes”

#ONBOOT=yes

TYPE=”Ethernet”

IPADDR_START=172.16.16.126

IPADDR_END=172.16.16.130

IPV6INIT=no

#GATEWAY=172.16.16.100

  1. Save it and restart/start network service

[root@**************]# /etc/init.d/network restart

How To View Logs Files on Linux

Almost all log files are located under /var/log directory and its sub-directories on Linux. You can change to this directory using the cd command. You need be the root user to view or access log files on Linux or UNIX like operating systems. You can use the following commands to see the log files:

1.    less command

2.    more command

3.    cat command

4.    grep command

5.    tail command

6.    zcat command

7.    zgrep command

8.    zmore command

 

How do I view log files on Linux?

Open the Terminal or login as root user using ssh command. Go to /var/logs directory using the following cd command:
# cd /var/logs

To list files use the following ls command:
# ls

To view a common log file called /var/log/messages use any one of the following command:
# less /var/log/messages
# more -f /var/log/messages
# cat /var/log/messages
# tail -f /var/log/messages
# grep -i error /var/log/messages


Common Linux log files names and usage

§  /var/log/messages : General message and system related stuff

§  /var/log/auth.log : Authenication logs

§  /var/log/kern.log : Kernel logs

§  /var/log/cron.log : Crond logs (cron job)

§  /var/log/maillog : Mail server logs

§  /var/log/qmail/ : Qmail log directory (more files inside this directory)

§  /var/log/httpd/ : Apache access and error logs directory

§  /var/log/lighttpd/ : Lighttpd access and error logs directory

§  /var/log/boot.log : System boot log

§  /var/log/mysqld.log : MySQL database server log file

§  /var/log/secure or /var/log/auth.log : Authentication log

§  /var/log/utmp or /var/log/wtmp : Login records file

§  /var/log/yum.log : Yum command log file.

GUI tool to view log files on Linux

System Log Viewer is a graphical, menu-driven viewer that you can use to view and monitor your system logs. This tool is only useful on your Linux powered laptop or desktop system. Most server do not have X Window system installed. You can start System Log Viewer in the following ways:

Click on System menu > Choose Administration > System Log:

A note about rsyslogd

 

All of the above logs are generated using rsyslogd service. It is a system utility providing support for message logging. Support of both internet and unix domain sockets enables this utility to support both local and remote logging. You can view its config file by tying the following command:
# vi /etc/rsyslog.conf
# ls /etc/rsyslog.d/
In short /var/log is the location where you should find all Linux logs file. However, some applications such as httpd have a directory within /var/log/ for their own log files. You can rotate log file using logrotate software and monitor logs files using logwatch software.

Via: Linux Log Files Location And How Do I View Logs Files on Linux?.

How-to Start / Stop / Restart Network Service in Linux

How-to Start / Stop / Restart Network Service in Linux

You can use the following commands as per your UNIX operating systems.

HP-UX Unix start / stop / restart networking service

# /sbin/init.d/net stop
# /sbin/init.d/net start
# /sbin/init.d/hostname start

IBM AIX Unix start / stop / restart networking service

Simply type the following command to make changes to tcp/ip
# smitty mktcpip
Start network service
# startsrc
Stop network service
# startsrc

OpenBSD start / stop / restart networking service

Start network service
# sh /etc/netstart pnc0

FreeBSD start / stop / restart networking service

Restart network service
# /etc/rc.d/netif restart

Sun/Oracle Solaris Unix start / stop / restart networking service

Restart network service

# svcadm restart physical

Linux: CentOS / RHEL / Red Hat / Fedora start / stop / restart networking service

# service network stop
# service network start
# service network restart

Linux: Debian / Ubuntu server start / stop / restart networking service

 

# service networking stop
# service networking start
# service networking restart

Via Unix HowTo: Start / Stop / Restart Network Service Command.

How To Disable Firewall on Linux

How To Disable Firewall on RHEL / CentOS / RedHat Linux

iptables is administration tool / command for IPv4 packet filtering and NAT. You need to use the following tools:

service is a command to run a System V init script. It is use to save / stop / start firewall service.

chkconfig command is used to update and queries runlevel information for system service. It is a system tool for maintaining the /etc/rc*.d hierarchy. Use this tool to disable firewall service at boot time.

How Do I Disable Firewall?

First login as the root user.

Next enter the following three commands to disable firewall.
# service iptables save
# service iptables stop
# chkconfig iptables off

 

If you are using IPv6 firewall, enter.
# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off

Via How To: Disable Firewall on RHEL / CentOS / RedHat Linux.

Show all installed packages or software in Linux

Red Hat/Fedora Core/CentOS Linux

Type the following command to get list of all installed software
# rpm -qa | less

Debian Linux

Type the following command to get list of all installed software:
# dpkg –get-selections

Ubuntu Linux

Type the following command to get list of all installed software:
# sudo dpkg –get-selections

FreeBSD

Type the following command to get list of all installed software:
# pkg_info | less
# pkg_info apache

Use pkg_version command to summarizes the versions of all installed packages:
# pkg_version | less
# pkg_version | grep ‘lsof’

OpenBSD

 

OpenBSD also use pkg_info command to display list of all installed packages or software:
# pkg_info | less
# pkg_info apache

Via Show all installed packages or software in Linux, FreeBSD, OpenBSD.

Linux for Windows Server Administrators

Linux for Windows Server Admins

Create and Add Users

Add the user by typing in useradd followed by the desired login name to create. An example would be useradd sburns. This will follow with a few questions to answer and finally create the user. You should now be able to login with PuTTY.  Once logged in as the nonprivileged user, the administrator can elevate their privileges to root.

Using su – will allow a user to switch between users, even root, as long as the user knows the relevant password. The command itself is shorthand for “switch user.” As root an administrator can change to any other user by using the command su simon (or su bill or whomever), assuming the password is known. The “-” switch is used to give all the environmental variables. Using su – without specifying a user will assume you want to switch to the root user. There is a file called /etc/sudoers that holds the configuration for su.

So now we are logged in, lets cover some rudimentary file system-related items. When logged in as a normal user, they would initially be placed in their home directory that was created when the user was created, as was shown before. Move about the system using the command cd, the same as Windows, but remember that Linux is case sensitive.

Using the Linux CLI

With Linux, the backslash becomes a forward slash. To return to your own home directory at any point, just type cd without any arguments. If you are also not sure where you are in the file structure, there is a command called pwd. This command will give the full path to your current location. This is a very useful command, especially if you have many windows open – and double check before using potentially dangerous commands!

Managing Drives with Linux

Linux has no concept of drive letter mappings. Instead drive letters map to what are known as mount points. A very rudimentary example is with CD ROM drives. In Windows, when a CD is inserted, it is mounted as a drive letter. For example, E: This differs in Linux because when you mount a CD, it essentially links the contents of a CD to a folder. Something to bear in mind is that as a rule Linux machines do not auto mount media.

An administrator would have to mount the CD and link it to a folder. Most modern Linux distributions come with a media folder for this purpose. To mount a CD, use the commandmount /dev/cdrom /media. Similarly, to dismount a disk, use the command umount /media. This mounting method is not only for CDs but also for USB sticks, hard disks, and most other media, albeit with some occasional options to specify file systems and such.

To see what is mounted currently, type the command mount. Standard mounts are stored in the file /etc/fstsab. You can modify this file to add additional mount points if you wanted to add additional storage systems at boot. Pro tips: First, make sure you have a backup (use the command cp /etc/fstab fstab.bak). Second, use the mount -a command to verify the fstab file is still valid before you reboot it and find that it isn’t!

Now it might be a good time to introduce you to how most Linux installations are organized from a file and directory perspective.

  • / – root, as in the top level of the disk
  • /home – where users home directories and personal data are located
  • /boot – contains important boot files. You will rarely need to go in here
  • /dev – contains pseudo devices that link directly to the hardware
  • /root – the roots home directory, and where a root can store its files
  • /etc – contains all the configuration files for pretty much everything: networking, services, and some applications
  • /mount – This folder is used to mount NFS mounts and removable media
  • /var – Contains many system components, logs, and miscellaneous
  • /proc – Holds information about running processes.
  • /bin – Contains program files
  • /sbin – Contains system administration binary files

Useful Linux CLI Commands

When working with files, there are some useful commands you can run to help you manage them, as Linux doesn’t tend to do file extensions. If you want to know what type of file you are looking at, you can use the command file file, and it will interrogate the file and provide all the information it can gather.

To view human readable files, you can use the cat command. To edit a file, use the nano editor (for example, nano filename).

If you need to find a file, you can use the locate command. For example, to locate redhat-release (This file holds the release information for the RedHat Build) use the command locate redhat-release.

Other useful commands we can use right now are df, which gives disk space statistics. Usingdf -h may prove a better option as it gives sizes in human readable form of megabytes, gigabytes, and such, rather than an unwieldy size in bytes.

If you want to change your password now, you can use the command passwd. Used without any switches, it will allow you to change the password of the user you are logged in as. If you are logged in as root, you can change other people’s passwords by using the passwdcommand, followed by the username. An example would be passwd stuart.

It is also possible to edit the user setup by use of the command usermod. This will allow you to manage and modify settings on a per-user basis; for example, changing the username or home directory.

via Linux for Windows Server Administrators.