AWS VPC - Build Server Zone(Public Network) and LAN (Private Network)

Greeting everyone. So this time our article is about AWS VPC. In this article I am going to talk about what is VPC? How to set up a public network (Server Zone) and private network (LAN) in AWS VPC.
#<b>Introduction</b>
#####<b>What is VPC?</b>

- VPC stand for Virtual Private Cloud.It is a virtual network which dedicated to our AWS account.To make it simple we can say we be able to setup or configure our network on cloud.We also can modify its IP ranges, create subnet ,  configure route table , network gateway and security setting.

#####<b>What is Server Zone?</b>

- Server zone(Public network) is a public zone where normally it contains all the server machine.Any services that is being provide to the users on the internet should be place in this zone.

Example : Mail Server , VoIP Server, Web Server , DNS Server, FTP Server.

#####<b>What is LAN?<b>
- LAN(Private network) LAN stand for Local Area Network which is private network. This network is not response or receive directly to the internet. If there is a device want to request or access to the internet, first, it needs to sent the request to the router and router will communicate with the external network which is internet.

#<b>Getting Start</b>
So , today we are going to build a network in AWS VPC by creating A VPC , create two subnet which one subnet is for public network and another one is for private network.

#####<b>Why do we need to do that?Why do we need to separate our network?</b>

- We do that for a security purpose. When we host a website or anything on the internet. Our server will open to all the people on the internet. It mean everyone can access or make a request to our server so it mean that server is at risk because there is a chance that somebody trying to hack into our network. If we put the whole network together ,if the hacker successfully hack into the server machine the whole network will be in danger but if we separate the network, even if we get hack, the hacker won't be able to do anything to our LAN (private network).

##<b> Our VPC Structure </b>
<img width="723" alt="Screen Shot 2018-02-20 at 4.07.13 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/1e1721ea-df35-55f3-e588-943c14481011.png">

##<b>1. Create VPC</b>

So ,I assume that everyone has an AWS account. Right now let's go into AWS service and find VPC and create it.


Let's create a VPC and give its IP range 172.21.0.0/16. With this IP range I could get up to 65534 available IP address.To know the available IP address the easy way is to use online IP address calculator. => link http://jodies.de/ipcalc

##<b>2. Create Subnet</b>
- Ok so now, let's create subnet.First of all , let create subnet for a private network.
<img width="888" alt="Screen Shot 2018-02-20 at 2.18.37 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/374a99a0-f4be-1ee4-b892-f7078ead45a3.png">
I name this subnet as privateZone and its IP range is 172.21.0.0/19. The reason why I use /19 it is because I only need 8000+ available IP for my private network.

- Ok let's create subnet for a public network.
<img width="838" alt="Screen Shot 2018-02-20 at 2.26.23 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/830b1fa4-050d-f24c-2f79-786f542aa1ae.png">
I name this subnet as serverZone since it is going to contain only server machine and its IP range is 172.21.32.0./20. The reason why it is start from 172.21.32.0 it is because our private network has use all the IP from 172.21.0.0 until 172.21.31.255 so our next subnet must start from 172.21.32.0 and for this network I only need 4000+ IP that is why I use /20.

##<b>3. Create Internet GateWay <b>
- So, let go to internet gateway and create it and you have to associate it with your VPC . I name this internet gateway as visal-Igateway and you have to remember that 1 VPC can have only 1 internet gateway.
<img width="643" alt="Screen Shot 2018-02-20 at 2.37.45 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/a315c429-add5-7fdc-d924-a4f436fd2d2a.png">

##<b>4. Create Public Route Table </b>
Before we begin to create route table I want you guys to know that What make a subnet public it depends on what route table it is associate with and whether that route table has a rule outbound through the internet gateway.

- Ok so now let create a route table. 
<img width="763" alt="Screen Shot 2018-02-20 at 2.59.20 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/9bd985b0-3dec-0a58-9f91-eee35cfde883.png">
after we create our route we have to assign a rule for that route to out bound through the internet gateway. We can do that by click into the route and type 0.0.0.0/0 in the destination field and choose internet gateway and save it.
<img width="727" alt="Screen Shot 2018-02-20 at 3.13.22 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/b4088070-fa5a-a4d1-7c3a-098f0196d869.png">
So after we set this rule any subnet that associate with this route table it will become public subnet. So right now let associate this route table with our serverZone subnet since we want it to become public.Now let click on Subnet Associations tape - > click edit -> and select our serverZone and save.
<img width="758" alt="Screen Shot 2018-02-20 at 3.18.59 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/49e87694-b3db-e831-af91-952a9de5fb9a.png">

##<b>5. Create NAT Gateway</b>
We create NAT gateway the purpose is to translate between the private network and public network so our private network can also access to the internet but like I have mentioned since beginning , our private network won't access directly it will go to private route table and private route will communicate with public route table through NAT.
<img width="1311" alt="Screen Shot 2018-02-20 at 3.23.35 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/10a99ee2-73ad-3bfe-c2f7-ee61dba28465.png">
During the creation of NAT please choose public subnet(serverZone) as a subnet and click create new EIP then click create a NAT Gateway.

##<b>6. Create a Private Route Table</b>
- Create private route. I name it as visal-Private-Route
<img width="795" alt="Screen Shot 2018-02-20 at 3.38.41 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/0459a799-ab4c-7516-ac7c-ef4c1a665a2b.png">

- Then Go to Routes tape , click edit and assign the outbound rule to it and choose NAT that we create as target then save. 
<img width="740" alt="Screen Shot 2018-02-20 at 3.39.11 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/fe8ea6fd-28a6-ce25-25a6-5156f5bee138.png">
- Go to Subnet Associations tape , click edit and select our private subnet then save.
<img width="711" alt="Screen Shot 2018-02-20 at 3.39.31 PM.png" src="https://qiita-image-store.s3.amazonaws.com/0/211896/51a95944-bea5-f646-3ef3-91892a4b8d98.png">

That's it! Now we have create a VPC which contain 2 subnets. Public subnet and Private subnet.