How to configure a Linux Nic

Source: Internet
Author: User
Nic configuration: 1. Nic configuration files configure Nic information, including IP addresses, subnet masks, and gateways. The NIC information is saved in the NIC configuration file. The NIC configuration file is located in the/etc/sysconfig/network-scripts directory. A Nic corresponds to a Nic configuration file ,...
Nic configuration: 1. Nic configuration files configure Nic information, including IP addresses, subnet masks, and gateways. The NIC information is saved in the NIC configuration file. The NIC configuration file is located in the/etc/sysconfig/network-scripts directory. A Nic corresponds to a Nic configuration file. the configuration file naming rules are as follows: ifcfg-Nic type and Nic serial number. because the Nic type is eth, the NIC serial number starts from 0, so the configuration file name of the first Nic is called the ifcfg-eth0, the second Nic is the ifcfg-eth1, and so on. The commonly used configuration file names in the NIC configuration file are also defined as follows: DEVICE = eth0. BOOTPROTO = dhcp, start the identification name of the NIC. Static/none: represents a fixed IP address; bootp/dhcp: obtains an IP address through the BOOTP or DHCP protocol. HWADDR = 00: 02: B3: 0B: 64: 22, the MAC address of the NIC. Www.2cto.com ONBOOT = yes, whether to enable the network adapter when starting the network service. When the RedHat system starts the network service, the network service reads all the Nic configuration files stored in the/etc/sysconfig/network-scripts/directory at a time. If ONBOOT in the NIC configuration file is set to yes, the network service calls the ifup command to start the NIC. if the ONBOOT parameter in the NIC configuration file is no, the network skips the start of this Nic. TYPE = Ethernet, network card TYPE. USERCTL = no, whether to allow normal users to start or stop the NIC. IPV6INIT = no, whether to enable the IPV6 function on the NIC. PEERDNS = yes, whether to allow the NIC to query DNS information from the DHCP server at startup, and automatically overwrite the/etc/resolv. conf configuration file. The following configuration items are used to specify the static IP address of the NIC. at this time, BOOTPROTO must be static or none. IPADDR = 192.168.1.55. specify the IP address of the NIC in static mode. NETMASK = 255.255.255.0, which defines the subnet mask of the network card. MTU = 1500, set the maximum transmission unit of the MAC frame of the NIC. GATEWAY = 192.168.1.1. set the default GATEWAY of the network. DNS1 = 192.168.128.5. specify the primary DNS server address. DNS2 = 192.168.128.6: specify the address of the backup DNS server. 2. you can directly modify the related content in the NIC configuration file by configuring the Nic information. However, this method has high requirements on users. The three commands used in RedHat Enterprise Linux5 to set IP addresses are system-config-network, setup, and ifconfig. The method for setting IP addresses in ifconfig is described in the common commands section. (1) run the system-config-network command www.2cto.com and enter the system-config-network command in the command prompt line to start the visual network configuration interface (this method is simple for beginners) (2) after you enter the setup command under the command line, the system setting interface is displayed. then, you can select Nic settings to enter the Nic setting interface (many systems can use the setup command to set the NIC, widely used) (3) ifconfig: the ifconfig command is powerful for viewing and setting Nic information. A. command syntax: ifconfig [parameter] parameter description: no parameter: displays the currently active Nic-a: displays the configuration information of all NICs in the system Nic device name: display the configuration information of the specified Nic. for example, view eth0 Nic information: # ifconfig eth0b. set IP address command syntax: ifconfig Nic device name IP address netmask subnet mask (note: the IP address set by the ifconfig command takes effect immediately, but after the machine is restarted, the IP address is returned to the original IP address, therefore, the ifconfig command can only be used to set a temporary IP address. for example: ifconfig eth0 192.168.168.156 netmask 255.255.255.0c. modify the MAC address command syntax: ifconfig Nic device name hw ether MAC address (note: disable the NIC before modifying the MAC address of the NIC. enable the Nic after the NIC is modified) eg: ifconfig eth0 hw ether 00: 0C: 29: 03: F3: 76 Order: www.2cto.com 1. ifdown disable Nic syntax: ifdown Nic device name 2. ifup enable Nic syntax: ifup Nic device name 3. how to bind an IP address to a MAC address: create the/etc/ethers file, the file content is "IP address mac address", and then run the "arp-f" command to make the configuration take effect. For example, bind the IP address 193.168.168.154 to the MAC address 00: 0C: 29: 03: F3: 75. # Echo "193.168.168.154 00: 0C: 29: 03: F3: 75">/etc/ethers # arp-f by Ziling Wolf
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.