"Notes" centos7-linux-Configure IP addresses on the virtual machine __linux

Source: Internet
Author: User
Tags uuid

A recent deployment of Hadoop on VMware found no previous configuration issues related to Linux, and here's a note:

There are two ways to configure IP addresses under the command line:
1, dynamic configuration, and then reset the network card after the configuration failed restore to the default configuration address (that is, this way does not modify the NIC profile)
2, static configuration, as long as the configuration file is still in, the permanent entry into force.

The following are the configuration methods:
1, the dynamic configuration of IP

A. View the IP address of the machine: Ifconfig, eth or en (abbreviated Ethernet) to the beginning of the network card, usually eth0, representing the first network card, such as a number of ETH, such as: Etho, eth1, and so on, on behalf of two cards, and so on.


B. Here because I am using the virtual machine installed CentOS 7, the installation did not modify the network configuration, so the name of my virtual network card is: eno16777736


C. command line input ifconfig eno16777736 192.168.162.3 use the original default mask if you do not specify a subnet mask


D. Re-enter ifconfig will find that its network card address (IP address) has been set to 192.168.162.3 as follows, after naming the content:


[Root@localhost ~]# Ifconfig
Eno16777736:flags=4163<up,broadcast,running,multicast> MTU 1500
inet 192.168.162.3 netmask 255.255.255.0 broadcast 192.168.162.255
Inet6 fe80::20c:29ff:fe9d:881d Prefixlen ScopeID 0x20<link>
Ether 00:0c:29:9d:88:1d Txqueuelen 1000 (Ethernet)
RX packets 1380 Bytes 109783 (107.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets 857 bytes 526344 (514.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


Lo:flags=73<up,loopback,running> MTU 65536
inet 127.0.0.1 netmask 255.0.0.0
Inet6:: 1 prefixlen 128 ScopeID 0x10Loop Txqueuelen 0 (local loopback)
RX Packets Bytes 844 (844.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets Bytes 844 (844.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


Virbr0:flags=4099<up,broadcast,multicast> MTU 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
Ether 52:54:00:b5:5c:72 Txqueuelen 0 (Ethernet)
RX Packets 0 Bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets 0 Bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


E. IP dynamic configuration commands with masks and gateways:
A. Setting IP and Mask
Ifconfig eth-? IP-ADDR netmask netmask-addr such as:
Ifconfig eno16777736 192.168.162.3 netmask 255.255.255.0


B. Setting up a gateway
Route add default GW gateway-addr such as:
Route add default GW 192.168.162.1




2. Static Configuration IP, vi your corresponding network card configuration file, such as:
vi/etc/sysconfig/network-scripts/ifcfg-eno16777736


Open as follows:
Type= "Ethernet"
Bootproto= "DHCP"
Defroute= "Yes"
Peerdns= "Yes"
Peerroutes= "Yes"
Ipv4_failure_fatal= "No"
ipv6init= "Yes"
ipv6_autoconf= "Yes"
Ipv6_defroute= "Yes"
Ipv6_peerdns= "Yes"
Ipv6_peerroutes= "Yes"
Ipv6_failure_fatal= "No"
Name= "eno16777736"
Uuid= "4D5237A8-97D6-4703-A58D-177E47729CB1"
Device= "eno16777736"
onboot= "Yes"
~
-----------------------------------
Configuration reference:
bootproto= "Static" #dhcp改为static
onboot= "Yes" #开机启用本配置
ipaddr=192.168.7.106 #静态IP
gateway=192.168.7.1 #默认网关
netmask=255.255.255.0 #子网掩码
dns1=192.168.7.1 #DNS Configuration
----------------------------------


To do the following configuration, if not added, after the configuration is as follows:


Type= "Ethernet"
bootproto= "Static"
Defroute= "Yes"
Peerdns= "Yes"
Peerroutes= "Yes"
Ipv4_failure_fatal= "No"
ipv6init= "Yes"
ipv6_autoconf= "Yes"
Ipv6_defroute= "Yes"
Ipv6_peerdns= "Yes"
Ipv6_peerroutes= "Yes"
Ipv6_failure_fatal= "No"
Name= "eno16777736"
Uuid= "4D5237A8-97D6-4703-A58D-177E47729CB1"
Device= "eno16777736"
onboot= "Yes"
ipaddr=192.168.162.3
netmask=255.255.255.0



Configuration complete reboot machine (virtual machine) or Restart Network Service is effective, the command is: Service network restart






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.