Linux NIC configuration
First, view network card information
1, ifconfig: Check the IP information of the network card
2, the network card configuration file:
/etc/sysconfig/network-scripts/ifcfg-eth0
Eth0: Represents the name of a network card, if there are multiple nets, there will be eth1, eth2 and so on. It's all in the/etc/sysconfig/network-scripts/directory.
3. Restart a single NIC command
Ifdown eth0: Shut down the eth0 NIC separately
Ifup eth0: Start the eth0 NIC separately
4, if the remote login to the service, as far as possible, service network Restar or/etc/init.d/network Restar to restart the network services, so as not to shut down a single network card, there is no way to restart the network card in the link
Two, to a network card set multiple IP address
1. Enter the/etc/sysconfig/network-scripts/directory
[Email protected] ~]# cd/etc/sysconfig/network-scripts/
2, copy/etc/sysconfig/network-scripts under the current directory Ifcfg-eth0, and renamed to Eth0:1
[email protected] network-scripts]# CP Ifcfg-eth0 ifcfg-eth0\:1
\: Indicates a caret
3. Edit the Ifcfg-eth0:1 configuration file
[Email protected] network-scripts]# vim ifcfg-eth0:1
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/57/wKioL1V5pauz7l4EAAJBiMqIDi8844.jpg "title=" 111111.png "alt=" Wkiol1v5pauz7l4eaajbimqidi8844.jpg "/>
Wq Save exit, restart NIC
[Email protected] network-scripts]# ifdown eth0 && ifup eth0
4, in the use of Ifconfig view eth0 network card, you will see a 192.168.20.98 IP address more
[[Email protected] network-scripts]# ifconfig eth0 link encap:Ethernet HWaddr 00:0C:29:AE:45:DA inet addr:192.168.21.98 bcast:192.168.21.255 mask : 255.255.255.0 inet6 addr: fe80::20c:29ff : Feae:45da/64 scope:link up broadcast RUNNING MULTICAST MTU:1500 Metric:1 RX packets:56068 errors:0 dropped:0 overruns:0 frame:0 TX packets:21286 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:27489174 (26.2 MIB) tx bytes :2283396 (2.1 MIB) eth0:1 link encap:ethernet hwaddr 00:0c:29:ae:45:da inet addr :192.168.20.98 bcast:192.168.20.255 mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 metric:1lo 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:65536 Metric:1 RX packets:9 errors:0 dropped:0 overruns:0 frame:0 tx packets:9 errors:0 Dropped:0 overruns:0 carrier:0 collisions :0 txqueuelen:0 rx bytes:612 ( 612.0 B) TX bytes:612 (612.0 b)
Third, Mii-tool view NIC connection status
[Email protected] network-scripts]# mii-tool eth0 eth0:negotiated 100basetx-fd, link ok
Just see "link OK" to indicate that the network card is connected status, if the "no link" indicates that the NIC is broken or not connected to the network cable.
Iv. Changing the host name
1. Check the hostname: [[email protected] ~]# hostname
2, temporary change: [[email protected] ~]# hostname linux6 after restart failure
3. After reboot, you need to modify the hostname in the following configuration file
[Email protected] ~]# cat/etc/sysconfig/network
Networking=yes
Hostname=linux2
Five, DNS settings
1. DNS configuration file:/etc/resolv.conf
[Email protected] network-scripts]# cat/etc/resolv.conf; Generated by/sbin/dhclient-script nameserver 192.168.21.254 nameserver 222.88.88.88
It should be noted that resolv.conf has its inherent format, must be written as "nameserver IP" format, the above line with '; ' line is a line of comments, there is no practical meaning, it is recommended to write two or more namserver, By default, the first namserver is used to resolve the domain name, and the second is used when the first one is not resolved.
2, under the Linux has a special file/etc/hosts can also resolve the domain name, but we need to manually add the ip+ domain name in the content, its role is to temporarily resolve a domain name, very useful
[Email protected] network-scripts]# vim/etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.21.200 www.gu hantai.cn #这是我临时添加了一个域名
3, now use ping command to pingwww.guhantai.cn see if can resolve to 192.168.21.200
[Email protected] network-scripts]# ping Www.guhantai.cnPING www.guhantai.cn (192.168.21.200) (+) bytes of data.
4, need to note that each line as a record, divided into two parts, the first part is IP, the second part is the domain name. It is important to note that:
A, one IP can be followed by multiple domain names
B, each line can have only one IP, that is, a domain name can not be multiple IP
C, if there are multiple lines in the same domain name (the previous IP is not the same), will be the first occurrence of the record to resolve
This article is from the It Exchange Learning blog, so be sure to keep this source http://sxct168.blog.51cto.com/824373/1661057
Configuring multiple IP addresses for linux network adapters