Standalone server, under CentOS system, modify DNS and gateway

Standalone server, under CentOS system, modify DNS and gateway

For some independent servers, the system is not configured properly, resulting in network problems. Generally, it will be normal after modifying the DNS and gateway. The host provider will generally send you this information.

1. CentOS modify DNS
Modify the DNS configuration file corresponding to the network card

 vi /etc/resolv.conf

Modify the following content

 nameserver 8.8.8.8 nameserver 8.8.4.4

2. CentOS modifies the gateway <br />Modify the configuration file of the gateway corresponding to the network card

 vi /etc/sysconfig/network

Modify the following content

 NETWORKING=yes(表示系統是否使用網絡,一般設置為yes。如果設為no,則不能使用網絡,而且很多系統服務程序將無法啟動) HOSTNAME=centos(設置本機的主機名,這里設置的主機名要和/etc/hosts中設置的主機名對應) GATEWAY=192.168.1.1(設置本機連接的網關的IP地址。例如,網關為10.0.0.2)

3. CentOS changes IP address <br />Modify the configuration file of the IP address corresponding to the network card

 vi /etc/sysconfig/network-scripts/ifcfg-eth0

Modify the following content

 DEVICE=eth0 #描述網卡對應的設備別名,例如ifcfg-eth0的文件中它為eth0 BOOTPROTO=static #設置網卡獲得ip地址的方式,可能的選項為static,dhcp或bootp,分別對應靜態指定的ip地址,通過dhcp協議獲得的ip地址,通過bootp協議獲得的ip地址BROADCAST=192.168.0.255 #對應的子網廣播地址HWADDR=00:07:E9:05:E8:B4 #對應的網卡物理地址IPADDR=12.168.1.2 #如果設置網卡獲得ip地址的方式為靜態指定,此字段就指定了網卡對應的ip地址IPV6INIT=no IPV6_AUTOCONF=no NETMASK=255.255.255.0 #網卡對應的網絡掩碼NETWORK=192.168.1.0 #網卡對應的網絡地址ONBOOT=yes #系統啟動時是否設置此網絡接口,設置為yes時,系統啟動時激活此設備

4. Restart network configuration

 service network restart

or

 /etc/init.d/network restart

5. Modify IP address <br />Effective immediately:

 ifconfig eth0 192.168.0.2 netmask 255.255.255.0

Start to take effect:

修改/etc/sysconfig/network-scripts/ifcfg-eth0

6. Modify the Default Gateway
Effective immediately:

 route add default gw 192.168.0.1 dev eth0

Start to take effect:

修改/etc/sysconfig/network

Modify DNS
Modify /etc/resolv.conf
The modification will take effect immediately and the startup will also be effective
7. Modify host name
Effective immediately:

 hostname centos1

Start to take effect:

 /etc/sysconfig/network

8. Manually change centos to static IP
(1) I searched for it first and got the following explanation:
IP IP address
Netmark Subnet Mask
Gateway Default Gateway
HostName Host name
DomainName domain name
DNS DNS IP
(2) Files that need to be modified often include
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
/etc/hosts

<<:  Rebel Hosting i3-540 16GB RAM Dedicated Server Review

>>:  HostDeez: $11/month/8GB RAM/80GB SSD space/5TB bandwidth/KVM/Germany

Recommend

Coreston: $49/month/2x L5520/16GB memory/1TB hard drive/10TB traffic/Dallas

Coreston, a US hosting provider, provides vps and...

SkilledNerd: $59.99/month/8GB memory/500GB space/15TB traffic/16 IP

SkilledNerd, an American hosting provider, was fo...

ixwebhosting dedicated IP and shared IP switching

As the threshold for building a website in China ...

Blog navigation submission and collection dedicated page

1 Chinese independent blog navigation site has be...

The impact of templates on click-through rate

Recently I have been testing the impact of templa...

Hostease Alipay RMB purchase tutorial diagram

Now most of the space has been transferred to for...

SSD VPS: $48/year/1GB RAM/30GB storage/2000G traffic/OpenVZ

Introduction SSD VPS is an American hosting compa...

AltusHost: .com domain registration or transfer, both for 4.95 Euros

AltusHost is a European hosting provider with a r...

Serve By Design: $15/year/128MB/10GB space/250GB traffic/OpenVZ

Serve By Design is an American hosting company fo...

HostMyBytes: $5/year/40GB space 3TB traffic/unlimited sub-accounts/Los Angeles

HostMyBytes, its previous special VPS was very po...

holderhost:$30/year/512MB RAM/30GB storage/2048GB bandwidth/OpenVZ

Holderhost is an American hosting company founded...