Linux Static IP Configuration

Source: Internet
Author: User

Title: How to set a static IP address for a Linux system

  1. Centos OS 6.5
    Vi/etc/sysconfig/network-scripts/ifcfg-<interface_alias_name>
    Default modification:/etc/sysconfig/network-scripts/ifcfg-eth0

    File:/etc/sysconfig/network-scripts/ifcfg-eth0
     for eth0device=Eth0bootproto= none# This line ensures that the interface would be isbrought up during boot. Onboot= for most outbound connections.# the address, netmask, and gateway is all necessary. IPAddr=192.168. 100.5 NETMASK=255.255. 255.0 GATEWAY=198.168. 100.1
    eth0 Code

    File:/etc/sysconfig/network-scripts/ifcfg-eth0:0

     for eth0:0DEVICE=eth0:0Bootproto= none# This line ensures that the Interface'll is brought up during boot. Onboot=yes# eth0:0ipaddr=192.0. 2.6 NETMASK=255.255. 255.0
    eth0:0 Code

    File:/etc/sysconfig/network-scripts/ifcfg-eth0:1

     # Configuration for  eth0:1  device  =eth0:1  bootproto  =none# this line ensures that the interface would be is brought up during boot. Onboot  =yes# eth0:  1  # This is a private IP address. Private IPs  do   not having a gateway (they is Not publicly routable). # All need to specify are the address and netmaskipaddr  =192 .168 . 133.234  netmask  =255.255 . 128.0  
    eth0:1 Code

    Service Network restart

  2. Centos 7
    Centos 7 no longer uses the "Network" service, you must create a/etc/sysconfig/network-scripts/ifcfg-eth0 file
    File:/etc/sysconfig/network-scripts/ifcfg-eth0
    Device="eth0"HWADDR="00:21:70:10:7E:CD"nm_controlled="No"Onboot="Yes"Bootproto=static# Bootproto=dhcpipaddr=192.168.1.106NETMASK=255.255.255.0# # The GATEWAY is sometimesinch:/etc/sysconfig/Networkgateway=192.168.1.1
    sample ' static assignment ' configuration Code

Linux Static IP Configuration

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.