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

Example analysis of the impact of MySQL index on sorting

This article uses examples to illustrate the impa...

How to use gdb to debug core files in Linux

1.core file When a Segmentation fault (core dumpe...

The difference between clientWidth, offsetWidth, scrollWidth in JavaScript

1. Concept They are all attributes of Element, in...

If I change a property randomly in Vue data, will the view be updated?

Interviewer: Have you read the source code of Vue...

Correct use of MySQL partition tables

Overview of MySQL Partitioned Tables We often enc...

Vue implements dynamic circular percentage progress bar

Recently, when developing a small program, I enco...

Docker container exits after running (how to keep running)

Phenomenon Start the Docker container docker run ...

MySQL 5.7 installation and configuration method graphic tutorial

This tutorial shares the installation and configu...

How to select all child elements and add styles to them in CSS

method: Take less in the actual project as an exa...

Practice of realizing Echarts chart width and height adaptation in Vue

Table of contents 1. Install and import 2. Define...

MySQL partitions existing tables in the data table

Table of contents How to operate Operation proces...

Steps to install MySQL 5.7 in binary mode and optimize the system under Linux

This article mainly introduces the installation/st...

Detailed steps for installing rockerChat in docker and setting up a chat room

Comprehensive Documentation github address https:...