Contents

Introduction

Prerequisites

Requirements

Components Used

Background Information

Problem

Procedure to Add, Delete, or Modify /ETC/HOSTS Entries

Introduction

This document describes the procedure to add, delete, or modify /ETC/HOSTS entries in a Cisco Policy Suite (CPS).

Prerequisites

Requirements

Cisco recommends that you have knowledge of these topics:

- Linux

- CPS

Note: Cisco recommends that you must have privilege Root access to CPS CLI.

Components Used

The information in this document is based on these software and hardware versions:

- CPS 20.2

- MongoDB v3.6.17

- Unified Computing System (UCS)-B

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.

Background Information

In order to send network traffic to a host, the numeric IP address for that host must be known. The IP address is traditionally written as xxx.xxx.xxx.xxx, where each xxx represents a value from 0 to 255, for an IPv4 network address. Computers require these addresses, but humans find it difficult to remember the numeric values. On a Linux system, these readable names are converted to their numeric IP equivalents by the Resolver Library, contained in the libresolve.so files that are provided as part of the glibc RPM package. The programs that need to look up the numeric IP address for a name issue call to this library.

Host names and their IP addresses can be found in a variety of places. One of them is /ETC/HOSTS file.

The /ETC/HOSTS file contains the IP host names and addresses for the local host and other hosts in the Internet network. This file is used to resolve a name into an address (that is, to translate a host name into its Internet address).

[root@installer ~]# cat /etc/hosts

127.0.0.1 localhost

#BEGIN_QPS_LOCAL_HOSTS

xxx.xxx.xxx.xxx lb01 dc1-lb01

xxx.xxx.xxx.xxx lb02 dc1-lb02

xxx.xxx.xxx.xxx sessionmgr01 dc1-sessionmgr01

xxx.xxx.xxx.xxx sessionmgr02 dc1-sessionmgr02

xxx.xxx.xxx.xxx qns01 dc1-qns01

xxx.xxx.xxx.xxx qns02 dc1-qns02

xxx.xxx.xxx.xxx pcrfclient01 dc1-pcrfclient01

xxx.xxx.xxx.xxx pcrfclient02 dc1-pcrfclient02

#END_QPS_LOCAL_HOSTS

#BEGIN_QPS_OTHER_HOSTS

xxx.xxx.xxx.xxx ntp-primary ntp

xxx.xxx.xxx.xxx ntp-secondary btp

xxx.xxx.xxx.xxx lbvip01 lbvip01

xxx.xxx.xxx.xxx lbvip02 lbvip02

xxx.xxx.xxx.xxx arbitervip arbitervip

#END_QPS_OTHER_HOSTS

xxx.xxx.xxx.xxx installer

[root@installer ~]#

Problem

Whenever there is a requirement to add, delete, or update local hosts or peers' information to CPS, their host details must be added, deleted, or modified into /ETC/HOSTS.

Procedure to Add, Delete, or Modify /ETC/HOSTS Entries

1. Approach for CPS hosted in OpenStack.

Step 1. Back up of /ETC/HOSTS and other files.

Run these commands from the Cluster Manager:

# cp /etc/hosts /var/tmp/hosts_bkp_$(date +%Y-%m-%d)

# cp /var/qps/config/deploy/json/AdditionalHosts.js /var/tmp/AdditionalHosts.js_bkp

# cp /qsb_config/features/system/system.json /var/tmp/system.json_bkp

Step 2. Verify the system status.

Run this command from the Cluster Manager:

#curl -s http://installer:8458/api/system

Expected Output:

{"state":"deployed"}

Step 3. Backup of current additional hosts configuration.

Run this command from the Cluster Manager:

$ curl -k -X GET http://installer:8458/api/system/config/additional-hosts > /var/tmp/additional_hosts_$(date +%Y-%m-%d).yaml

Step 4. Preparation of yaml file with required additional hosts details.

Run this command from the Cluster Manager:

# cp /var/tmp/additional_hosts_$(date +%Y-%m-%d).yaml /var/tmp/additional_hosts_new.yaml

Add, delete, or modify entry in additional_hosts_new.yaml.

For example:

$ vi /var/tmp/additional_hosts_new.yaml

---

- name: "ntp-primary"

ipAddress: "xxx.xxx.xxx.xxx"

alias: "ntp-primary"

- name: "ntp-secondary"

ipAddress: "xxx.xxx.xxx.xxx"

alias: "ntp-secondary"

- name: "corporate_nms_ip"

ipAddress: "xxx.xxx.xxx.xxx"

alias: "corporate_nms_ip"

- name: "corporate_syslog_ip"

ipAddress: "xxx.xxx.xxx.xxx"

alias: "corporate_syslog_ip"

Step 5. Run PUT API call command from the Cluster Manager to add required hosts details in /ETC/HOSTS.

curl -i -X PUT http://installer:8458/api/system/config/additional-hosts -H "Content-Type: application/yaml" --data-binary "@additional_hosts_new.yaml"

Note: This command must be executed from the same directory where additional_hosts_new.yaml file is placed.

Step 6. Verification of host details in glibc /ETC/HOSTS.

Run this command from both Load Balancer (LB) Virtual Machines (VMs) and verify host details.

#cat /etc/hosts

Step 7. Restart all the Qns processes on both LBs.

Run this command to restart the LB Qns process.

Command Syntax:

#monit stop {Process Name}

#monit start {Process name}

Command example:

#monit stop qns-1

#monit start qns-1

2. Approach for CPS hosted in VMware.

Step 1. Log in to the Cluster Manager and add, delete, or modify local host details in /var/qps/config/deploy/csv/Hosts.csv and peer details in /var/qps/config/deploy/csv/AdditionalHosts.csv respectively as per the requirement.

Run this command to add, delete, or modify local host details in the Hosts.csv file.

#vi /var/qps/config/deploy/csv/Hosts.csv.

Run this command to add, delete, or modify peer details in the AdditionalHosts.csv file.

#vi /var/qps/config/deploy/csv/AdditionalHosts.csv.

Step 2. Run this command to import the new configuration to the Cluster Manager.

#/var/qps/install/current/scripts/import/import_deploy.sh

Step 3. Run this command to verify the change in the Cluster Manager /ETC/HOSTS.

#cat /etc/hosts

Step 4. Run this command from the Cluster Manager to rebuild the CPS package.

[root@installer ~]# /var/qps/install/current/scripts/build_all.sh

Step 5. Run this command to download all the Puppet scripts, CPS software, /ETC/HOSTS files and update each VM with the new software from the Cluster Manager.

[root@installer ~]# /var/qps/install/current/scripts/upgrade/reinit.sh

Step 6. Run this command to verify the change in both LB /ETC/HOSTS.

#cat /etc/hosts

Step 7. Restart all the Qns processes on both LBs.

Run this command to restart the LB Qns process.

Command Syntax:

#monit stop {Process Name}

#monit start {Process name}

Command exampls:

#monit stop qns-1

#monit start qns-1