Home Operation and Maintenance CentOS Detailed explanation of two methods for configuring IP address in centos7

Detailed explanation of two methods for configuring IP address in centos7

Jul 22, 2020 pm 03:34 PM
centos7 IP address

The following column centos introductory tutorial will introduce to you two methods of configuring IP addresses in centos7. I hope it will be helpful to friends in need!

Detailed explanation of two methods for configuring IP address in centos7

There are two main ways to obtain an IP address on centos7, 1: obtain the IP dynamically; 2: set a static IP address

Before configuring the network, we first need to know the name of the centos network card. Centos7 no longer uses the ifconfig command. You can view it through the command IP addr. As shown in the figure, the network card name is ens32 and has no IP address.

1. Dynamically obtain ip (provided that your router has enabled DHCP)

Modify the network card configuration file vi /etc/sysconfig/network-scripts/ifcfg-ens32 (the last one is the network card name)

You need to modify the dynamically obtained IP address Just two places

(1)bootproto=dhcp

(2)onboot=yes

After modification, restart the network service. Systemctl restart network

[root@mini ~]# systemctl restart network
[root@mini ~]#
Copy after login
Copy after login

In this way, the dynamically configured IP address is set. Check again at this time. Click ip addr and you will see that you have obtained the IP address and can access the Internet (ping Baidu)

2. Configure a static IP address

Setting a static IP address is similar to a dynamic iIP. You also need to modify the network card configuration file vi /etc/sysconfig/network-scripts/ifcfg-ens32 (the last one is the network card name)

(1)bootproto=static

(2)onboot=yes

(3) ) Add a few lines at the end, IP address, subnet mask, gateway, dns server

IPADDR=192.168.1.160
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=119.29.29.29
DNS2=8.8.8.8
Copy after login

(4) Restart the network service

[root@mini ~]# systemctl restart network
[root@mini ~]#
Copy after login
Copy after login

You can configure only one DNS server. I use two free dns servers. Check the IP address and test the network connection

[root@mini ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d2:42:55 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.160/24 brd 192.168.1.255 scope global noprefixroute ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::f86e:939e:ff9b:9aec/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@mini ~]# ping www.baidu.com
PING www.a.shifen.com (163.177.151.109) 56(84) bytes of data.
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=1 ttl=55 time=27.5 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=2 ttl=55 time=35.2 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1008ms
rtt min/avg/max/mdev = 27.570/31.425/35.281/3.859 ms
Copy after login

For more centos related technical articles, please visit the centos system tutorial column!

The above is the detailed content of Detailed explanation of two methods for configuring IP address in centos7. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set Xiaohongshu not to display IP address? How does it change the id to locate the city? How to set Xiaohongshu not to display IP address? How does it change the id to locate the city? Mar 27, 2024 pm 03:00 PM

Xiaohongshu is a popular social e-commerce platform where users can share their daily life and discover their favorite products. Some users are more sensitive to personal privacy and hope that their IP address will not be displayed on Xiaohongshu to protect their online privacy. So, how to set Xiaohongshu not to display the IP address? This article will answer this question in detail. 1. How to set Xiaohongshu not to display the IP address? 1. Modify Xiaohongshu settings: Open Xiaohongshu APP, click "Me" in the lower right corner to enter the personal center. Then click on the avatar to enter account settings. In the account settings, find "Privacy Settings" and click to enter. Here, you can find the setting options for IP address, just turn it off. 2. Clear cache: Sometimes, Xiaohongshu may display an error

Where is the IP address of Xiaomi mobile phone? Where is the IP address of Xiaomi mobile phone? Feb 29, 2024 pm 06:10 PM

Where is the IP address of Xiaomi mobile phone? You can check the IP address on Xiaomi mobile phone, but most users don’t know where to check the IP address. Next is the graphic tutorial on how to check the IP address of Xiaomi mobile phone brought by the editor. Interested users come and take a look! Where is the IP address of Xiaomi mobile phone? 1. First open the settings function in Xiaomi mobile phone, select [My Device] and click to enter; 2. Then on the My Device function page, click [All Parameters] service; 3. Then on the All Parameters page , slide to the bottom and select [Status Information]; 4. Finally, you can see the IP address in the status information interface.

