Linux IP Address Configuration

Source: Internet
Author: User

You can use neat, netconfig, and ifconfig to configure IP addresses in linux. The first two of them have a user interface, and the third command only sets the IP address temporarily. After the machine is restarted, the configuration will be lost.

Sometimes it is difficult to obtain graphical user interface programs. Here is a direct method to modify the network configuration file.

The general network configuration file name is: ifcfg-eth [x], this x can be 0, 1, 2, etc., because you can set multiple networks, if only one is set, the configuration file name is ifcfg-eth0, file Location:

/Etc/sysconfig/network-scripts/ifcfg-eth0

1. Modify the network configuration file

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # Set the network card name, which must correspond to the file name #
ONBOOT = yes# Whether to enable the NIC at startup #
BOOTPROTO = static# The IP address obtained at startup is fixed here. If it is a dynamic host, it must be changed to dhcp #
IPADDR = 192.168.1.2# IP address #
NETMASK = 255.255.255.0# Subnet mask #
NETWORK = 192.168.1.0 # The first IP address of the NETWORK segment #
BROADCAST = 192.168.1.255 # BROADCAST address of the last same network segment #
GATEWAY = 192.168.1.2 # GATEWAY address #
# GATEWAYDEV = eth0

When the linux host is installed, the default value of the ONBOOT attribute is no. You need to change it to yes, and the default value of BOORPROTO is dhcp. You need to change it to static.

Set the IP address, network mask, and gateway.

2. Restart the network service.

Use it after setting:

Service network restart

Make the network settings take effect.

Red Hat Linux passed the test.

NOTE: If ONBOOT is set to no, the service network restart startup error may occur.

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.