Home  >  Article  >  Operation and Maintenance  >  Detailed explanation of how to set a static IP in Linux7

Detailed explanation of how to set a static IP in Linux7

Y2J
Y2JOriginal
2017-05-24 14:14:343192browse

This article mainly introduces the relevant information about the example of setting static IP in Centos Linux7. Friends who need it can refer to

The example of setting static IP in Centos Linux7

## First enter the location where the configuration file is placed:


cd /etc/sysconfig/network-scripts/

## Check which file is used by the current network card


ip add

## Filter out the configuration file list


ll | grep ifcfg

## Edit the configuration file


vi ifcfg-ens160

## The configuration file content is mainly: BOOTPROTO IPADDR NETMASK NM_CONTROLLED ONBOOT these fields, the other fields remain unchanged


TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.251
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=no
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
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=23a77b70-a6e3-4399-a5bd-4ca312a0f123
DEVICE=ens160
ONBOOT=yes

# # Modify the gateway configuration file:


vi /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
GATEWAY=192.168.1.1

## Restart the network service


systemctl restart network.service

【 Related recommendations】

1. Mysql free video tutorial

2. Detailed explanation of innodb_index_stats when importing data Error prompting table primary key conflict

3. Example details innodb_autoinc_lock_mode in mysql

4. Detailed example of adding new user permissions in MySQL

##5.

Detailed example of init_connect method in mysql

The above is the detailed content of Detailed explanation of how to set a static IP in Linux7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn