How to modify and configure IP, gateway, subnet mask, and DNS under Linux system

How to modify and configure IP, gateway, subnet mask, and DNS under Linux system

1. View network card information

First of all, we can use the following two commands to query the network card information and see which network card we are using

ifconfig
ip addr

insert image description here

Second, find the network card configuration file

Then we enter the following directory and find the network card file we used above

#进入目录
cd /etc/sysconfig/network-scripts/
#查看文件
ll

insert image description here

3. Modify network card information

Then we open the configuration file to modify

#每个人的配置文件名称都不一样
vi ifcfg-eno16777728

Some new machines may not have the following ones, we can add

###新增
#ip地址
IPADDR="192.168.19.201"
#子网掩码
NETMASK="255.255.255.0"
#网关
GATEWAY="192.168.19.2"
#DNS
DNS1="192.168.19.2"

insert image description here
Then wq! save and exit

Fourth, restart the network card

service network restart

The above is the entire content of this article. If it is helpful to you, remember to bookmark, like, and pay attention!

Guess you like

Origin blog.csdn.net/qq_42716761/article/details/126936264