In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to remotely log in to the linux host and change the IP address". The content in the article is simple and clear, and it is easy to learn and understand. please follow the editor's train of thought to study and learn "how to remotely log in to the linux host and change the IP address".
Problem analysis:
According to the response of colleagues in the development team, when cloning a system below RHEL6.0 through VCenter, the advanced option cannot be used to specify IP, so it is impossible to specify IP to the new instance through CloudStack. Moreover, the problem cannot be solved by using DHCP server, otherwise it will lead to inconsistency between the new virtual machine IP address and the specified IP, and may also lead to confusion in the allocation of IP addresses in the whole system.
The solution is as follows:
All templates made by the following RHEL6.0 systems are assigned a fixed reserved IP address, for example, in the 192.168.3.0ax 24 network segment, 192.168.3.240192.168.3.250 is reserved for such a template system.
Whether you clone a virtual machine through VCenter or create a new instance with CloudStack, as long as all virtual machines started with the fixed IP address will successfully start with the original IP address and communicate normally with other IP addresses in the network segment, you need to ensure that templates with the same IP address are not allowed to start at the same time.
The following system with template fixed IP: 10.196.18.250 is parsed in the control node, such as the cloudstackmanagement node / etc/hosts:
10.196.18.250 vm250
1. Start vm250, through the detection mechanism to judge its success, the program to 10.196.18.250 for a simple connection test, ping can be passed.
two。 During the process of starting the instance, write the IP address information to the local directory and save it in the following format:
Suppose the file name is: ifcfg-eth0.001 and the content is as follows
DEVICE=eth0
ONBOOT=on
BOOTPROTO=static
IPADDR=10.196.28.208
NETMASK=255.255.255.0
GATEWAY=10.196.28.254
3. Invoke the script file: ChangeIP.sh, which accomplishes two tasks:
[1] copy ifcfg-eth0.Id to the directory specified by vmId and rename it to ifcfg-eth0
[2] Log in to vmId through cloudstack management, restart the network service, and make the new network configuration file effective.
Usage:. / ChangeIP.sh id_of_ifcfg-eth0 id_of_vm
For example:. / ChangeIP.sh 001 250, copy the ifcfg-eth0.001 file into the paper vm250 system and restart the network service so that the final IP address of the new instance is 10.196.28.208
The code is as follows:
#! / bin/bash
# description: change ip on instances
# Usage:. / ChangeIP.sh fileId vmId
# flush the caches of remote hosts
> ~ / .ssh/known_hosts
# define the network configfile location
Dist=/etc/sysconfig/network-scripts/ifcfg-eth0
# define a function which copy the new ifcfg-eth0 file
# from cloudstack management or from other host to new
# instance boot from vm_fixip without interactive
Function scp_file () {
Expect-c "
Set timeout-1
Spawn-noecho scp $1 $2
Expect "yes/no"
Send "yesr"
Expect "password:"
Send "passwordr"
Expect eof
"
}
Scp_file ifcfg-eth0.$1 root@vm$2:$dist
# this function named res_new means restart network
# on new instance loading from new network config file
# without interactive
Function res_net () {
Expect-c "
Set timeout-1
Spawn-noecho ssh $1 $2
Expect "password:"
Send "passwordr"
Expect eof
"
}
Res_net root@vm$2 "service network restart > / dev/null 2 > & 1 &"
Sleep 2
Exit 0
Thank you for your reading, the above is the content of "how to remotely log in to the linux host and change the IP address". After the study of this article, I believe you have a deeper understanding of how to remotely log in to the linux host and change the IP address, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 298
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.