How to set fixed IP under Linux

Source: Internet
Author: User
Tags nameserver

This article turns from Http://blog.163.com/[email protected]/blog/static/3766198320118231431594/

The Linux system is installed, and the NIC IP is configured later through command mode. The configuration file is usually/etc/sysconfig/network-scripts/ifcfg-interface-name

1. Configure the network card IP address

Vi/etc/sysconfig/network-scripts/ifcfg-eth0 #第二块网卡: Vi/etc/sysconfig/network-scripts/ifcfg-eth1

Device=eth0 #物理设备名
ipaddr=192.168.1.10 #IP地址
netmask=255.255.255.0 #掩码值
network=192.168.1.0 #网络地址 (not available)
broadcast=192.168.1.255 #广播地址 (not available)
gateway=192.168.1.1 #网关地址
Onboot=yes # [Yes|no] (whether the device is activated at boot time)
Userctl=no #[yes|no] (whether the device can be controlled by a non-root user)
Bootproto=static #[none|static|bootp|dhcp] (non-use protocol at boot | static Assignment | BOOTP protocol | DHCP protocol)

2. Configure Network card DNS

The configuration file is below/etc/resolv.conf.

Vi/etc/resolv.conf

NameServer 202.109.14.5 #主DNS

NameServer 219.141.136.10 #次DNS

Search Localdomain

So after the network configuration is complete, you need to restart the Network service: Service network restart or/etc/init.d/network restart

3. A single NIC binds two IPs

Linux Network device configuration file is stored in the/etc/sysconfig/network-scripts, for the first Ethernet network device, the configuration file name is generally ifcfg-eth0. If you need to bind more than one IP address to the first network device, just create a file named ifcfg-eth0:0 in the/etc/sysconfig/network-scripts directory with the following sample:

Device= "eth0:0"
Ipaddr= "211.100.10.119"
netmask= "255.255.255.0"
onboot= "Yes"

Where device is the name of the appliance, ipaddr the IP address of this device, netmask is the subnet mask, onboot indicates that it starts automatically when the system starts.
If you need to bind more than one IP address, simply add the file name and the eth0 in the device in the file. Linux can support a maximum of 255 IP aliases.

How to set fixed IP under Linux

Related Article

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.