How to set a fixed IP address in linux

Source: Internet
Author: User
Tags nameserver
After the linux system is installed, configure the nic ip address in command mode. The configuration file is usually etcsysconfignetwork-scriptsifcfg-interface-name1 configuration nic ip address vietcsysconfignetwork-scriptsifcfg-eth0 second Nic:

After the linux system is installed, configure the nic ip address in command mode. The configuration file is usually/etc/sysconfig/network-scripts/ifcfg-interface-name

1. configure the nic ip address

Vi/etc/sysconfig/network-scripts/ifcfg-eth0 # Second Nic: vi/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE = eth0 # physical DEVICE name
IPADDR = 192.168.1.10 # IP address
NETMASK = 255.255.255.0 # mask value
NETWORK = 192.168.1.0 # NETWORK address (optional)
BROADCAST = 192.168.1.255 # BROADCAST address (optional)
GATEWAY = 192.168.1.1 # GATEWAY address
ONBOOT = yes # [yes | no] (whether to activate the device during boot)
USERCTL = no # [yes | no] (whether non-root users can control the device)
BOOTPROTO = static # [none | static | bootp | dhcp] (no protocol used during boot | static allocation | BOOTP protocol | DHCP protocol)

2. configure the Nic DNS

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

Vi/etc/resolv. conf

Nameserver 202.109.14.5 # Primary DNS

Nameserver 219.141.136.10 # Secondary DNS

Search localdomain

Therefore, after the network configuration is complete, you must restart the network service: service network restart or/etc/init. d/network restart.

3. bind two IP addresses to a single NIC

Linux network device configuration files are stored in/etc/sysconfig/network-scripts, for the first network device Ethernet, the configuration file name is generally ifcfg-eth0. To bind one more IP address to the first network device, create a file named ifcfg-eth0: 0 in the/etc/sysconfig/network-scripts directory, as shown in the following example:

DEVICE = "eth0: 0"
IPADDR = "211.100.10.119"
NETMASK = "255.255.255.0"
ONBOOT = "yes"

DEVICE indicates the DEVICE name, IPADDR indicates the IP address of the DEVICE, NETMASK indicates the subnet mask, and ONBOOT indicates automatic start at system startup.
If you need to bind another IP address, you only need to add one of the file name and the eth0 in the DEVICE in the file. LINUX supports up to 255 IP aliases.

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.