Centos6.2 setting up static IP and DNS

Source: Internet
Author: User

Refer to the following articles:
https://gist.github.com/fernandoaleman/2172388
http://www.lifelinux.com/how-to-configure-static-ip-address-on-centos/
http://www.ehowstuff.com/how-to-configure-static-ip-address-on-centos-6-2-linux-server/
Http://www.liurongxing.com/centos-dns-ifcfg-resolv.html
http://bbs.csdn.net/topics/390162805
Http://www.cnblogs.com/shawnloong/archive/2011/11/23/2260757.html

1) at the beginning of the system is DHCP automatically obtain IP, look at the system's IP, similar to the following: (This step is more critical to find the corresponding network devices and configuration files)
[Email protected]_aaa ~]# ifconfig
Eth6 Link encap:ethernet HWaddr 08:00:27:c1:e4:3d
inet addr:192.168.0.103 bcast:192.168.0.255 mask:255.255.255.0
Inet6 ADDR:FE80::A00:27FF:FEC1:E43D/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:108 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12689 (12.3 KiB) TX bytes:5908 (5.7 KiB)
Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up LOOPBACK RUNNING mtu:16436 metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)

2) Modify the corresponding/etc/sysconfig/network-scripts/ifcfg-eth6, but my following file does not exist, so directly create this file, the contents of the file is modified as follows:
Device=eth6
Hwaddr= "08:00:27:c1:e4:3d"
Nm_controlled=yes
Onboot=yes
Type=ethernet
ipaddr=192.168.0.120
Bootpro=static
netmask=255.255.255.0
dns1=192.168.0.1
Networking_ipv6=no
Ipv6init=no
Ipv6_autoconf=no
gateway=192.168.0.1

3) Modify the/etc/sysconfig/network file as follows:
Networking=yes
Networking_ipv6=no
Ipv6init=no
Hostname=centos_aaa
gatway=192.168.0.1

4) Restart Service network restart

5) Restart the system shutdown-r now

6) View the new Ip:ipconfig

7) But this time to find the problem, you can access the intranet, but not access to the external network.
It seems that configuring DNS in/etc/resolv.conf does not work, open the prompt as follows:
# Generated by NetworkManager
# No nameservers found; Try putting DNS servers into your
# ifcfg files in/etc/sysconfig/network-scripts like so:
#
# dns1=xxx.xxx.xxx.xxx
# dns2=xxx.xxx.xxx.xxx
# domain=lab.foo.com Bar.foo.com
Check the data that the DNS configuration must be added to/etc/sysconfig/network-scripts/ifcfg-eth6, increase dns1=192.168.0.1.
But this time or not, the last data is missing the default routing settings, need to add the following file/etc/sysconfig/network-scripts/route-eth6, the content is: via 192.168.0.1.
Then you can restart the network.



8) The/etc/hosts file is set up as follows: But it should be not related to IP and DNS configuration issues.
27.0.0.1 localhost.localdomain localhost
192.168.0.120 centos_aaa CENTOS_AAA
:: 1 localhost6.localdomain6 Localhost6

9) However, it is found that the static IP does not work after the shutdown restart, because the network service is not set to auto-random startup and is modified as follows:
Need to start Network service:
[[Email protected]_aaa ~]# chkconfig Network on
[Email protected]_aaa ~]# chkconfig--list | Less
Network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

10) After restarting the machine only IPv6, no IPv4, need to manually perform service network start to enter a fixed IP4 state. How to solve this problem??? (originally because network and networkmanager two services conflict)
First stop IPv6, add in the last/etc/sysctl.conf:
Net.ipv6.conf.all.disable_ipv6 = 1
Net.ipv6.conf.default.disable_ipv6 = 1
Then stop the NetworkManager service:
Chkconfig--level123456 NetworkManager off
Personally feel that in order to avoid the two service similar function conflict, NetworkManager should not be a service, only should be to the network service of an upper layer of packaging.

Centos6.2 setting up static IP and DNS

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.