Telnet to Linux host for replacement IP address

Source: Internet
Author: User
Tags file copy reserved ssh cloudstack

Problem Analysis:

According to the development team colleague, It is not possible to use advanced options for IP-specific operations by vcenter the RHEL6.0 of systems with the following version, which is not possible by assigning IP to a new instance by Cloudstack, and it is not possible to use a DHCP server to resolve the problem, or it will cause the new virtual machine IP address to Inconsistent, it can also cause confusion in the allocation of IP addresses throughout the system.
Solution Idea:

A fixed reserved IP address is specified for the RHEL6.0 of the following systems, such as 192.168.3.0/24 network segments, reserved 192.168.3.240~192.168.3.250 to such template systems.

Whether through the Vcenter clone virtual machine or Cloudstack new instance, as long as all the virtual machines that are started through the fixed IP address will successfully start with the original IP address, and normally communicate with other IP addresses in the network segment, you need to ensure that the same IP address template is not allowed to start at the same time.

The following is a template fixed IP: 10.196.18.250 system, in the control node, such as the Cloudstackmanagement node above/etc/hosts resolution:

10.196.18.250 vm250

1. Start vm250, through the detection mechanism to determine the success of its start-up, the program to 10.196.18.250 a simple connection test, ping pass.

2. In the process of starting the instance, the IP address information is also written to the local directory, and is saved in the following format:

Suppose the file name is: ifcfg-eth0.001, and the contents are 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 script file: changeip.sh, the script file accomplishes two tasks:

"1" will ifcfg-eth0. Id Copy to vmid specified directory, renamed to Ifcfg-eth0

"2" Through the Cloudstack management landing Vmid, restart network services, making the new network configuration file effective.

How to use:./changeip.sh id_of_ifcfg-eth0 ID_OF_VM

such as:./CHANGEIP.SH 001 250, will ifcfg-eth0.001 file copy paper vm250 system, and restart network services, so that the final IP address of the new instance is 10.196.28.208

Double-click the code to select all
1 2 3 4 5 6 7 8 9 10 11 The #!/bin/bash #description: Change ip  on Instances #Usage:./changeip.sh fileid vmId # flush of remote HO STS >~/.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 Boo T from vm_fixip  without interactive function scp_file () {expect-c "set Timeout-1 Spawn-noecho SCP $ 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  $ expect" passwor D: "Send" PASSWORDR "expect EOF"} res_net  root@vm$2 "service network restart >/dev/null 2>&1 &" SLE EP 2 Exit 0

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.