cenos modify ip address Comments Centos modify the IP address, gateway, DNS

Centos modify the IP address, gateway, DNS

 

A, CentOS change the IP address

 

Modify the configuration file corresponding to the IP address of the network card

# Vi / etc / sysconfig / network-scripts / ifcfg-eth0 Telecommunications

# Vi / etc / sysconfig / network-scripts / ifcfg-eth0: 1 Netcom

 

Modify the following

DEVICE = eth0 # corresponding to the description of the card device alias, e.g. ifcfg-eth0 file it as eth0

Way BOOTPROTO = static # set ip address of the network card, possible options for the static, dhcp or bootp, corresponding to the specified static ip address, obtained by ip address dhcp protocol, obtained by ip address bootp protocol

BROADCAST = 192.168.0.255 # corresponding to the subnet broadcast address

HWADDR = 00: 07: E9: 05: E8: B4 # corresponding physical address of the network card

IPADDR = 12.168.1.2 # If you set the card to get a static ip address ways to specify this field to specify the ip address of the corresponding network card

IPV6INIT=no

IPV6_AUTOCONF=no

NETMASK = 255.255.255.0 # card corresponding netmask

NETWORK = 192.168.1.0 # card corresponding network addresses

ONBOOT = yes # When the system is set up this network interface startup, set to yes, this device is activated when the system starts

 

Two, CentOS modify gateway

Gateway changes the corresponding network card configuration file

[root@centos]# vi /etc/sysconfig/network

 

Modify the following

NETWORKING = yes (indicate whether the system is using the network, usually set to yes. If set to no, you can not use the network, and many system services will not start)

HOSTNAME = centos (set the host name of the machine, where the host names provided and / etc / hosts in the host name corresponding to the set)

GATEWAY = 192.168.1.1 (gateway is provided connected to the machine's IP address. For example, gateway 10.0.0.2)

 

Three, CentOS modify DNS

Modify the corresponding network card DNS configuration files

# Vi /etc/resolv.conf

Modify the following

nameserver 8.8.8.8 #google domain name server

nameserver 8.8.4.4 #google domain name server

 

Fourth, restart the network configuration

# service network restart

or

# /etc/init.d/network restart

 

Modify the IP address

With immediate effect:

# ifconfig eth0 192.168.0.2 netmask 255.255.255.0

Start to take effect:

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

 

Modify Gateway Default Gateway

With immediate effect:

# route add default gw 192.168.0.1 dev eth0

Start to take effect:

Modify / etc / sysconfig / network

 

Modify DNS

Modify /etc/resolv.conf

After the modification can take effect immediately, starting as effective

 

Modify the host name

With immediate effect:

# hostname centos1

Start to take effect:

Modify / etc / sysconfig / network

Original Address: https://www.cnblogs.com/programer-xinmu78/p/10022949.html

A, CentOS change the IP address

 

Modify the configuration file corresponding to the IP address of the network card

# Vi / etc / sysconfig / network-scripts / ifcfg-eth0 Telecommunications

# Vi / etc / sysconfig / network-scripts / ifcfg-eth0: 1 Netcom

 

Modify the following

DEVICE = eth0 # corresponding to the description of the card device alias, e.g. ifcfg-eth0 file it as eth0

Way BOOTPROTO = static # set ip address of the network card, possible options for the static, dhcp or bootp, corresponding to the specified static ip address, obtained by ip address dhcp protocol, obtained by ip address bootp protocol

BROADCAST = 192.168.0.255 # corresponding to the subnet broadcast address

HWADDR = 00: 07: E9: 05: E8: B4 # corresponding physical address of the network card

IPADDR = 12.168.1.2 # If you set the card to get a static ip address ways to specify this field to specify the ip address of the corresponding network card

IPV6INIT=no

IPV6_AUTOCONF=no

NETMASK = 255.255.255.0 # card corresponding netmask

NETWORK = 192.168.1.0 # card corresponding network addresses

ONBOOT = yes # When the system is set up this network interface startup, set to yes, this device is activated when the system starts

 

Two, CentOS modify gateway

Gateway changes the corresponding network card configuration file

[root@centos]# vi /etc/sysconfig/network

 

Modify the following

NETWORKING = yes (indicate whether the system is using the network, usually set to yes. If set to no, you can not use the network, and many system services will not start)

HOSTNAME = centos (set the host name of the machine, where the host names provided and / etc / hosts in the host name corresponding to the set)

GATEWAY = 192.168.1.1 (gateway is provided connected to the machine's IP address. For example, gateway 10.0.0.2)

 

Three, CentOS modify DNS

Modify the corresponding network card DNS configuration files

# Vi /etc/resolv.conf

Modify the following

nameserver 8.8.8.8 #google domain name server

nameserver 8.8.4.4 #google domain name server

 

Fourth, restart the network configuration

# service network restart

or

# /etc/init.d/network restart

 

Modify the IP address

With immediate effect:

# ifconfig eth0 192.168.0.2 netmask 255.255.255.0

Start to take effect:

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

 

Modify Gateway Default Gateway

With immediate effect:

# route add default gw 192.168.0.1 dev eth0

Start to take effect:

Modify / etc / sysconfig / network

 

Modify DNS

Modify /etc/resolv.conf

After the modification can take effect immediately, starting as effective

 

Modify the host name

With immediate effect:

# hostname centos1

Start to take effect:

Modify / etc / sysconfig / network

Original Address: https://www.cnblogs.com/programer-xinmu78/p/10022949.html

Guess you like

Origin www.cnblogs.com/lovetl/p/12059395.html