Ifcfg-eth0 tutorials for starting and configuring the network card under CentOS

Source: Internet
Author: User
Tags nameserver

Step 1, configure the files in the/etc/sysconfig/network-scripts/ifcfg-eth0.

Configuration details for the Ifcfg-eth0 under CentOS6.4:

[[Email protected]]# vi/etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0

Type=ethernet

Uuid=5ff155a4-9a33-4224-8ae0-706eadf7fa3c

hwaddr=00:15:5d:a1:58:00

Onboot=no

Nm_controlled=yes

Bootproto=none

Ipaddr=202.205.161.xxx

Prefix=23

Gateway=202.205.xxx. Xx

Dns1=202.205.xxx. Xx

Dns2=219.142.xxx.xxx

Defroute=yes

Ipv4_failure_fatal=yes

Ipv6init=no

Name= "System eth0"

The previous six lines are system-brought, followed by manual additions.

After this setting, remember to restart the network card:

[[Email protected]]#/etc/init.d/network Stop

[[Email protected]]#/etc/init.d/network Start

Or

[Email protected]]#/etc/init.d/network Restart

After restarting the NIC, you also have to activate eth0 [[email protected]]# ifup eth0 #启动网络

When the computer restarts, the network is not automatically connected, but also need to configure the Ifcfg-eth0 file to enable the computer to automatically activate the network card and Internet connection

[[Email protected]]# vi/etc/sysconfig/network-scripts/ifcfg-eth0

To find the Onboot=no, change the parameter to Yes.

You can use the NTSYSV command to open the Management window if you set the Manage Startup item service under the graphical interface.

OK, now you can ping through the gateway, if you have to surf the Internet, you must also set up DNS. Setting up DNS is described in step 2

Step 2, modify DNS

[Email protected] ~]# vi/etc/resolv.conf

Add two DNS to the inside:

NameServer 202.205.xxx.xxx

NameServer 219.142.xxx.xxx

Step 2 has been set up on the above my.

OK, big attack Gaocheng, can surf the internet!!!

The following is a reference, if you do not follow the above steps, you can look at the following details:

Network Interface configuration file

[[Email protected]]# cat/etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

Type=ethernet #网卡类型

Device=eth0 #网卡接口名称

Onboot=yes #系统启动时是否自动加载

Bootproto=static #启用地址协议--static: Static protocol--BOOTP Protocol--DHCP Protocol

ipaddr=192.168.1.11 #网卡IP地址

netmask=255.255.255.0 #网卡网络地址

gateway=192.168.1.1 #网卡网关地址

dns1=10.203.104.41 #网卡DNS地址

hwaddr=00:0c:29:13:5d:74 #网卡设备MAC地址

broadcast=192.168.1.255 #网卡广播地址

Re-import the Ifcfg-eth0 network configuration file

[Email protected]]#/etc/init.d/network Reload

Shutting down interface eth0: [OK]

Shutting down loopback interface: [OK]

Bringing up loopback interface: [OK]

Bringing Up interface eth0: [OK]

Nic interface shutdown and activation

[Email protected]]# ifdown eth0 #关闭网络

[Email protected]]# ifup eth0 #启动网络

Network Service startup and shutdown

Method One:

[[Email protected] ~]# service network stop #关闭网络服务

[Email protected] ~]# service network start #启动网络服务

[Email protected] ~]# service network restart #重启网络服务

Method Two:

[[email protected] ~]#/etc/init.d/network stop

[[email protected] ~]#/etc/init.d/network start

[Email protected] ~]#/etc/init.d/network restart

Network card status Query

[Email protected] ~]# service network status

Configured devices:

Lo eth0

Currently active devices:

Lo eth0

Temporary configuration of network card information without rebooting.

[Email protected] ~]# ifconfig eth0 10.1.1.10 netmask 255.0.0.0

View NIC interface information, list all interfaces by default

[Email protected] ~]# ifconfig

Eth0 Link encap:ethernet HWaddr 00:0c:29:13:5d:74

inet addr:192.168.1.11 bcast:192.168.1.255 mask:255.255.255.0

Inet6 ADDR:FE80::20C:29FF:FE13:5D74/64 Scope:link

Up broadcast RUNNING multicast mtu:1500 metric:1

RX packets:413 errors:0 dropped:0 overruns:0 frame:0

TX packets:572 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:47701 (46.5 KiB) TX bytes:64842 (63.3 KiB)

Base address:0x2000 memory:d8920000-d8940000

Lo Link encap:local Loopback

inet addr:127.0.0.1 mask:255.0.0.0

Inet6 addr::: 1/128 scope:host

Up LOOPBACK RUNNING mtu:16436 metric:1

RX packets:407 errors:0 dropped:0 overruns:0 frame:0

TX packets:407 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:70759 (69.1 KiB) TX bytes:70759 (69.1 KiB)

View current Routing and gateway Information

[Email protected] ~]# Netstat-r

Kernel IP Routing Table

Destination Gateway genmask Flags MSS Window Irtt Iface

192.168.1.0 * 255.255.255.0 U 0 0 0 eth0

169.254.0.0 * 255.255.0.0 U 0 0 0 eth0

Default 192.168.1.1 0.0.0.0 UG 0 0 0 Eth0dns: Host name: CentOS main dns:202.106.46.151 Second dns:202.10 6.0.20 Third dns:8.8.8.8 network configuration: eth0 static ip:192.168.1.106 subnet mask 255.255.255.0 default gateway IP 192.168.1.1device=eth0ipaddr=192.168.1 .106netmask=255.255.255.0broadcast=192.168.1.255onboot=yesbootproto=nonegateway=192.168.1.1type=ethernet "/etc/ Sysconfig/network-scripts/ifcfg-eth0 "11L, 187C

Ifcfg-eth0 tutorials for starting and configuring the network card under CentOS

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.