CentOS Nic startup, configuration and other ifcfg-eth0 tutorials

Source: Internet
Author: User
Tags nameserver

CentOS Nic startup, configuration and other ifcfg-eth0 tutorials

Step 1 configure the file in/etc/sysconfig/network-scripts/ifcfg-eth0. It power CentOS under the ifcfg-eth0 configuration details:

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE="eth0"HWADDR="00:0C:29:FD:FF:2A"NM_CONTROLLED="yes"ONBOOT="yes"IPADDR=192.168.1.31NETMASK=255.255.255.0GATEWAY=192.168.1.1BOOTPROTO=static

The first three lines are system labels and are manually added later. In this case, remember to restart the NIC:

[root@localhost ~]# /etc/init.d/network stop[root@localhost ~]# /etc/init.d/network start

Now, you can PING the gateway. If you have to access the Internet, you do not need to set DNS. For more information about DNS settings, see Step 2.

Step 2. Modify dns [root @ localhost ~] # Vi/etc/resolv. conf add two dns: nameserver 202.96.134.20.nameserver 8.8.8.8.8

OK. The attack is successful. You can access the Internet !!!!

For more information, see the network interface configuration file.

[Root @ localhost ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0 # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) TYPE = Ethernet # Nic type device = eth0 # Nic Interface Name ONBOOT = yes # Whether to automatically load BOOTPROTO = static when the system starts # enable address protocol -- static: static protocol -- bootp protocol -- dhcp protocol IPADDR = 192.168.1.11 # Nic IP address NETMASK = 255.255.255.0 # Nic network address GATEWAY = 192.168.1.1 # Nic GATEWAY address DNS1 = 10.203.104.41 # Nic DNS address HWADDR = 00: 0C: 29: 13: 5D: 74 # Nic device MAC address BROADCAST = 192.168.1.255 # Nic Broadcast address re-import ifcfg-eth0 network profile [root @ localhost ~] #/Etc/init. d/network reloadShutting down interface eth0: [OK] Shutting down loopback interface: [OK] Bringing up loopback interface: [OK] Bringing up interface eth0: [OK]

Disable and activate the NIC interface [root @ localhost ~] # Ifdown eth0 # disable the network [root @ localhost ~] # Ifup eth0 # Start the network

Method 1: [root @ localhost ~] # Service network stop # disable the network service [root @ localhost ~] # Service network start # start the network service [root @ localhost ~] # Service network restart # Method 2: [root @ localhost ~] #/Etc/init. d/network stop [root @ localhost ~] #/Etc/init. d/network start [root @ localhost ~] #/Etc/init. d/network restart Nic status query [root @ localhost ~] # Service network status Configured devices: lo eth0 Currently active devices: lo eth0

Configure the NIC information temporarily without restarting. [Root @ localhost ~] # Ifconfig eth0 10.1.1.10 netmask 255.0.0.0 view Nic interface information. All interfaces are listed by default.

[root@localhost ~]# ifconfigeth0      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-d8940000lo        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 the current route and gateway information [root @ localhost ~] # 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 255.* 255.255.0.0 U 0 0 eth0 default 192.168.1.1 0.0.0.0 UG 0 0 0 0 eth0DNS: host Name: CentOS primary DNS: 202.106.46.151 second DNS: 202.106.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 = 255.= 255.255.255.0BROADCAST = 255.= yesBOOTPROTO = noneGATEWAY = 192.168.1.1TYPE = Ethernet "/etc/sysconfig/network-scripts/ifcfg-eth0" 11L, 187C

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.