Building Professional Web Hosting Solution
<< Linux Basic Setup and Configuration Course
>> Linux VM/VPS Fundamental Configuration Section
- Configuring Local or Public DNS PTR Records
- Debian Based Hostname Plus Network Configuration
- Red Hat Based Hostname Plus Network Configuration
- Red Hat Based Systems Network Manager Text UI
Debian Based Hostname Plus Network Configuration will show you step by step how to set your Public VPS Network Configuration. The following procedures should be used as baseline across all Debian and Ubuntu base systems deployment when it comes to Network, DNS, and Hostname Settings. The Basic requirements in this article will include configuring, setting, and verifying a proper hostname, FQDN, Static IP, and hosts file to prepare your VPS for next and advanced configuration.
Objectives:
1. Setting a VPS Hostname and FQDN
2. Configuring Network Settings DO or Vultr
3. Private VM Interface Network Settings
4. Configuring Server’s Hosts File Settings
Prerequisites:
A. Basic Domain, Sub-domain, or DNS Knowledge
B. Login to your DigitalOcean or Vultr Account
Note: Setting and Configuring basic requirements such Static IP Address, Hostname (FQDN), and Hosts File before configuring any service is a must step. Most Public VPS created ready with proper Static IPv4/IPv6 Address, Hostname, and Hosts file. Regardless, it’s very important to double check these settings before configuring any service.
Recommendations:
For better performance, use VPS with at least 2 CPUs, 4G Memory, 1G Bandwidth, and SSD Storage drive.
Table of Contents
Set a VPS Hostname and FQDN
The hostname is your VPS label. The Hostname and FQDN used to represent Services and Applications that are hosted at that VPS. It’s very important to set proper hostname and FQDN since these names allow the server to communicate Internally and Externally using names instead if IP addresses. Services and Applications can represent them selves to the rest of the network and communicate with other VPSs using those names instead of static IP Address.
Public VPS Users: DigitalOcean or Vultr allows you to set a Hostname while you are creating your Droplet or instance. However, always verify it using the hostname or hostnamectl commands, if the hostname is not set as required, change it using step 2 as shown below. If you decide to change the hostname, please make sure to change the Reverse DNS records as well at your domain DNS management control panel.
Private VM Users: The Network settings concept is the same across both Public VPS and Private VM running at VirtualBox. For instance, you need to use Private IP address range at your VirtualBox or VMware Station instead of using Public IP Address. Below, you will find an Interface samples referring to Public VPS, you can use the same template, however replace the IP Settings using your Private IP range.
Run the following steps (1 to 4)
1. Check your VPS Hostname
hostname
Or, Systemd Based such Debian8, Ubuntu16.04, or CentOS7
hostnamectl
If you believe your VPS’s Hostname was not set properly, use the next command to set it a proper hostname.
2. Set or Change the VPS Hostname
Replace node1.ccnahub.com using your sub-domain.
echo node1.ccnahub.com > /etc/hostname
3. Reboot and Verify Hostname
hostname
Or
hostnamectl
4. Rename Your VPS Label if Needed
a. DigitalOcean
Navigate as shown in the image below to rename your Droplet as shown if needed. The Label name usually should reflects your Droplet hostname.
Navigate as shown in the image below to rename your Vultr Instance as shown if needed. The Label name usually should reflects your instance hostname.
Configuring Network Settings DO or Vultr
Using DigitalOcean Debian/Ubuntu VPS Interface
DigitalOcean configures a static Public IP address and Private IP address for Debian Based Systems using one file as shown below. If you haven’t chosen a Private IP address during VPS creation, then skip the private IP address interface configuration or verification.
Verify IP address Settings
- Navigate under your Droplet or VPS instance Settings to find the Network and IP address Settings you need to verify.
- View or display the interface file Network Settings, use cat command or nano command to view and verify the network settings.
Run the following steps (1 to 3)
1. First, I will make sure nano editor is installed
apt-get install nano -y
2. Backup the Interfaces File
cp /etc/network/interfaces /etc/network/interfaces-bak
3. View/Configure Network Interfaces File
nano /etc/network/interfaces
Below you will an example of my VPS interface file.
TIP: Optional – just a personal preference, you will notice that I have configured and labeled each section of my interface file different than the default output, however, as long as I am using the same IP address settings then shouldn’t be a problem. Feel free to use the same format. Of course, use your VPS’s IPv4 and 6 settings instead.
Recommended Steps
- Copy the below interface file to your notepad
- Copy and use your VPS IP Addresses Settings instead
- Go back and edit your Interface file using nano editor, hit Alt-b to backup its content
- Now, have the cursor at the beginning of the file, then delete all lines using Ctrl-k keys
- Finally, copy and paste your final interface file from the notepad to your VPS’s interface file and save
Note: Remember, DigitalOcean Droplet’s Interface file already configured with Static IP address Settings, so you don’t need to edit the file unless you have too. Regardless, it’s good to view and verify the IP settings.
IPv6: As of this writing and if IPv6 network enabled for the VPS, IPv6 DNS settings sometimes doesn’t resolve properly, therefore, I placed IPv4 DNS server before IPv6 as shown below.
# This file describes the network interfaces available on your # system and how to activate them. For more information, see # interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth1 eth0 # Public IPv6 Address iface eth0 inet6 static address 2604:A880:0800:0010:0000:0000:044A:7001 netmask 64 gateway 2604:A880:0800:0010:0000:0000:0000:0001 autoconf 0 dns-nameservers 8.8.4.4 8.8.8.8 2001:4860:4860::8844 2001:4860:4860::8888 # Public IPv4 Address iface eth0 inet static address 104.236.81.39 netmask 255.255.192.0 gateway 104.236.64.1 up ip addr add 10.17.0.7/16 dev eth0 # Private IPv4 Address iface eth1 inet static address 10.132.136.54 netmask 255.255.0.0
Save: Ctrl-X, Hit Y Key, and Enter.
If you changed the network settings, restart the network service:
service network restart
And
sudo ifdown eth0 && sudo ifup eth0
Using Vultr Debian/Ubuntu VPS Interface
As of this writing, Vultr might not configure your VPS interface with Static IP addresses the way DigitalOcean does, which is not a big deal. Switching to Static IP Address Settings can be done using the interface template as shown below.
Note: If you haven’t chosen a Private IP address during VPS creation, then skip private IP address interface configuration.
Run the following steps (1 to 3)
1. First, I will make sure nano editor is installed
apt-get install nano -y
2. Backup the Interfaces File
cp /etc/network/interfaces /etc/network/interfaces-bak
3. View/Configure Network Interfaces File
nano /etc/network/interfaces
Below you will an example of my VPS interface file which you can use.
TIP: Optional – just a personal preference, you will notice that I have configured and labeled each section of my interface file different than the default output, however, as long as I am using the same IP address settings then shouldn’t be a problem. Feel free to use the same format. Of course, use your VPS’s IPv4 and 6 settings instead.
Recommended Steps
- Copy the below interface file to your notepad
- Copy and use your VPS IP Addresses Settings instead
- Go back and edit your Interface file using nano editor, hit Alt-b to backup its content
- Now, have the cursor at the beginning of the file, then delete all lines using Ctrl-k keys
- Finally, copy and paste your final interface file from the notepad to your VPS’s interface file and save
Note: As per Vultr Support, I recommend configuring all instances statically as shown below. However, when deploying a new VPS from a snapshot, remember to change the old static IP address to match the newly assigned IP address. But, if you elect to deploy a new instance with a pre-reserved IP address, this would not be necessary as the IP would carry over.
Besides, there is the blue “network configuration examples” link under your VPS instance “Settings” tab, includes all necessary file paths and configurations for network settings. Last but not least, remember that not all the VPS instances use the interface name “eth0”, some instances such Ubuntu16 might use different interface name. Always refer to your VPS “Settings” tab to make sure you are using the proper format, IP Address, and Subnet Mask.
Debian Based System Interface File
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth1 eth0 # Public IPv6 Address iface eth0 inet6 static address 2001:19f0:0:201e:5400:00ff:fe27:d60a netmask 64 dns-nameservers 2001:19f0:300:1704::6 # Public IPv4 Address iface eth0 inet static address 104.207.135.106 netmask 255.255.252.0 gateway 104.207.132.1 dns-nameservers 108.61.10.10 post-up ip route add 169.254.0.0/16 dev eth0 # Private IPv4 Address iface eth1 inet static address 10.99.0.11 netmask 255.255.0.0 mtu 1450
Save: Ctrl-X, Hit Y Key, and Enter.
If you changed the network settings, restart the network service:
ifdown eth0 && ifup eth0 ifdown eth1 && ifup eth1
Or
service networking restart
If you loose the connection, try to connect again. If you can’t connect again, reboot the VPS from the Web Console Interface and try again.
Ubuntu16.04 Interface File
Note: At Vultr, Ubuntu16 might uses “ensx” instead of “ethx” for the interface name, this is very crucial to note down since might be needed across other advanced configuration as well.
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto ens3 ens7 # Public IPv6 Address iface ens3 inet6 static address 2001:19f0:0:201f:5400:00ff:fe27:d60d netmask 64 dns-nameservers 2001:19f0:300:1704::6 # Public IPv4 Address iface ens3 inet static address 45.63.5.93 netmask 255.255.254.0 gateway 45.63.4.1 dns-nameservers 108.61.10.10 post-up ip route add 169.254.0.0/16 dev ens3 # Private IPv4 Address iface ens7 inet static address 10.99.0.12 netmask 255.255.0.0 mtu 1450
Save: Ctrl-X, Hit Y Key, and Enter.
If you changed the network settings, restart the network service:
ifdown ens3 && ifup ens3 ifdown ens7 && ifup ens7
Or
service networking restart
If you loose the connection, try to connect again. If you can’t connect again, reboot the VPS from the Web Console Interface and try again.
Private VM Interface Network Settings
Using Private Virtualization Platform such VirtualBox or VMware Station, your Interface name might look different than “eth0”. So ,all you need to do is to set your Interface settings as Static IP similar to what is showing below. A private VM running at VirtualBox, VMware Station, or Proxmox, can be configured with static IP Address similar to the following interface:
Recommended Steps
- Copy the below interface file to your notepad
- Copy and use your VPS IP Addresses Settings instead
- Go back and edit your Interface file using nano editor, hit Alt-b to backup its content
- Now, have the cursor at the beginning of the file, then delete all lines using Ctrl-k keys
- Finally, copy and paste your final interface file from the notepad to your VPS’s interface file and save
Debian8 Interface file
Edit Network Interface
nano /etc/network/interfaces
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.45 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 192.168.1.1 8.8.8.8
Save: Ctrl-X, Hit Y Key, and Enter.
service networking restart
Ubuntu16.04 Interface file
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto enp0s3 iface enp0s3 inet static address 192.168.1.50 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 192.168.1.1 8.8.8.8
As you can see, the interface name is enp0s3, yours could be eth0 or different.
Save: Ctrl-X, Hit Y Key, and Enter.
service networking restart
Ubuntu14.04 Interface
Here another interface but Ubuntu1404 VM.
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.47 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 192.168.1.1 8.8.8.8
Save: Ctrl-X, Hit Y Key, and Enter.
service networking restart
Configuring Server’s Hosts File Settings
The hosts file meant to map the VPS Fully Qualified Domain Name (FQDN) and it’s hostname to a static IP address. It is one of the most important basic requirements to configure after setting VPS Hostname and the Static IP Addresses.
Configure Hosts File
nano /etc/hosts
Recommended Steps
- Copy the below hosts file to your notepad
- Copy and use your VPS IP Addresses Settings instead
- Go back and edit your hosts file using nano editor, hit Alt-b to backup its content
- Now, have the cursor at the beginning of the file, then delete all lines using Ctrl-k keys
- Finally, copy and paste your final host file from the notepad to your VPS’s hosts file and save
Note: Of course, replace the Static IPv4 and IPv6 Addresses using your VPS IP Addresses, and replace node1.ccnahub.com and node1 using your VPS FQDN and hostname. Besides, note the loop addresses below (127.0.0.1 and ::1), these loop addresses must be pointed to hostname localhost and FQDN localhost.localdomain respectively as shown below.
My Public VPS hosts file:
# # IPv4 and IPv6 Hosts File # # The following lines are desirable for IPv4 capable hosts 127.0.0.1 localhost.localdomain localhost 127.0.0.1 localhost4.localdomain4 localhost4 162.243.255.108 node1.ccnahub.com node1 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ::1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 2604:a880:0:1010::20:f001 node1.ccnahub.com node1
Save: Ctrl-X, Hit Y Key, and Enter.
My Private VM Hosts File:
#
# IPv4 and IPv6 Hosts File
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
192.168.1.26 node1.ccnahub.com node1
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Save: Ctrl-X, Hit Y Key, and Enter.
3. Verify hosts file Info
Ping your VPS hostname
ping node1
ping6 node6
And
ping node1.ccnahub.com
ping6 node1.ccnahub.com
Public VPS Users: You should be able to ping your VPS hostname, FQDN, and get reply. If for any reason the ping is not going through, double check your host file, or contact your VPS provider.
Besides, you should be able to ping outside Networks such Google.
ping google.com
and
ping6 ipv6.google.com
Final thought, I recommend you reboot your VPS and recheck everything again such Hostname, IP Settings, and Hosts file configuration.
Recommended Readings
By Wikipedia Debian | About Debian | Debian Installation Guide | HowtoForge Debain8 Minimal Server
Building Professional Web Hosting Solution
<< Linux Basic Setup and Configuration Course
>> Linux VM/VPS Fundamental Configuration Section
- Configuring Local or Public DNS PTR Records
- Debian Based Hostname Plus Network Configuration
- Red Hat Based Hostname Plus Network Configuration
- Red Hat Based Systems Network Manager Text UI
LEAVE A COMMENT