Linux Learning CentOS (v)----Network card Configuration

Source: Internet
Author: User
Tags uuid

Linux system version: Centos 6.5 (server Edition)

Linux system version: Centos 7

Earlier, we used the remote tool SECURECRT, with the "ifconfig eth0 + specific IP Address" command to Linux with an IP address (refer to my blog:), but this configuration problem is:

    • Can only take effect temporarily, once reboot, need reconfiguration;
    • Only the IP address and subnet mask can be configured to connect to the intranet, it is not possible to connect the external network.

If you want to connect to an extranet, the IP address, subnet mask, gateway, and DNS are integral. Today, how to really give CentOS a IP, and set up successfully, by using the SECURECRT software, the same LAN on another Win7 system computer can also remotely access the Linux on this computer. There are many methods, and in the following two methods, I use the bridge mode in the virtual machine. If you install a dual system, the configuration method is the same. Given that there is a small difference between CentOS 6.5 and CentOS 7, here are a few words.

One, Centos 6.5 (server version) of the network card configuration:

"Method One" directly modifies the NIC configuration file:

(1) Enter the following command to modify the network card configuration file:

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

The modification information is as follows:

E=eth0//网卡名称

HWADDR=00:0c:29:5c:94:74//物理地址

TYPE=Ethernet

UUID=36c43db3-95a9-427c-af8f-ba130189de85

ONBOOT=yes //将ONBOOT="no"改为ONBOOT="yes"

NM_CONTROLLED=yes

BOOTPROTO=none

IPADDR=192.168.1.98//修改IP地址

NETMASK=255.255.255.0//修改子网掩码

GATEWAY=192.168.1.1//修改网关

DNS1=8.8.8.8//修改DNS服务器

IPV6INIT=no

USERCTL=no

(2) Restart the Network service:

To take effect, you must restart Linux or restart the network service, we restart the network service, execute the following command:

service network restart

If the display works as follows, the configuration is successful and the Internet access is available:

Note: This configuration is permanently in effect.

"Method Two" is one of the simplest: using the Redhat Series's own tool Setup command

Note: If the Linux distribution is not a Redhat series, it can only be modified with the configuration file (later).

(1) Modify IP:

Enter the following command:

setup

The following window pops up:

, select the third item: Network configuration. The following screen appears:

, the first one is with IP, the second is with DNS. We choose the first, with IP, pop up the following interface:

To eth0 this NIC configuration IP, pop up the following interface:

, the "*" number represents the automatic acquisition of IP, if you want to automatically obtain, the LAN must have automatic allocation of IP servers exist (that is, the DHCP server), in the current environment, can only be manually configured, we modify the parameters as follows:

This is the time to configure.

(2) Turn on the network card service:

The CentOS default network card is not started, we execute the following command, modify the NIC configuration file:

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

Then, change onboot= "No" to onboot= "yes", the effect is as follows:

This time, the configuration is complete. The same LAN in another Win7 system computer can also remotely access the Linux on this computer, if the Linux system already has the SSH service, we now install the Linux version, will be installed SSH, the default is OpenSSH

You can view the installed SSH version information by using the following command:

ssh -v

The SSH version information I installed for CentOS 6.5 is as follows:

For details on how to use the SSH service, please refer to one of my other blog posts:

Second, Centos 7 (server version) of the network card configuration:

CentOS 7 has a lot less in the NIC configuration file, so it is still necessary to mention the following separately, but it is the same as the CentOS 6.5 configuration method.

(1) Enter the following command to modify the network card configuration file:

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

The default configuration information is as follows:

TYPE=Ethernet

BOOTPROTO=dhcp

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=eth0

UUID=2e09b0f4-ec1a-44b0-8066-7da7ce04ff02

ONBOOT=no

HWADDR=00:0C:29:46:8C:C0

PEERDNS=yes

PEERROUTES=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

Modify the content Bootproto, and add content ipaddr, NETMASK, GATEWAY, DNS, the final effect is as follows:

TYPE=Ethernet

BOOTPROTO=static//将“DHCP”改为“static”

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=eth0

UUID=2e09b0f4-ec1a-44b0-8066-7da7ce04ff02

ONBOOT=yes//将“no”改为“yes”

HWADDR=00:0C:29:46:8C:C0

PEERDNS=yes

PEERROUTES=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPADDR=192.168.1.99//增加IP地址

NETMASK=255.255.255.0//增加子网掩码

GATEWAY=192.168.1.1//增加网关

DNS1=8.8.8.8//增加DNS

2) Restart the Network service:

To take effect, you must restart Linux or restart the network service, we restart the network service, execute the following command:

service network restart

If the display works as follows, the configuration is successful and the Internet access is available:

Linux Learning CentOS (v)----Network card Configuration

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.