CentOS for Linux (5)-nic configuration, linuxcentos

Source: Internet
Author: User

CentOS for Linux (5)-nic configuration, linuxcentos

 

[Statement]

Reprinted, but keep the original source of the article → _ →

Life One: http://www.cnblogs.com/smyhvae/

Source: http://www.cnblogs.com/smyhvae/p/3932903.html

Contact: smyhvae@163.com

 

[Body]

Linux: Centos 6.5

Linux: Centos 7

Previously, we used the remote tool SecureCRT and assigned linux an IP address through the "ifconfig eth0 + specific IP Address" command (refer to my blog: use of the remote logon management tool SecureCRT ), however, the problem with this configuration is:

  • It can only take effect temporarily. Once restarted, You need to reconfigure it;
  • Only IP addresses and subnet masks can be configured. You can connect to the Intranet and cannot connect to the Internet.

If you want to connect to the Internet, IP addresses, subnet masks, gateways, and DNS are indispensable. Today, how can I configure an ip address for CentOS and use SecureCRT after it is set successfully, another Win7 System Computer in the same LAN can also remotely access Linux on this computer. There are many methods. In the following two methods, I use the bridging mode in the virtual machine. If you install dual systems, the configuration methods are the same. Considering the differences between Centos 6.5 and Centos 7, let's talk about them here.

 

1. Nic configuration of Centos 6.5 (server version:

[Method 1] directly modify the NIC configuration file:

(1) enter the following command to modify the NIC configuration file:

vi /etc/sysconfig/network-scripts/ifcfg-eth0 

The modification information is as follows:

E = eth0 // Nic name HWADDR = 00: 0c: 29: 5c: 94: 74 // physical address TYPE = EthernetUUID = bytes = yes // change ONBOOT = "no" to ONBOOT = "yes" NM_CONTROLLED = yesBOOTPROTO = noneIPADDR = 192.168.1.98 // modify the IP address NETMASK = 255.255.0 // modify the subnet mask GATEWAY = 192.168.1.1 // modify the GATEWAY DNS1 = 8.8.8.8 // modify the DNS server IPV6INIT = noUSERCTL = no

(2) restart the network service:

To take effect, you must restart Linux or the network service. Restart the network service and run the following command:

service network restart 

If the result is as follows, the configuration is successful and the Internet is accessible:

Note: This configuration takes effect permanently.

 

Method 2: Use the Redhat tool setup command

Note: If the Linux release is not a RedHat series, you can only modify the configuration file (method 1 above ).

(1) modify the ip Address:

Enter the following command:

setup 

The following window is displayed:

Select network configuration. The following page is displayed:

, The first is with ip address, and the second is with DNS. Select the first one. The following page is displayed:

Configure the ip address for the eth0 Nic. The following page is displayed:

"*" Indicates that the ip address is automatically obtained. To obtain the ip address automatically, a server (DHCP server) with an automatically assigned ip address must exist in the LAN. In the current environment, only manual configuration is allowed. we modify the parameters as follows:

Press the Space key and remove "*". Then we can switch through the tab key and set each field. The configuration is completed at this time.

(2) Enable the NIC service:

The default Nic of CentOS is not started. Run the following command to modify the NIC configuration file:

vi /etc/sysconfig/network-scripts/ifcfg-eth0 

Then, change ONBOOT = "no" to ONBOOT = "yes". The effect is as follows:

At this time, the configuration is complete and you can access the Internet. In addition, another Windows 7 System Computer in the same LAN can remotely access Linux on this computer, provided that the Linux system already has the ssh service, SSH is installed. OpenSSH is used by default.

You can run the following command to view the installed ssh version:

ssh -v 

The ssh version of CentOS 6.5 that I installed is as follows:

For details about how to use the ssh service, refer to another blog: use the remote logon management tool SecureCRT.

 

Ii. Nic configuration for Centos 7 (server version:

The NIC configuration file of Centos 7 contains a lot of things, so it is necessary to mention the following separately, but the configuration method is the same as that of Centos 6.5.

(1) enter the following command to modify the NIC configuration file:

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736 

The default configuration information is as follows:

TYPE=EthernetBOOTPROTO=dhcpDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noNAME=eth0UUID=2e09b0f4-ec1a-44b0-8066-7da7ce04ff02ONBOOT=noHWADDR=00:0C:29:46:8C:C0PEERDNS=yesPEERROUTES=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yes 

Modify the content BOOTPROTO and add IPADDR, NETMASK, GATEWAY, and DNS. The final effect is as follows:

TYPE = EthernetBOOTPROTO = static // change "DHCP" to "static" DEFROUTE = Signature = notes6init = yesIPV6_AUTOCONF = yesIPV6_DEFROUTE = Signature = noNAME = eth0UUID = Signature = yes // change "no" change "yes" HWADDR = 00: 0C: 29: 46: 8C: c0PEERDNS = yesPEERROUTES = yesIPV6_PEERDNS = route = yesIPADDR = 192.168.1.99 // Add IP address NETMASK = 255.255.255.0 // Add subnet mask GATEWAY = 192.168.1.1 // Add GATEWAY DNS1 = 8.8.8.8.8 // Add DNS

(2) restart the network service:

To take effect, you must restart Linux or the network service. Restart the network service and run the following command:

service network restart 

If the result is as follows, the configuration is successful and the Internet is accessible:

In this way, we are done.

 


Network settings in linux (centos5)

1) Find A 8169 NIC Driver and install it.

2) If DHCP is enabled for your route, the IP address can be automatically assigned. You do not need to set it. If it is not enabled, you can configure it based on the IP address of the route and so on, however, be careful when setting the IP address of another computer.

Is the remote network the Ip address and subnet mask of the local machine required?

In Linux (CentOS 62), how does one configure DNS configuration and command?

On the command line interface
Vi/etc/resolv. conf
Jump to the last line by uppercase G,
Then, press A in upper case to jump to the end character of the last line,
Then press the back space key on the disk, delete the original IP address, and enter your actual dns ip address again.
Then Press ESC on the drive,
Finally: wq. Remember that there is a colon Before wq.
It means saving the configuration and then exiting.

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.