Allocating EIP(Elastic IP Address) To EC2 Instance & Releasing EIP From EC2 Instance – #SmartCherrysTech

Allocating EIP(Elastic IP Address) To EC2 Instance & Releasing EIP From EC2 Instance – Here We Will Know How To Allocate EIP(Elastic IP Address) To EC2 Instance & Release EIP From EC2 Instance.

We Have Public & Private IP Addresses

  • So AWS Support Both IPv4 And IPv6
  • By Default Your Instance Will Get One Public IP & One Private IP Address
  • By Default Public IP It Is Dynamic IP Address In Nature
  • Its Not A Static IP Address
  • Let Say See The Your Public IP & Private IP Address On Your Ec2 Dashboard- Details Section
  • So The Public IP Address To The Instance Is Dynamic IP Address.
  • What Is The Meaning Of Dynamic Public IP Address?
  • If You Restart The Machine, If You Stop The Machine, If You Reboot The Machine
  • There May Be Chances To Change In This IP Address
  • Practically, You Have This Public IP Address?
  • Try To Copy & Paste Your Machines Public & Private IP Address Somewhere.
  • If You Stop & Restart The Machine, The Public IP Address Will Change.
  • Public IP Address Is Dynamic IP Address.
  • If You Terminate Your Machine, Is The Respective Key Pair Will Be Deleted?
  • No, The Key Pair Will Not Be Deleted.
  • It Will Remain With You And As Well As AWS Platform.
  • If You Want To Use The Same Key Again You Can Use The Same Key Again.
  • But The Machine Is Deleted, The Machine Is Terminated.
  • Key Will Remain In Your Account.
  • Public IP Address Will Change If You Restart The Machine But The Private IP Address Will Remain Same.
  • Because You Are Getting Private Address From VPC, From Your Internal Network.
  • So Its Private IP Address
  • And Private IP Addresses Are Not Accessible Over The Internet.
  • You Can Reach Your Machine Only Using Public IP Address.
  • Every Time You Restart Machine, Every Time You Get New IP Address.
  • If You Provide An Static IP Address To Machine, Do We Have Any Option?
  • Because Every time You Find IP Addresses Being Changed, So How You Can Manage Your DNS Record Entry?
  • You Need Static IP Address In Some Cases.
  • So We Have An Option For That, That Is Elastic IP Address
  • Its EIP(Elastic IP Address)
  • If You Are Using Elastic IP Address, It Provides Static IP Address To Your Instance.
  • Or Your Network Interface To Your Load Balancer Or To Container(Docker Container)
  • EIP Is Not Free Of Cost,
  • In Free AWS Account, You’ll Get Only One EIP Free
  • Maximum 5 EIP Per Region You Can Take.
  • This Is Kind Of Quota If You Talk With AWS Support Team.
  • But By Default Upto 5 EIP You Can Allocate.

 

How To Take And How To Map With EC2 Instance?

  1. Allocate An EIP to Your AWS Account.
  2. Associate The EIP with EC2 Instance, You Can Associate With Any Resource, If You Are Using Container, You Can Associate With Container Or Network Interface Etc.
  3. Then The Job Is Done.

 

If You Deleted The EC2 Instance, Then Your EIP Will Fail.

Then How You Can Release This EIP? Because It Is The Static IP Address.

The Process To Release The EIP –

  1. Disassociate The EIP From The Machine.
  2. Once It Is Disassociated, The You’ll Release The EIP To Avoid The Charges From AWS.

By Default You’ll Public And Private IP Addresses To Your Machine When It Is Created But When You Want To Provide The Static IP Address Then You Have To Put Some Efforts.

 

Allocating EIP To The EC2 Instance

Go To EC2 Dashboard

When You See Instance Summary Below Your Instance.

You’ll See The EIP Section Is Blank, It Means You Do Not Have Any Static IP Address To Your Machine.

Or Fixed IP Address To Your Machine.

You Machine Is Running, Left Hand Side You Can See, You Scroll Down, You Just Navigate The Left Side Pan.

You’ll See Elastic IP Option, Under Network & Security.

