How to set a static IP for a Linux server

Source: Internet
Author: User

The CentOS 7 Series is the example of setting up a static IP, the original Redhat series of Linux distributions can be easily set up by the Setup tool static IP, but after version 7, the function of the setup tool is gradually weakened, so this time by modifying the configuration file to set the static IP, Here's how:

First note that the routing gateway must be set to configure static IP or use the specified IP binding Mac can be configured, otherwise the configuration is unsuccessful, do not blindly configure

Configuration file for network configuration under/etc/sysconfig/network-scripts/, the filename prefix is ifcfg-followed by the name of the network card, you can view and edit by Double tab, or you can use Ifconfig to view or use the command: ls/etc/sysconfig/network-scripts/ifcfg-* lists all of the device configuration files,

  

For example, this is the ifcfg-eno16777984 file, Ifcfg-lo is the local loopback address configuration file, all computers have, do not move him,

Now use: vim/etc/sysconfig/network-scripts/ifcfg-eno16777984 to open the configuration file for editing, which is dynamically obtained by DHCP, such as:

  

At this time if you want to change to static, first change the bootproto= "DHCP" to bootproto= "static" for static acquisition, and then at the end append such as the following configuration:

broadcast=192.168.1.255ipaddr=192.168.1.33netmask=255.255.255.0gateway=192.168.1.1

Broadcast set is the LAN broadcast address, IPADDR is the static ip,netmask is the subnet mask, gateway is gateways or routing address, need to explain, there is a network configuration is the LAN number, this is Ifcalc automatic calculation, So configuring these here is sufficient, and the final configuration is as follows:

  

Save exit after configuration is complete,

The DNS configuration file location is:/etc/resolv.conf, the inside of the nameserver specify the DNS server address, this configuration is very simple not to say the details

are set up, and then use the command: /etc/init.d/network restart or service network Restart to restart the Network service, if the route is configured to support static IP after a reboot, Then Linux can get the IP address you just configured so that the static IP is configured successfully

How to set a static IP for a Linux server

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.