Where to change the IP address of Xianyu_Share how to change the IP address of Xianyu Where to change the IP address of Xianyu_Share how to change the IP address of Xianyu Mar 20, 2024 pm 05:06 PM

Xianyu is a very practical second-hand trading platform. Here we can buy many different products and sell our own idle items. What if we want to modify our address? Let’s take a look with the editor below! Share how to modify the Xianyu IP address. First, open the Xianyu software. After entering the homepage, you can see seafood market, recommendations, address and other options in the upper left corner. Click &quot;Address&quot;. 2. Then on the address page, we click the [Down Arrow] next to the address; 3. After the final click, we click on the city on the city selection page;

CentOS7 various version image download addresses and version descriptions (including Everything version) CentOS7 various version image download addresses and version descriptions (including Everything version) Feb 29, 2024 am 09:20 AM

When loading CentOS-7.0-1406, there are many optional versions. For ordinary users, they don’t know which one to choose. Here is a brief introduction: (1) CentOS-xxxx-LiveCD.ios and CentOS-xxxx- What is the difference between bin-DVD.iso? The former only has 700M, and the latter has 3.8G. The difference is not only in size, but the more essential difference is that CentOS-xxxx-LiveCD.ios can only be loaded into the memory and run, and cannot be installed. Only CentOS-xxx-bin-DVD1.iso can be installed on the hard disk. (2) CentOS-xxx-bin-DVD1.iso, Ce

How to change the location of Douyin IP address? Why does the IP address change location? How to change the location of Douyin IP address? Why does the IP address change location? Mar 21, 2024 pm 06:30 PM

Users share their lives, show off their talents, and interact with netizens across the country and even the world through Douyin. Some users wish to change their IP addresses on Douyin due to reasons such as privacy protection or geographical restrictions. So, how does the Douyin IP address change its location? 1. How to change the location of Douyin IP address? A proxy server is an intermediary service used to forward user requests to the Internet and return responses. By configuring a proxy server, users can hide their real IP addresses and change their IP addresses. This approach helps protect user privacy and improves network security. Proxy servers can also be used to access restricted content or bypass geolocation restrictions. Overall, using a proxy server is a practical network tool that can help users browse the Internet more safely and freely.

Steps to enter CentOS 7 emergency repair mode Steps to enter CentOS 7 emergency repair mode Jan 13, 2024 am 09:36 AM

Open the centos7 page and appear: welcome to emergency mode! afterloggingin, type "journalctl -xb" to viewsystemlogs, "systemctlreboot" toreboot, "systemctldefault" to tryagaintobootintodefaultmode. giverootpasswordformaintenance(??Control-D???): Solution: execute r

Bitcoin transaction IP address (Is the Bitcoin transaction IP address public?) Bitcoin transaction IP address (Is the Bitcoin transaction IP address public?) Feb 06, 2024 am 10:03 AM

Bitcoin transaction IP address Bitcoin transaction IP address is an indispensable and important component of the Bitcoin transaction system. It is the core of the Bitcoin trading platform through which Bitcoin traders can conduct Bitcoin transactions. The Bitcoin transaction IP address is the basis of the Bitcoin transaction system and the basis on which Bitcoin traders can conduct Bitcoin transactions. The Bitcoin trading IP address is a global network address used to locate the Bitcoin trading system’s servers and traders’ devices. By querying the Bitcoin transaction IP address, you can obtain transaction status and related information. In addition, Bitcoin trading IP addresses can also be used to connect clients to the Bitcoin trading system and traders’ devices. Are Bitcoin transaction IP addresses public? Bitcoin transaction IP addresses will not be made public

How to access and clean junk files in /tmp directory in CentOS 7? How to access and clean junk files in /tmp directory in CentOS 7? Dec 27, 2023 pm 09:10 PM

There is a lot of garbage in the tmp directory in the centos7 system. If you want to clear the garbage, how should you do it? Let’s take a look at the detailed tutorial below. To view the list of files in the tmp file directory, execute the command cdtmp/ to switch to the current file directory of tmp, and execute the ll command to view the list of files in the current directory. As shown below. Use the rm command to delete files. It should be noted that the rm command deletes files from the system forever. Therefore, it is recommended that when using the rm command, it is best to give a prompt before deleting the file. Use the command rm-i file name, wait for the user to confirm deletion (y) or skip deletion (n), and the system will perform corresponding operations. As shown below.

See all articles