Static IP on CentOS 7: how to configure it?

Several ways to configure a static IP address on a network interface in CentOS 7.

Static IP on CentOS 7: how to configure it?
Home | Static IP on CentOS 7: how to configure it?
Categorie: Tn Solutions,

Static IP on CentOS 7 machine network interface

There are several ways to configure a static IP address on a network interface in CentOS 7.
Whoever, private, professional or company, needed to set a static IP address, will have the following guide.

Consider connecting to a Linux CentOS 7 machine through the command line

yum install vim

we configure the network card of reference and to find it we execute

ip addr

we will have the following example result:

enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:0b:d5:2c brd ff:ff:ff:ff:ff:ff
inet 10.10.10.10/24 brd 10.10.10.255 scope global dynamic enp0s3
valid_lft 86146sec preferred_lft 86146sec
inet6 fe80::a00:27ff:fe0b:d52c/64 scope link
valid_lft forever preferred_lft forever

In this case the assignment mode is DHCP, in case we want to change to static we will modify the following file:

vim /etc/sysconfig/network-scripts/ifcfg-enp0s3

adding and modifying the following parameters:

TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes

in particular we will modify:

BOOTPROTO=static

and we will add the following variables:

IPADDR=10.10.10.150
NETMASK=255.255.255.0
GATEWAY=10.10.10.254
DNS1=8.8.8.8
DNS2=8.8.4.4

once considered the example of 10.10.10.150 available for static assignment it will be possible to restart the reteli card:

ifdown enp0s3 && ifup enp0s3

Talk to an expert

Fill out the form and you will be contacted by one of our technicians

We are ready to listen to your every need and transform it into your best technological ally Agency. Request an initial free consultation with one of our specialized IT technicians now

    GPS Spoofing in Drones: Electronic Warfare in Ukraine

    GPS Spoofing in Drones: Electronic Warfare in Ukraine

    Electronic warfare has become a critical component in the Russia-Ukraine conflict, transforming the battlefield into a testbed for advanced technologies. Among these, GPS spoofing has emerged as a highly effective strategy to neutralize enemy drones without physical destruction. This article delves into the technical mechanics of GPS spoofing, its implications in modern conflicts, and its ... GPS Spoofing in Drones: Electronic Warfare in Ukraine
    Cyberattack on M-I Stadio Srl: A Wake-Up Call for the Sports Industry

    Cyberattack on M-I Stadio Srl: A Wake-Up Call for the Sports Industry

    The recent ransomware attack on M-I Stadio Srl, the company managing San Siro stadium on behalf of Inter and AC Milan, serves as a stark warning for the entire sports industry. The cyber gang Bashe claimed responsibility, alleging the theft of one terabyte of sensitive data, exposing the organization to operational, legal, and reputational risks. ... Cyberattack on M-I Stadio Srl: A Wake-Up Call for the Sports Industry
    The Importance of IT Resource Virtualization: Cost Reduction and Server Optimization

    The Importance of IT Resource Virtualization: Cost Reduction and Server Optimization

    Introduction IT resource virtualization is one of the most transformative technological advancements in recent decades. This technology allows organizations to maximize hardware utilization, reduce IT expenses, and streamline server management. For many businesses, IT virtualization is no longer an option but a necessity to ensure flexibility, scalability, and operational efficiency. Imagine running multiple virtual servers ... The Importance of IT Resource Virtualization: Cost Reduction and Server Optimization