In this example, we will use 2 CentOS 7 servers. Assign 192.168.1.1 to the first server and 192.168.1.2 to the second server with 255.255.255.0 mask (/24)
SERVER_IP1 - first server
SERVER_IP2 - second server
1. Access the first server (server1) via ssh (root@SERVER_IP1)
2. Check the contents of the eth- configuration file interface. It will present you with the following lines:
: $MAC, $UUID are custom values automatically assigned to the hardware and should not be changed
3. After that, edit the configuration file for the eth0 interface (specific to our infrastructure and NIC cards), add accordingly the IP address of the private subnet and mask. We will use 192.168.1.1/24. You can use another range of private IP addresses as well as any preferred editor. In our example, we will use nano
. nano /etc/sysconfig/network-scripts/ifcfg-eth0
4. Add the following lines so the file will look as follows:
The following parameters were added:ONBOOT="yes"
yes: This interface is activated at boot time.
no: This interface is not activated at boot time.
Private IP address for interfaceNETMASK=255.255.255.0
Netmask for the 192.168.1.1/24 subnet
5. After performing the changes and saving the file, restart the network on the server by running the following command: service network restart
The result should read as follows:
You can otherwise disable and re-enable the interface by utilizing the ifdown ; ifup command
(ifdown disables the interface, ifup enables the interface.)
Disable the eth0 first:
After that, enable it again with ifup:
eth0 port should be enabled with the configured parameters:
Server1 configuration is now complete.
6. For the server2 perform the same action, only change 192.168.1.1
or any other IP address within 192.168.1.1/24 subnet. Assigned parameters stay the same (Mask, onboot). Only the IP address should be different.
Apply the same steps as for the Server1.
After all the settings are done, make sure that the hosts are available.
1. Check the contents of the eth1 interface: cat /etc/netplan/01-netcfg.yaml
The following content of the YAML file should be present there:
2. For our private interface eth0, we will copy /etc/netplan/01-netcfg.yaml
file with the following command: cp /etc/netplan/01-netcfg.yaml /etc/netplan/02-netcfg.yaml
3. After that, open the YAML file for eth0 (/etc/netplan/02-netcfg.yaml) with the editor of your choice (make sure to follow the rules of how to edit YAML documents
: YAML is very strict with indentation and is case-sensitive, so please be attentive to the YAML syntax.nano /etc/netplan/02-netcfg.yaml:
Replace the following text data:
eth1 >> eth0
addresses: [220.127.116.11/26] >> addresses: [192.168.1.1/24]
4. Remove the lines:
nameservers block (including addresses that follows).
The configuration file should look as follows:
5. After the configuration file for eth0 has been created, disable the port eth0 with the command:
ip link set eth0 down
You can check the status of the interface with the following command:
ip link show eth0:
6. After forcing shutdown, apply the new configuration using the command:
7. Check if the IP address has been added to the interface:
You will then need to check for eth0 at the output:
As long as the state is "UP" and set internal IP address is present, you are good to go.
8. On the host 2, perform the same operations, only set the internal IP address to another value, different from the existing hosts within the same subnetwork /24.
9. After the configuration has been performed on the both servers, ensure that the hosts are available for each other (link to the last section).
1. Check the contents of the interface’s configuration file: cat /etc/network/interfaces
The initial file should contain the following information:
2. Open the file with your favorite text editor and amend the following lines to the end of the file:
3. Add the necessary data and save the changes:
iface eth0 inet static
The file should look as follows:
4. After that, restart the networking with the following command:
systemctl restart networking:
5. Once restarted, check the interface parameters:
6. You will need to check for eth0 at the output:
As long as the state is "UP" and the set internal IP address is present, you are good to go.
How to check for available hosts
After the configuration has been performed on both servers, ensure that the hosts are available to each other by utilizing ping
command and tcpdump
Server1: ping IP address
Server2: tcpdump -i eth0 icmp
And vice versa:
Server2: ping IP address
Server1: tcpdump -i eth0 icmp
This wraps up the VLAN interface setup for your OS, which is based on two network hosts. For more than two network hosts, we recommend using the available IP address from a private subnet that is not assigned to the existing hosts.