Wednesday, October 9, 2024

Join our community of SUBSCRIBERS and be part of the conversation.

To subscribe, simply enter your email address on our website or click the subscribe button below. Don't worry, we respect your privacy and won't spam your inbox. Your information is safe with us.

1,030FollowersFollow
1,000FollowersFollow
30,000FollowersFollow

How to setup network adapter in CentOS?

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

Step 1

Connect to the virtual server with superuser privileges and execute the command:

ifconfig -a

You will see a list of available adapters of the following type:

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 MAC field with the ether value from the list of network interfaces. Remember the name of the new interface, in our case it is eth1. A configured adapter that has Internet access is eth0.

Step 2

Change to the directory where the network interface configuration files are located:

cd /etc/sysconfig/network-scripts/

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

cp ifcfg- <existing_interface> ifcfg- <new_interface>

For example:

cp ifcfg-eth0 ifcfg-eth1

Step 3

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

Step 4 – If DHCP is enabled

Open the copied file for editing using a text editor, for example, vi:

vi ifcfg- <new_interface>

For example:

vi ifcfg-eth1

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

HWADDR =
NAME = <interface_name>
DEVICE = <interface_name>
ONBOOT = yes
USERCTL = no
BOOTPROTO = dhcp

check_link_down () {
return 1;
}

Save the 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 disabled

Open the copied file for editing using a text editor, for example, vi:

vi ifcfg- <new_interface>

For example:

vi ifcfg-eth1

Make corrections by specifying your own values:

HWADDR =
NAME = <interface_name>
GATEWAY = <gateway_address>
DNS1 = <gateway_address>
DEVICE = <interface_name>
ONBOOT = yes
USERCTL = no
BOOTPROTO = static
NETMASK = <subnet mask>
IPADDR = <local_ip address>
PEERDNS = no

check_link_down () {
return 1;
}

Save the 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 network services of the server for the changes to take effect:

service network restart

To check the correctness of the work, ping to another server on a private or public network:

ping 10.0.1.3
CmsDaddy
CmsDaddy
Hello Guys, Here we write about ultimate guides about content management system (CMS) and other software such as WordPress, Joomla, Drupal, Oxwall, Skadate, Prestashop, Magento, CSS, HTML, Linux, CentOS, Ubuntu, Windows, macOS, Android, iOS, iPadOS, etc...
Exit mobile version