Configuring a Network Adapter in CentOS

After connecting the VPS with the operating system to a private or public network, you need to configure the network interface.

Step 1

Connect to the virtual server with superuser rights and run the command:

ifconfig -a

You will see a list of available adapters that looks like this:

eth0: flags=4163  mtu 1500
        inet 5.200.47.73  netmask 255.255.255.0  broadcast 5.200.47.255
        inet6 fe80::250:56ff:fe01:29a9  prefixlen 64  scopeid 0x20
        ether 00:50:56:01:29:a9  txqueuelen 1000  (Ethernet)
        RX packets 760  bytes 57362 (56.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 101  bytes 12839 (12.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163  mtu 1500
        inet6 fe80::8f6:6de2:ec53:e800  prefixlen 64  scopeid 0x20
        ether 00:50:56:01:03:59  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22  bytes 3580 (3.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1  (Local Loopback)
        RX packets 64  bytes 5184 (5.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 5184 (5.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In the network settings, find the  field with the value of the ether parameter from the output of the list of network interfaces. Remember the name of the new interface, in our case is eth1. The configured adapter that has to the Internet is eth0.

Step 2

Change to the directory where the network interfaces configuration are located:

cd /etc/sysconfig/network-scripts/

Copy the configuration file of an existing interface, specifying the name of the new interface:

cp ifcfg- ifcfg-

:

cp ifcfg-eth0 ifcfg-eth1

Step 3

You need to check if the DHCP option is enabled. This can be done in the network settings in the control panel.

Step 4 – If DHCP is enabled

Open the copied file for editing with a text editor such as vi:

vi ifcfg-

For example:

vi ifcfg-eth1

Make corrections by specifying your own values, which can be found in the control panel:

HWADDR=
NAME=
DEVICE=
ONBOOT=yes
USERCTL=no
BOOTPROTO=dhcp

check_link_down() {
return 1;
}

Save your changes.As a result, the content will look like this:

HWADDR=00:50:56:01:10:cf
NAME=eth1
DEVICE=eth1 
ONBOOT=yes
USERCTL=no
BOOTPROTO=dhcp

check_link_down() {
 return 1;
}

Step 4 – If DHCP is off

Open the copied file for editing with a text editor such as vi:

vi ifcfg-

For example:

vi ifcfg-eth1

Make corrections with your own values:

HWADDR=
NAME=
GATEWAY=
DNS1=
DEVICE=
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
NETMASK=
IPADDR=
PEERDNS=no

check_link_down() {
return 1;
}

Save changes and close the file.

As a result, the content will look like this:

HWADDR=00:50:56:01:03:59
NAME=eth1
GATEWAY=10.0.1.1
DNS1=10.0.1.1
DEVICE=eth1
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=10.0.1.2
PEERDNS=no

check_link_down() {
 return 1;
}

Step 5

Restart the server network services for the changes to take effect:

service network restart

To check if it works correctly, ping to another server on a private or public network:

ping 10.0.1.3

 

Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!