1. view the network MAC address
[[email protected] ~]# cat /etc/udev/rules.d/70-persistent-net.rules
The following information is displayed:
# PCI device 0x15ad:0x07b0 (vmxnet3) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:94:04:3c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x15ad:0x07b0 (vmxnet3) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:94:53:24", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Eth0: corresponds to the first Nic, and eth1: The second Nic. Currently, eth0 is used to connect to the vro, and eth1 is retained (the server is generally used to connect to other hosts)
2. Modify host name
[[email protected] ~]# vim /etc/sysconfig/network
Open the file, modify the following content, and save
Networking = yes # Use Network hostname = centos # Set Host Name
3. Modify the NIC
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
Open the file, modify the following content, and save
Device = eth0 # corresponding to the first Nic type = Ethernet onboot = yes # whether to run nm_controlled = Yes bootproto = static # use a static IP address, instead of assigning IP defroute = Yes ipv4_failure_fatal = Yes ipv6init = no name = "system eth0" # name hwaddr = 00: 50: 56: 94: 04: 3C # It must correspond to the MAC address (/etc/udev/Rules) of etho. d/70-persistent-net.rules) peerdns = Yes peerroutes = Yes ipaddr = 192.168.2.249 # specify the local IP address netmask = 255.255.255.0 # specify the subnet mask gateway = 192.168.2.1 # specify the Gateway
4. Modify DNS
[r[email protected] ~]# vim /etc/resolv.conf
Open the file, modify the following content, and save
Nameserver 8.8.8.8 # Google's DNS server nameserver 61.144.56.100 # specify the nearest DNS server in the current city (different cities, online search) nameserver 192.168.2.1 # specify the DNS server specified on the router
5. Restart Network Configuration
[[email protected] ~]#service network restart
6. Restart
[[email protected] ~]#shutdown -r now
7. view the current IP settings
[[email protected] ~]# ifconfig
8. Test whether to connect to the Internet
[[email protected] ~]# ping www.baidu.com
Note: Do not write wrong letters, ipaddr, or ipadr gateway. Do not write fewer hosts...
Centos Nic Configuration