How to set and activate IP addresses in linux

Source: Internet
Author: User
Article Title: how to set and activate an IP address in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

In Linux, how do I set IP addresses? We can use commands to set the IP address, but the prerequisite for this method is that the user needs the root permission. The nic ip address configuration information is stored in the/etc/sysconfig/network-script/ifcfg-eth0 file of the linux system. the specific format is:

# Cat ifcfg-eth0 [root @ localhost network-scripts] #

DEVICE = eth0

BOOTPROTO = none

ONBOOT = yes

TYPE = Ethernet

NETMASK = 255.255.255.0

IPADDR = IP address

USERCTL = no

PEERDNS = yes

GATEWAY = GATEWAY address (IP address of the router)


The following is an example of how to set IP addresses in Linux.


# Ifconfig eth0 192.168.0.1 or modify the ifcfg-eth0 under/etc/sysconfig/network-scripts/

# Vi/etc/syssconfig/network-scripts/ifcfg-eth0

  

DEVICE = eth0

BOOTPROTO = static

HWADDR =; here is the physical address of your Nic. you do not need to enter the detected Nic.

ONBOOT = yes

IPADDR = 192.168.0.1

NETMASK = 255.255.255.0

NETWORK = 192.168.1.0

BROADCAST = 192.168.1.255

GATEWAY =; enter the IP address of your GATEWAY and router.

Save and exit

#/Sbin/service network restart

If the enable Nic is OK, the IP address is successfully set. In addition, we can use ifconfig eth0 to display the current IP address to confirm whether it is set correctly.

Use the following command:

/Etc/init. d/network reload command or service network [command]

Re-import the file to start the network.

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.