RHCE path-network setting methods and parameters in Linux

Source: Internet
Author: User
Linux network configuration methods and some parameters. I. For Linux network configuration, we know that if a computer wants to access the Internet, some parameters must be set, including ip, mask, gateway, dns, and hostname. How can we set them in Linux? Before setting these parameters, let's talk about the name of the NIC in Linux. In Linux, we know that any device is a file. Therefore, in Linux, the NIC is also a file, that is, ethx, where x is a number and 0, it indicates the first Nic, which is 1,

Linux network configuration methods and some parameters.

I. Linux Network Configuration
We know that if a computer wants to access the Internet, some parameters must be set, including ip, mask, gateway, dns, and hostname. How can we set them in Linux?

Before setting these parameters, let's talk about the name of the NIC in Linux.
In Linux, we know that any device is a file.
Therefore, in Linux, the NIC is also a file, that is, ethx, where x is a number, 0, it indicates the first Nic, 1, it indicates the second Nic, and so on.
The first Nic is eth0, the second Nic is eth1, and the third Nic is eth2, and so on. You just need to remember it. There is no reason.
1. Configure the ip address first
You can use the ipconfig command to view the details of all network adapters.
Ifconfig ethx ip/mask example
Ifconfig eth0 192.168.0.25/24
Set the IP address of the first Nic to 192.168.0.25 and the subnet mask to 255.255.255.0, that is, the first 24 bits are the network bits.

2. How to Use and disable the NIC
Use two commands ifup and ifdown
Ifup ethx or ifdown ethx indicate enable Nic and disable Nic respectively.

However, these settings are temporarily valid,
After the system is restarted, it becomes invalid. If you want to set it to permanently valid, what should you do? Then we can edit the network-related configuration file.
You can set it in three ways. Two of them are set in the graphic interface. I will not talk about them here. Only the third method of editing text files is described in detail for configuration. Take the first Nic as an example.
Nic configuration files:/etc/sysconfig/network-scripts/ifcfg-eht0
Use vim to open this file. There are several options, which can be assigned with different values. The main options are as follows:
1. DEVICE = eth0
2. BOOTPROTO =
3. IPADDR =
4. NETMASK =
5. GATEWAY =
6. ONBOOT =
7. USERCTL =
8. TYPE =
9. DHCPCLASS =

1. The name of the NIC behind the DEVICE. The value must be the same as the name of the NIC in the opened configuration file.
In this example, eth0
2. BOOTPROTO indicates the way the IP address is obtained. There are four optional values: dhcp, static, none, bootp.
Dhcp dynamically obtains the IP address. If this method is used, the following IPADDR and NETMASK do not need to set the value. static is the static IP address, which can be specified by ourselves, none is not set IP address, bootp is
An earlier Protocol automatically obtained an IP address. However, after the IP address is shut down and restarted, the obtained IP address is no longer returned to the address pool, but becomes private. Currently, ipv4 addresses are not enough, this method is rarely used.
3. IPADDR is followed by the IP address. If the IP address is obtained through dhcp, you do not need to set this parameter.
4. NETMASK indicates the subnet mask of the corresponding ip address, followed by the subnet mask.
5. GATEWAY. It indicates the default GATEWAY. The so-called default GATEWAY is the default route for the host to connect to the Internet. This option is followed by the IP address of the default route.
6. ONBOOT indicates whether or not the boot starts along with the system. There are two optional values. Yes/no respectively. If yes is selected, the system starts up with the system, and no is not started with the system.
7. USERTCL. Indicates whether normal users can enable or disable NICs. There are two optional values: yes/no,
If yes is selected, normal users can enable or disable the NIC. If no is selected, normal users cannot enable or disable it.
Online.
8. TYPE indicates the network TYPE, which is not commonly used
9. DHCPCLASS indicates the DHCP type. I will talk about this later.

After setting the items above, save and exit, and then restart the network service, it will take effect permanently.

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.