码迷,mamicode.com
首页 > 系统相关 > 详细

Linux Static IP Configuration

时间:2015-06-15 23:32:26      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:

如题:如何给Linux系统设置静态IP地址

  1. Centos OS 6.5
    vi /etc/sysconfig/network-scripts/ifcfg-<interface_alias_name>  
    默认修改:/etc/sysconfig/network-scripts/ifcfg-eth0

    File: /etc/sysconfig/network-scripts/ifcfg-eth0
    技术分享
    # Configuration for eth0
    DEVICE=eth0
    BOOTPROTO=none
    
    # This line ensures that the interface will be brought up during boot.
    ONBOOT=yes
    # eth0 - This is the main IP address that will be used for most outbound connections.
    # The address, netmask, and gateway are 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

    技术分享
    # Configuration for eth0:0
    DEVICE=eth0:0
    BOOTPROTO=none
    
    # This line ensures that the interface will be brought up during boot.
    ONBOOT=yes
    
    # eth0:0
    IPADDR=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 will be brought up during boot.
    ONBOOT=yes
    
    # eth0:1
    # This is a private IP address. Private IPs do not have a gateway (they are not publicly routable).
    # All you need to specify is the address and netmask
    IPADDR=192.168.133.234
    NETMASK=255.255.128.0
    eth0:1 Code

    service network restart

  2. Centos 7
    Centos 7 不再使用"Network"服务, 你必须创建/etc/sysconfig/network-scripts/ifcfg-eth0文件
    File: /etc/sysconfig/network-scripts/ifcfg-eth0 
    技术分享
    DEVICE="eth0"
    HWADDR="00:21:70:10:7E:CD"
    NM_CONTROLLED="no"
    ONBOOT="yes"
    BOOTPROTO=static
    # BOOTPROTO=dhcp
    IPADDR=192.168.1.106
    NETMASK=255.255.255.0
    #
    #   the GATEWAY is sometimes in: /etc/sysconfig/network
    GATEWAY=192.168.1.1
    sample ‘static assignment‘ configuration Code

Linux Static IP Configuration

标签:

原文地址:http://www.cnblogs.com/Mrhuangrui/p/4579290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!