1. centos DNS server Modification
Modify the following content
1 |
nameserver 8.8.8.8 # Google Domain Name Server |
2 |
nameserver 8.8.4.4 # Google Domain Name Server |
2. centos gateway Modification
Modify the gateway configuration file of the corresponding Nic
1 |
[root@centos] # vi /etc/sysconfig/network |
Modify the following content
1 |
NETWORKING= yes # (Indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started) |
2 |
HOSTNAME=centos # (Set the Host Name of the local machine. The host name set here must correspond to the host name set in/etc/hosts) |
3 |
GATEWAY=192.168.1.1 # (Set the IP address of the gateway connected to the local machine. For example, the gateway is 10.0.0.2) |
3. Modify the IP address of centos
Modify the configuration file of the corresponding Nic IP Address
1 |
[root@centos] # vi /etc/sysconfig/network-scripts/ifcfg-eth0 |
Modify the following content
01 |
DEVICE=eth0 # Describe the device alias corresponding to the NIC, for example, it is eth0 in the ifcfg-eth0 File |
02 |
BOOTPROTO=static # Set the way for the NIC to obtain the IP address. The possible options are static, DHCP or BOOTP, which correspond to the IP address specified by the static state, the IP address obtained through the DHCP protocol, and the IP address obtained through the BOOTP protocol. |
03 |
BROADCAST=192.168.0.255 # Corresponding subnet broadcast address |
04 |
HWADDR=00:07:E9:05:E8:B4 # The physical address of the corresponding Nic |
05 |
IPADDR=12.168.1.2 # If you set the method for obtaining the IP address from the NIC to static, this field specifies the IP address of the NIC. |
08 |
NETMASK=255.255.255.0 # Network mask corresponding to the NIC |
09 |
NETWORK=192.168.1.0 # Network address corresponding to the NIC |
10 |
ONBOOT= yes # Whether to set this network interface when the system starts. If it is set to yes, this device is activated when the system starts. |
4. Restart the network configuration.
1 |
[root@centos] # service network restart |
3 |
[root@centos] # /etc/init.d/network restart |
The modified IP address takes effect immediately:
1 |
[root@centos] # ifconfig eth0 192.168.0.2 netmask 255.255.255.0 |
Start effective:
[Root @ centos] #/etc/sysconfig/network-scripts/ifcfg-eth0
Changing the gateway's default gateway takes effect immediately:
1 |
[root@centos] # route add default gw 192.168.0.1 dev eth0 |
Start effective:
1 |
[root@centos] # /etc/sysconfig/network |
The modification takes effect immediately after DNS modification.
1 |
[root@centos] # /etc/resolv.conf |
Modification of host name takes effect immediately:
1 |
[root@centos] # hostname centos1 |
Start effective:
1 |
[root@centos] # /etc/sysconfig/network |
Manually change centos to a static IP Address
1. Search for the following explanation:
3 |
Gateway # Default Gateway |
5 |
DomainName # Domain Name |
2. files to be modified often have
2 |
/etc/sysconfig/network-scripts/ifcfg-eth0 |
Problems:
The 'connect: network is unreachable error' problem occurs. virtualbox uses the bridged adapter Method for connection.
By modifying the/etc/sysconfig/network-scripts/ifcfg-eth0, the IP address of the virtual machine is already network and netmask.
Ping the same network and netmask is found, so it is determined that it should be the routing configuration problem of the virtual machine operating system,
Try directly modifying the system file/etc/sysconfig/network-scripts/route-eth0 to add 'defult via 192.168.0.1 '(192.168.0.1 is the IP address of my vro and can be modified as needed ).
I ran to the/etc/sysconfig/network-scripts/directory and found that the root node didn't have the route-eth0 file, so I created a file and added 'defult via 192.168.0.1 'to the file.
Run '/etc/init. d/network restart' to restart the network. Everything is OK! It turns out that the problem lies in the routing.
In fact, I have used the route add command to configure routes, but it becomes invalid after being restarted.