Linux: fixed ip, linux fixed ip

Source: Internet
Author: User

Linux: fixed ip, linux fixed ip

By default, ip addresses are dynamically allocated using dhcp when the operating system is installed. Usually we need to fix it.

Otherwise, the ip address will change after each system restart, which will cause unnecessary troubles in daily work.

 

The following describes how to fix Ip addresses in rhel and centos.

 

1. Run the ifconfig command to check which network interfaces are available.

For example, the above ens33, lo. Here, lo is the loop, which is the local loop address. Ens33 is a fixed address.

Then there will be a ifcfg-ens33 configuration file under the/etc/sysconfig/network-scripts/directory. You can run the following command to verify it (the root user is required ):

Ls/etc/sysconfig/network-scripts | grep ifcfg-

 

 

2. Switch to the root user and use vim to edit the file:/Etc/sysconfig/network-scripts/ifcfg-Ens33

Note that:

Ipaddr: IP address. Enter the value of inet in ifconfig.

Netmask: Subnet Mask. Fill in the value of netmask in ifconfig above.

Gateway: refers to the gateway where the IP address is located. If your ip address is 192.168.0.x, the network segment is 192.168.0.1.

3. Run the reboot command to restart the machine after wq is saved.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.