Open In App

How to Install Consul Server on Ubuntu 22.04

Last Updated : 26 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

Consul is a free and open-source service discovery by Hashicorp. It's available on every Linux distribution, including Debian/Ubuntu, and RHEL/CentOS distributions. It is used for service discovery.

Required Ubuntu Version

Generally, we should use the latest Ubuntu versions currently 22.04 but this method works for 18.04 and above versions.

Screenshot-2024-08-22-011529
Ubuntu Info

Why use Consul Servers?

Services require the network locations (IP addresses and ports) of the other services to communicate with each other. Earlier before Consul, we had to write code for each of the services in the service configuration console, which can be time-consuming and error-prone. If a service's location changes, all dependent services are to be updated manually.

Consul helps services find each other. Now instead of hard-coding network locations, services are dynamically recognized and connected to other services.

How do Consul Servers work?

Services register themselves with Consul by providing their details (name, address, port, MAC Address, etc.) either through DNS or HTTP requests.. Console servers can be used to monitor the console of other machines, support data centers, and remotely solve issues. They enable administrators to remotely access the consoles of different machines. It's like viewing and interacting with the system consoles as if they were physically present. This is a centralized management system and is highly efficient.

Consul features include a Service Mesh that provides secure connections with TLS(Transport Layer Security) and provides authorization between services.

Prerequisite:- Ensure that you have Ubuntu updated and sudo privileges given on servers.

1. To update, download, and install the latest packages in your system use the Command :

sudo apt-update 
sudo apt-get update
sudo apt-get update

2. Now download the latest version of consul 1.8.4 :

 wget https://releases.hashicorp.com/consul/1.8.4/consul_1.8.4_linux_amd64.zip  
consul 1.8.4

This command will download the Consul ZIP file to your current directory. wget is a command used to download files from the internet. It supports HTTP, HTTPS, and FTP protocols.

3. Unzip the zip file using command :

unzip consul_1.8.4_linux_amd64.zip
unzip consul

4.Move the consul binary to the /usr/local/bin directory with the following command : sudo mv consul /usr/local/bin/ .This is done so that when the Consul binary is in /usr/local/bin/, it becomes available for execution from any directory in the terminal. The Consul binary is the executable file for the Consul software, which is used for service discovery. Use ls command to check the files in the directory.

sudo mv consul /usr/local/bin/ .

5. To versify the version installed

 consul --version
 consul --version

Hence, Consul Version 1.8.4 is installed in your Ubuntu (linux) System properly.

Setting Up UFW

UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables firewall rules. It serves as an interface to iptables, simplifying the configuration of your firewall. UFW is generally installed by default on Ubuntu. If it is uninstalled, you can install it with the following command:

sudo apt install ufw

Step 1: Enable IPv6

If IPv6 (Internet Protocol Version 6) is not enabled already, you need to enable it:

1. Open the UFW configuration file:

sudo nano /etc/default/ufw

2. Find the line that sets the IPV6 variable and change its value to yes:

IPV6=yes

Save and close the file.

Step 2: Check Default Firewall Policies

Default firewall policies control how to handle traffic that does not match any other rules. By default, UFW is set to deny all incoming connections and allow all outgoing connections. You can configure these settings manually using the following commands:

To set the default incoming policy to deny

sudo ufw default deny incoming

To set the default outgoing policy to allow

sudo ufw default allow outgoing

Step 3: Allow the OpenSSH UFW Application Profile

To ensure that you can connect to your server via SSH, you need to allow the OpenSSH application profile:

Run the following command to create firewall rules that allow all connections on port 22, the default port for SSH:

sudo ufw allow OpenSSH

Step 4: Enable the Firewall

Once you have configured the necessary rules, you can enable the firewall with the following command:

sudo ufw enable

Step 5: Allow HTTP/HTTPS Connections

For common web traffic, you may want to allow HTTP and HTTPS connections:

Allow HTTP connections

sudo ufw allow http

Allow HTTPS connections

sudo ufw allow https
sudo ufw allow https
UFW policies set to correct values

Next Article
Article Tags :

Similar Reads