Linux (with CentOS as an example) Network configuration considerations

  

First time when the basic network configuration is

1. Check the network mac address first

[root@centos ~] # cat /etc/udev/rules.d/70-persistent-net.rules

2. Modify hostname

[root@centos ~]# vim /etc/sysconfig/network< Br>

Open the file, modify the following and save

NETWORKING=yes #Use the network

NETWORKING_IPV6=yes #Use the network to not write

HOSTNAME=centos #Set Host Name

3.Modify Network Card

[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0 # Correspondence A network card

TYPE=Ethernet

ONBOOT=yes #Run at startup

NM_CONTROLLED=yes

BOOTPROTO=static #Use static IP, and IP is not assigned by DHCP

DEFROUTE=yes

HWADDR=00:50:56:94:04:3C # Must correspond to the MAC address of etho (/etc/udev/rules.d/70-persistent-net.rules)

PEERDNS=yes # The dns obtained from DHCP overwrites the local DNS

PEERROUTES=yes

IPADDR=192.168.0.100 #Specify the local IP address

NETMASK=255.255.255.0 #Specify the child Netmask

GATEWAY=192.168.0.1 #Specify gateway

IPV6INIT=no# indicates that IPV6 is not supported

4.Modify DNS

[root@ Centos ~]# vim /etc/resolv.conf

Open the file, modify the following and save

nameserver 202.106.195.68 #Specify the nearest DNS server in the current city (the cities are different, online Search)

nameserver 202.106.46.151

nameserver 192.168.0.1 #Specify the DNS server specified on the router

5. Restart the network configuration

[ ,null,null,3],Root@centos ~]#service network restart

6.Test whether to connect to the external network

ping gateway

ping www.bicner.com

The above is A piece of content that you can find from the Internet, this is easy to find on the Internet

The following is the most important note.

1. Check if the network cable is plugged in

The server is sometimes so wonderful, obviously the light of the network cable interface is bright, but in fact it is not good, don't ask me how to know, in the ratio The data center where the factory sounds are big, standing for a few hours, I won’t say it out.

[root@RedHat ~]# ethtool eth0

Look at Link detected: yes This line, if yes, it means the network cable is connected. If it is no, it is not connected to the network cable. You can also see the Speed ​​line. If it is Unknown, the network cable is not plugged in. If it is 1000Mb/s, the network cable is plugged in.

Ifconfig can also be viewed. If there is no RUNNING, it means the network cable is not connected.


2. NIC interface is closed and activated

[root@RedHat ~]# ifdown eth0 #关闭网络

[root@RedHat ~]# ifup eth0 #Start Network

Copyright © Windows knowledge All Rights Reserved