How to modify network settings such as IP address DNS server in centos 5.5

Source: Internet
Author: User
Tags nameserver

1. centos DNS server Modification

1 vi /etc/resolv.conf

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.
06 IPV6INIT=no
07 IPV6_AUTOCONF=no
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
2 # Or
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:

1 IP         # IP Address
2 Netmark    # Subnet Mask
3 Gateway    # Default Gateway
4 HostName   # Host Name
5 DomainName # Domain Name
6 DNS        # Dns ip Address

2. files to be modified often have

1 /etc/sysconfig/network
2 /etc/sysconfig/network-scripts/ifcfg-eth0
3 /etc/resolv.conf
4 /etc/hosts

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.