Advertisement
uopspop

Untitled

Nov 15th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. * create VPC
  6. ** "vpc_env"
  7. ** "192.168.0.0/16"
  8.  
  9. * create subnet
  10. ** "us-east-1a"
  11. ** "192.168.1.0/24"
  12.  
  13. * create instance
  14. ** "Free tier only"
  15. ** image: "Microsoft Windows Server 2012 R2 Base - ami-eb1ecd96"
  16. ** key pair: "vpc_env_keypair"
  17. ** get public IP (for RDP)
  18. ** get password:
  19. *** Administrator
  20. *** 4K.T8rsvhIZ?tDSOALAz9s2t@P?aI(MA
  21.  
  22.  
  23.  
  24. ** RDP
  25. ** security group - allow RDP (default inbound is allowed)
  26. ** security group - allow response for RDP to go back (outbound - random port 1025 - 65535)
  27. ** subnet - auto-assign IP
  28.  
  29.  
  30. * subnet - route table
  31.  
  32.  
  33.  
  34.  
  35. * how to verify now ec2 can access to the Internet from within
  36. ** first: rdp to ec2
  37. ** windows:
  38. *** ping -t 8.8.8.8|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 8.8.8.8>nul" > ping.txt
  39. ** Linux:
  40. *** ping www.google.fr | while read pong; do echo "$(date): $pong"; done > ping.txt
  41.  
  42. ** second: change 0.0.0.0/0 from internet gateway to nat gateway
  43. ** wait a minute
  44. ** third: change 0.0.0.0/0 from gat gateway to internet gateway
  45. ** rdp to ec2
  46. ** final: check our log file to see whether the ping continues without long interruption
  47.  
  48. -----------------------------
  49. (Virginia)
  50. (Oregon)
  51.  
  52. VPC:
  53. * test_st_envsetup
  54. * 10.99.0.0/16
  55.  
  56. Subnet:
  57. * test_st_envsetup_public
  58. * 10.99.1.0/24
  59.  
  60. Routing:
  61. * default: local is set
  62.  
  63. NACL:
  64. * "test_st_envsetup"
  65. * default: all is allowed
  66.  
  67. Internet gateway:
  68. * test_st_envsetup_igw
  69. * create one
  70. * attach to VPC
  71.  
  72. Routing:
  73. * 0.0.0.0/0 to internet gateway
  74.  
  75. -----------------------------
  76.  
  77. NAT
  78.  
  79. (After setting up public subnet: )
  80.  
  81. NAT:
  82. * add an Elastic IP
  83. * create an NAT
  84. * attach this NAT to our public subnet
  85.  
  86. Create a private subnet:
  87. ** test_st_envsetup_private
  88. ** 10.99.2.0/24
  89.  
  90. Routing:
  91. ** attention: we are still using the default routing table
  92. *** create a new routing table
  93. *** test_st_envsetup_private
  94. *** private subnet: direct 0.0.0.0/0 to NAT gateway
  95. *** attach the new routing table to our private subnet
  96.  
  97. NACL:
  98. * default: all is allowed
  99.  
  100. ------------------------------
  101.  
  102. EC2-Linux:
  103. * create
  104. * add security group
  105. ** allow ssh inbound
  106. ** allow icmp "outbound" (attention: we are gonna send icmp from within) ??
  107. * "test_st_envsetup_keypair_final02"
  108. (* ping )
  109. * name it "test_st_envsetup_private"
  110. * ephemeral port
  111. ** "32768-61000"
  112.  
  113. EC2-Windows:
  114. * create
  115. * add security group
  116. ** allow RDP inbound
  117. ** allow ICMP inbound
  118. * "test_st_envsetup_keypair_final"
  119.  
  120. * RDP to Windows
  121. * close firewall
  122.  
  123.  
  124. error tryout:
  125. * remove internet gw
  126. * add back
  127. * remove sg icmp setting (give it some time ... )
  128. * add back
  129. * remove nacl all rules
  130. * add nacl icmp blocking inbound
  131. * add nacl icmp blocking outbound
  132.  
  133.  
  134.  
  135. ------------------------------
  136.  
  137. Test: add a bastion host
  138. * create a new ec2 linux instance
  139. * "test_st_envsetup_public"
  140. * auto-assign public IP: enable
  141. * Must choose the same key pair used for private subnet
  142. * name it
  143.  
  144.  
  145. Putty:
  146. * convert private key to .ppk format for Putty connection
  147. ** "test_st_envsetup_keypair_final02"
  148. * add this ppk-format file to your pageant
  149. * putty
  150. ** hostname: "ec2-user@52.91.156.32"
  151. ** Connection-SSH-Auth- click allow agent forwarding
  152. ** save "linux_rhel_ec2-user_final"
  153. * ssh to the ec2 linux instance in the private subnet
  154. ** "ssh ec2-user@10.99.2.168"
  155. * ping test
  156.  
  157. error tryout:
  158. * remove sg outbound rules for ICMP
  159. ** add back
  160. * add and remove sg inbound rules for ICMP
  161. ** to prove it's stateful
  162.  
  163.  
  164.  
  165. ------------------------------
  166.  
  167. * make it sleep
  168. delete NAT gateway
  169. stop instances
  170. release elastic IP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement