How to use network adapter configuration under Linux

Source: Internet
Author: User
Tags ssh access

Use environment for CentOS6.6 version;


1. Check the network card IP address ifconfig

Nic configuration file:/etc/sysconfig/network-scripts/ifcfg-eth0

If there are more than one network card, eth1, eth2 ...

If Linux has more than one NIC, just want to restart a NIC using command # ifdown eth0; ifup eth0

Ifdown Stop the network card, ifup start the network card;

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/6b/a0/wkiol1uze1wrd421aabgtjcyhzg514.jpg "title=" qq picture 20150416171210.png "alt=" Wkiol1uze1wrd421aabgtjcyhzg514.jpg "/>

If we telnet to the server and use Ifdown eth0 to stop the network card, subsequent commands will not be run, which will cause the network to fail to connect to the server. So please try to restart the network card using service network restart ;


2. Set multiple IPs for a network card

[[email protected] ~]# Cd/etc/sysconfig/network-scripts/[[email protected] network-scripts]# CP Ifcfg-eth0 ifcfg-eth0\ : 1

Edit ifcfg-eth0:1 This configuration file, change the inside Device=eth0:1 set the new IP address 192.168.20.30;

[Email protected] network-scripts]# vim ifcfg-eth0:1device=eth0:1hwaddr=00:0c:29:43:3d:32type=ethernetuuid= 0b1f4512-cefa-4a9e-ae85-adb2ac2a9903onboot=yesnm_controlled=yesbootproto=staticipaddr=192.168.20.30netmask= 255.255.255.0gateway=192.168.20.1

After saving the exit, restart the network card;

[Email protected] network-scripts]# service network restart

[[Email protected] network-scripts]# ifconfig eth0      link  encap:Ethernet  HWaddr 00:0C:29:43:3D:32             inet addr:192.168.20.20  bcast:192.168.20.255  mask : 255.255.255.0          inet6 addr: fe80::20c:29ff : Fe43:3d32/64 scope:link          up broadcast  RUNNING MULTICAST  MTU:1500  Metric:1           RX packets:62506 errors:0 dropped:0 overruns:0 frame:0           TX packets:82867 errors:0 dropped:0  overruns:0 carrier:0          collisions:0  txqueuelen:1000           RX bytes:38679452  (36.8 MIB)   tx bytes :47133078  (44.9 MIB)           Interrupt:18  base address:0x2000 eth0:1    link encap:ethernet  hwaddr  00:0c:29:43:3d:32            inet addr :192.168.20.30  bcast:192.168.20.255  mask:255.255.255.0           UP BROADCAST RUNNING MULTICAST  MTU:1500   metric:1          interrupt:18 base address:0x2000

You can see one more IP, you can use remote SSH access to this 192.168.20.30;



3. Check the network card connection status mii-tool eth0

[[email protected] ~]# mii-tool eth0siocgmiiphy on ' eth0 ' failed:operation not supported

Because it is a virtual machine so display "operation not supported", the real machine will show eth0:negotiated 100basetx-fd, link ok;"link OK" indicates that the NIC is connected "No link" indicates that the NIC is broken or not connected to a network cable.


4. Change host Name

Hostname View the host name of the system;

The hostname hostname can change the hostname, and the login prompt will be changed the next time you log on, so the changes are only temporarily saved in memory and will not take effect after restarting;

[[email protected] ~]# hostname yonglinux.com[[email protected] ~]# hostnameangel[[email protected] ~]# hostnameangel[[ Email protected] ~]# hostname Angel


To permanently change the hostname, you need to edit the configuration file /etc/sysconfig/network, change the hostname, save the exit after the restart to take effect;

Networking=yes

Hostname=yonglinux.com


5. Set up DNS

DNS for the domain name resolution, the domain name is resolved to an IP address;

Configuration file is/etc/resolv.conf

[Email protected] ~]# cat/etc/resolv.conf; Generated By/sbin/dhclient-scriptnameserver 192.168.20.2

Multiple DNS addresses can be added in the format: nameserver IP Address


Linux also has a special file /etc/hosts can also resolve the domain name

Add the IP address domain address manually; The primary function is to temporarily parse a domain name.

The format is: IP address domain name 192.168.1.111 www.baidu.com

[Email protected] ~]# ping Www.baidu.comPING www.baidu.com (192.168.1.111) (+) bytes of data.

A few points to note:

1) An IP can be followed by a number of domain names, spaces separated, can be dozens of or even hundreds of;

2) only one IP per line, that is, a domain name can not correspond to multiple IPs;

3) If there are multiple lines in the same domain name (IP is not the same) will be the first occurrence of the record to parse;



This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://8802265.blog.51cto.com/8792265/1635785

How to use network adapter configuration under Linux

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.