
CentOS 7 offers us a stable platform at the architecture and development level due to its wide possibilities and characteristics that make it one of the best distros at the company level. There are certain basic tasks that we can implement to have a more specific and centralized control over the equipment and these are:
- Set the hostname in order to identify it much more easily on the network
- Define a static IP address in case CentOS 7 fulfills defined tasks such as DNS, DHCP, etc.
1. Modify the CentOS 7 hostname
First of all we must know what the current name of the equipment is, for this we enter the hostname command and we will obtain the current name of the equipment:
We see that in this case it is called localhost, to define a new team name we will use the following syntax:
hostname (New name)For this case we will assign the name Solvetic, so we enter the following:
hostname SolveticIf we are not as root users, we must put the sudo parameter to perform the action. Once this process is done we will use the hostname command again to check the new name:
2. Modification of the Hosts file
It is possible that within the hosts file we have records with the old name of the equipment, this can be checked using the command:
cat / etc / hosts
As we see in the address line 127.0.0.1 we still have the old name of the team (localhost). To modify this value we access the hosts file using the preferred editor (vi, nano) and modify the name of the device:
We use the following command again and see the change applied:
cat / etc / hosts
3. Set the static IP address in CentOS 7
Now we will see how to configure or change IP address, DNS, Gateway (Gateway), Subnet etc. on the CentOS 7 Linux system.
Step 1
For this change in the first place it is important to know which is the network adapter that our team has and for this we can use the command
ifconfig or ipaddr
Note:
In case the ifconfig command is not available we can install it using the following command:
yum install net-toolsWhen executing the ifconfig command we see that our adapter is enp0s3:
Step 2
With this value we will access the following directory to make the respective change.
/ etc / sysconfig / network-scriptsTo do this we enter the following:
sudo nano / etc / sysconfig / network-scripts / ifcgfg-enp0s3We will see the following:
Step 3
There we must add the IPADDR, NETMASK and GATEWAY fields with the respective IP address and it is very important that in the BOOTPRO field it is defined as static:
We save the changes using the combination
Ctrl + O
We leave the editor using
Ctrl + X
Step 4
We restart the network service using the command
service network restartTo verify the change we use the ifconfig command again and we will see the new static IP address:
Step 5
Now we must go to the path /etc/resolv.conf to set the DNS server values, we can see that by default it is empty:
We can add the new DNS server using some public such as Google (8.8.8.8):
We save the changes using the combination
Ctrl + O
Step 6
Now we can verify that the navigation is correct by pinging a website:
As we can see, it is very easy to modify the name of the device and establish a static IP address in CentOS 7.
$config[ads_text6] not foundCentOS 7 firewall
Articles