You Click On It.

Just Click On Allocate EIP.

First Of All You’ll Allocate An EIP.

And Choose In Which Region You Want To Allocate The EIP.

So That Is The Code Of Your Region Under Elastic IP Address Settings.

us-east-1

You Are Taking This EIP From From Amazon’s Pool Of IPv4 IP Addresses.

Means You Are Purchasing This EIP, Static IP Address, Fix IP Address From Amazon’s Pool.

In Some Cases Company Says ‘NO We Do Not Want To Purchase, We Already Have The EIP In Bulk, We Already Purchased From ISP.

So What Should You Do?

In That Case First Of All You Have To Map Those IP’s With The AWS Account And Later On Those IP Addresses Can Be Used With Your EC2 Instances Or Other Resources, In That Case You Wont Pay Any Money To AWS For Those EIP’s.

But Here In This Case You Are Purchasing, Im Just Getting EIP From Amazon’s Pools Of IPv4,

So This Is The Default Setting, Let It Be As It Is.

Just Click On Allocate,

You Allocated One EIP.

This Is The EIP.

Now You Have The Static IP Address But This Static IP Address As Of Now Is Not Mapped With Any EC2 Instance.

So This Is Free, This Is Individual, This Is Not Yet Mapped With Any Resource.

So This Is Free From Resource, So You Need To Just Map This EIP With One Instance.

What You’ll Do, You’ll Select This EIP And Go To Actions.

And You Can Associate This EIP, You Select The Associate Elastic IP Address Option.

And Now It Is Asking On Which Particular Resource You Want To Map This EIP.

So We Have Two Options Here, One Is Instance And One Is Network Interface.

So You Are Choosing Instance Here.

You Click On Instance Here.

This Is The Running Instance You Have Right Now.

Either You Can Find Instance With Instance ID.

So You Are Selecting This Instance.

So Are You Providing Private IP Address Too?

Yes, You Are Providing Private IP Address To One Machine.

So Now If You Just Click On Associate.

The Picture Will Change.

Now This EIP,Is Mapped With This EC2 Instance, You Can See The Instance ID Under Associated Instance ID.

You Go Back To Instances Which Is There On Your Left Side On The Screen.

And If You Refresh It, This Time What You See?

You Have Now, EIP, With You.

Now You Can See The Public IP Address & EIP, Both Are Same For Your Machine.

Even The DNS Of This Machine Also Have The Same EIP In Its Name.

And The Private IP Address Will Remain Same.

And Now I Think The Picture Is Clear.

How You Can Provide And EIP To Your EC2 Instance.

 

Usefulness Of EIP & Why EIP Is Introduced?

If You Want To Provide An Fixed IP Address To Your Instance, We Have An Option Called EIP.

If You Have An EIP To Your Instance And If You Are Restarting Your Machine Again & Again, You Are Stopping & You Are Starting The Machine.

IP Address On That Machine Remain Same.

If You Have EIP On Your Machine, You Can Con figure Its Record In Route 53.

Even The If The EIP Is Same, You Can Use The EIP With The Load Balancers.

If You Have An Fixed EIP, The Best Thing Is You Can Define & Host Its On You Can Divert The Traffic.

 

How You Can Release This EIP?

Under Network & Security, Click On Elastic IPs.

You Can See EIP You Have.

Select This EIP.

Go To Actions-> Click On Disassociate The Elastic IP Address(Which Means First Of All You Are Disassociating This EIP From Your EC2 Instance)

After Clicking On It, You’ll See The EIP Is Not Associated With Any 2EC2 Instance.

It Has Been Disassociated.

Now Once Again Goto Actions, Now You Can Release The EIP, If You Release The EIP.

In Your Account There Is No EIP.

And If You Dont Have Any EIP, AWS Will Not Charge For This EIP.

 

After Disassociation The IP From One Instance Can We Reassign The Same IP Address With Another Instance?

Yes, You Can Use The Same EIP With Another Instance.

 

EIP’s Are Not Free, Only One EIP Is Free.You Can Use One EIP.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *