• notice
  • Congratulations on the launch of the Sought Tech site

CentOS configure network access

Introductionvi /etc/sysconfig/network-scripts/ifcfg-eth0 # 1. ONBOOT=no is changed to ONBOOT=yes whether it starts with the system# 2. BOOTPROTO=dhcp is changed to BOOTPROTO=static IP address allocation method, which is automatically allocated by the DHCP server , or manually configure

First, edit the network card configuration file


1
2
3
4
vi /etc/sysconfig/network-scripts/ifcfg-eth0
 

# 1. Change ONBOOT=no to ONBOOT=yes whether to start with the system

# 2. BOOTPROTO=dhcp is modified to BOOTPROTO=static IP address allocation method, whether it is automatically allocated by the DHCP server or manually configured

Add after the content of the ifcfg-eth0 file

1
2
3
4
5
6

IPADDR=192.168.1.160 << IP

NETMASK=255.255.255.0 << subnet mask

GATEWAY=192.168.1.1 << gateway

DNS1=202.96.134.133

DNS2=202.96.128.68

The DNS configuration is added according to the local network provider. I am here in Shenzhen, and I use the DNS of Shenzhen Telecom

After adding, exit and save

1113.png


2. Restart the network service


1
service network restart

111.png


3. DNS can also be configured in other files


1
2
3
4
5
6
vi /etc/resolv.conf
# join in
  nameserver 202.96.134.133
  nameserver 202.96.128.68
   
# Exit save, restart network service  service network restart

Note: Actually /etc/resolv.conf is the DNS configuration information of the network card configuration file before it is automatically called 


Fourth, test whether the network is connected

1
ping www.baidu.com

1112.png




Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+