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

centriohost: Virtual hosting for $3 per year, Globalsign Wildcard SSL for $5

centriohost, founded in 2008, now has Black Frida...

Baidu Cloud: 88 yuan/year/1GB memory/40GB space/1Mbps/KVM/domestic

Baidu Cloud, owned by Baidu, offers VPS prices lo...

Baota Linux Panel: Released Version 5.8

Previous introduction: VPS, independent server gr...

Dediserve: €8.97/month/2GB RAM/30GB SSD space/1.5TB bandwidth/KVM/Chicago

Dediserve has many data centers, among which the ...