CentOS Network Configuration Example
1. Configure DNS
Vi/etc/resolv.conf
Join:
Copy CodeThe code is as follows:
nameserver 192.168.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
2. Configure the Gateway:
Vi/etc/sysconfig/network
Join:
gateway=192.168.0.1
Complete the following:
Copy CodeThe code is as follows:
Networking=yes
Hostname=localhost.localdomain
gateway=192.168.0.1
3, configure the IP address:
Vi/etc/sysconfig/network-scripts/ifcfg-eth0
The contents are as follows:
Copy CodeThe code is as follows:
device= "Eth0"
hwaddr= "00:0c:29:6c:bb:e6"
nm_controlled= "Yes"
onboot= "No"
netmask=255.255.255.0
ipaddr=192.168.0.8
gateway=192.168.0.1
bootproto=static
Onboot=yes
Peerdns=yes
4, restart the service:
Copy CodeThe code is as follows:
/etc/init.d/network Restart
or use the command:
Service Network Restart
or:
ifdown eth0 and ifup eth0
After the configuration is complete, ping the gateway to see if it can ping or check the actual configured IP address with ifconfig eth0.
DNS, gateways, IP addresses, mostly configuration Resolv.conf\network\ifcfg-eth0