How to set a fixed IP in Linux (tested and effective)

How to set a fixed IP in Linux (tested and effective)

First, open the virtual machine

Open xshell5 to connect to the virtual machine (more convenient, the Linux ip is set by default here, but it is not fixed)

Enter ifconfig to view network management related configuration information:

Then enter the vi /etc/sysconfig/network-scripts/ifcfg-ens33 command. Modify the network card configuration file

Press i to edit. Make the changes below. Do not delete the original configuration, just modify it as follows. Just add the configuration items that are not available.

After opening it, you can see that the default configuration is DHCP, and then onboot=no, which means it will not start when the system starts. We need to modify this configuration

Then create two values ​​ip and subnet mask below and add them to any position in the above picture.

IPADDR=192.168.0.116 (fill in your IP address) #IP address

NETMASK=255.255.255.0 (fill in your mask value) #Mask value

GATEWAY=192.168.0.1 (default gateway)

DNS1=8.8.8.8 (using Google's default DNS server)

If the above 4 items are not available, add them. If they are available, modify them (configure as shown above, and delete other parameters, they are useless)

Esc to exit editing, :wq to save and exit, reboot to restart

After restarting, enter ifconfig to check whether the IP modification is successful.

The above is a detailed explanation of how to set up a fixed IP in Linux. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Example of how to get the local IP address through Python under Linux
  • How to get IP address using python3 in linux
  • Example method of viewing IP in Linux

<<:  How to detect if the current browser is a headless browser with JavaScript

>>:  Detailed explanation of MySQL database (based on Ubuntu 14.0.4 LTS 64 bit)

Recommend

Linux 6 steps to change the default remote port number of ssh

The default ssh remote port in Linux is 22. Somet...

How to change the password of mysql5.7.20 under linux CentOS 7.4

After MySQL was upgraded to version 5.7, its secu...

Native JS to achieve book flipping effects

This article shares with you a book flipping effe...

Implementation of building custom images with Dockerfile

Table of contents Preface Introduction to Dockerf...

Detailed explanation of how to create MySql scheduled tasks in navicat

Detailed explanation of creating MySql scheduled ...

Solve the problem that Docker must use sudo operations

The steps are as follows 1. Create a docker group...

CSS pseudo-class: empty makes me shine (example code)

Anyone who has read my articles recently knows th...

How to set the position of the block element in the middle of the window

How to set the position of the block element in t...

What are Web Slices?

IE8 new feature Web Slices (Web Slices) Microsoft...

How to implement element floating and clear floating with CSS

Basic Introduction to Floating In the standard do...

Bootstrap 3.0 study notes CSS related supplement

The main contents of this article are as follows:...

Tomcat configuration and how to start it in Eclipse

Table of contents How to install and configure To...

Detailed explanation of the use of Linux seq command

01. Command Overview The seq command is used to g...

CSS makes tips boxes, bubble boxes, and triangles

Sometimes our pages will need some prompt boxes o...

Tutorial on resetting the root password of Mac MySQL

Disclaimer: This password reset method can direct...