Configuring static IP addresses in Linux

Source: Internet
Author: User

Just installed CentOS, the default configuration is dynamic IP, if the virtual machine restarted (although not often), the IP address switched, and then use the Remote tool connection to re-change the address, laborious.

Today, a static address is set and recorded.

Environment: VMware 10.0.0 + CentOS 6

First, set up VMware's network settings

    • Edit > virtual Network Editor
      • VMnet8 > Nat Mode (IP address of shared host with virtual machine)
        • Select "Nat Settings" and remember "Gateway IP" (set to use later)
      • Uncheck the "Use local DHCP service to assign IP addresses to virtual machines" check box
    • Right-click installed systems > Settings > Network adapters > select NAT Mode
      • By the way, click "Advanced", note the MAC address (set to use later)

Modifying a Linux configuration file

As the following configuration file needs to be modified, modify the information after the file for the example below, it is recommended to pre-modify the backup:

    • /etc/sysconfig/network
    • /etc/sysconfig/network-scripts/ifcfg-eth0
    • /etc/resolv.conf

This case hypothesis data:

    • Gateway ip:192.168.116.2
    • The static ip:192.168.116.130 to be set
    • MAC Address: XX:XX:XX:XX:XX:XX

networking=yeshostname=localhost.localdomaingateway=192.168.116.2
/etc/sysconfig/network

Device= "eth0"# Bootproto= "DHCP"bootprote= "Static"ipaddr=192.168.116.130 NETMASK =255.255.255.0HWADDR= "XX:XX:XX:XX:XX:XX"ipv6init= "No"nm_controlled= "Yes"  Onboot= "Yes"TYPE= "Ethernet"UUID= "948bedc9-f08f-49cd-8c06-4a7a9fcd2e4e"DNS1= 192.168.116.2
/etc/sysconfig/network-scripts/ifcfg-eth0

192.168.116.2
/etc/resolv.conf

Restart Network after modification

Service Network restart
View Code

Test

The last ping is successful.

Configuring static IP addresses in Linux

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.