Create two instances in two different vpc in same region and make them to ping to each other over internal ip(local ip)

 step1: Create Two VPC, one is Privpc and another is Pubvpc.

  


step2: Now create two subnet, one is Pubsub and another is Prisub.


step3: Now create two route tables, one is pubRT and another is PriRT. And attach pubRT to                         pubvpc. Then, PriRT attach with privpc.


step4: Now select pubRT and then below select subnet associate. Then, Edit subnet associate and                 select pubsub (subnet) and Save it.

          Now repeate same like this but this time for PriRT.

          Now sleect PriRT and then below select subnet associcate. Then, Edit subnet associate and                select prisub (subnet) and Save it.
  

step5: Now, create two Internet Gateway, one is pubigw and another is priigw. Then, Attach pubigw with pubvpc and priigw with priVPC.


step6: Now, create two security group, one is prisecgrp and another is pubsecgrp
           


      Now, select prisecgrp and go in inbound rules and Edit it. In inbound rules click on add rules            button then select type SSH and source ip 0.0.0.0/0
      Then add rules type All ICMP - IPv4 two time and add one time pubsub (subnet) CIDR IP                which you provided and second prisub (subnet) CIDR IP which you provided.

   

step7: Now create two instance one public and another is private
  
           In public instance configure : vpc -- pubvpc, subnet -- pubsub, security group -- pubsecgrp.
           Then Lauche instance.
 
           In private instance configure : vpc -- privpc, subnet -- prisub, security group -- prisecgrp.
           Then Lauche instance.

    

step8: Now, Go back to VPC dashboard and click on peering connection from the left hand side                   panel.

          Here, give name pubpeer. Then slecte local VPC to peer with in first VPC ID select pubvpc and            select another VPC to peer with in second VPC ID select priVPC and then click on create                      peering connection.

     


step9: Now, go back to route tables, and select one route pubRT and then select below route and                     click on button edit routes in right hand side below corner.

  


step10: Now, in Edit routes section click on Add route button and then click on target search box and               select internet gateway and choose pubigw and enter destination 0.0.0.0/0 which i hilighted                   in yellow color. 

             Then, click on Add route button again and click on target serach box and select peering                       connection  pubpeer and HERE make sure give correct destination if you doing this edit                 route for pubRT then enter destination of prisub (subnet) CIDR IP which you gave when                 created subnet.

             Same repeat these steps for priRT but just select internet gateway as priigw and in peer                     connection enter destinantion pubsub (subnet) CIDR IP which you gave when ctreated                     subnet.

   


step11: Now all steps done go back to EC2 instance page and connect first public instance and once it              should be connect copy private ip of Private instance. Then enter the command ping and                      paste the private ip of private insatnce like this commandping 172.0.0.38.

Now same like connect private instance this time and once it should be connect ping ip of public instance private ip.

   


     You will see same type of output in both instance when you connect and ping each other                     private IPs.   

 

      Thank you.

Comments

Popular posts from this blog

Error Solving : -bash: /usr/local/bin/kubectl: cannot execute binary file : after Kubernetes installation: you're trying to run the kubectl command on an EC2 instance in AWS

Nodejs Application project : using Aws, Jenkins, Docker, Kubernetes

Create two public subnets and two private subnets in two different availability zones(AZ) ( one public and one private subnet in each AZ).Create an instance of webserver (like apache ) in each AZ and an instance of db server in any AZ. Attach web servers to ELB and make sure to support cross zone availability.