www.awsgood.com
Virtual Private Cloud,你可以完全自訂這個網路裡面的subnet、ip range、routing table、gateway、security…等,當然也可以加EC2的instance進去。
是一段IP位址的範圍,aws的resource都可以擺在subnet裡面。一般會分為兩種:
如果你的region只有EC2-VPC而沒有EC2-Classic的話,在新增instance的時候就會有一個預設的VPC可以使用,並且有以下特性:
如果想要自建私有雲,或是想客製化網路環境的話,可以自建VPC實作。 因為自建VPC並不提供Public IP,所以必須搭配EIP及NAT…等技術才能與Internet連線 。基本上有以下四種情境,其他的變型情境都可以用這四種來衍生。
由於第三及第四種使用情境比較不符我們的使用方式,所以在此不深入研究,這邊只介紹第一及第二種情境。
| Destination | Target | Description |
|---|---|---|
| 10.0.0.0/16 | local | 表示所有連線到10.0.0.0/16網段的request,都要走local內網 |
| 0.0.0.0/0 | igw-xxxxxxxx | 表示所有連線到0.0.0.0/0網段的request,都要走到internet gateway,這樣才能連線到Internet |
| Source | Protocol | Port Range | Comments |
|---|---|---|---|
| 0.0.0.0/0 | TCP | 80 | 允許Internet可以讓所有HTTP連線連進來 |
| 0.0.0.0/0 | TCP | 443 | 允許Internet可以讓所有HTTPS連線連進來 |
| x.x.x.x | TCP | 22 | 允許特定IP可以使用SSH連進來 |
| Destination | Protocol | Port Range | Comments |
|---|---|---|---|
| 0.0.0.0/0 | TCP | 80 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| 0.0.0.0/0 | TCP | 443 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| Destination | Target | Description |
|---|---|---|
| 10.0.0.0/16 | local | 表示所有連線到10.0.0.0/16網段的request,都要走local內網 |
| 0.0.0.0/0 | igw-xxxxxxxx | 表示所有連線到0.0.0.0/0網段的request,都要走到internet gateway,這樣才能連線到Internet |
| Destination | Target | Description |
|---|---|---|
| 10.0.0.0/16 | local | 表示所有連線到10.0.0.0/16網段的request,都要走local內網 |
| 0.0.0.0/0 | eni-xxxxxxxx / i-xxxxxxxx | 表示所有連線到0.0.0.0/0網段的request,都要走到特定的網路介面(eni-xxxxxxxx)或NAT instance(i-xxxxxxxx),這樣才能透過Public subnet的NAT instance連線到Internet |
給Public subnet裡面的web server使用
| 流入 | |||
|---|---|---|---|
| Source | Protocol | Port Range | Comments |
| 0.0.0.0/0 | TCP | 80 | 允許Internet可以讓所有HTTP連線連進來 |
| 0.0.0.0/0 | TCP | 443 | 允許Internet可以讓所有HTTPS連線連進來 |
| x.x.x.x | TCP | 22 | 允許特定IP可以使用SSH連進來 |
| 流出 | |||
| Destination | Protocol | Port Range | Comments |
| 0.0.0.0/0 | TCP | 80 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| 0.0.0.0/0 | TCP | 443 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| DBServerSG-id | TCP | 3306 | 允許套用這個rule的instance,可以直接連線到DB server(此處以MySQL為例) |
給Public subnet裡面的NAT instance使用。
| 流入 | |||
|---|---|---|---|
| Source | Protocol | Port Range | Comments |
| 10.0.1.0/24 | TCP | 80 | 允許讓private subnet的HTTP連線連進來 |
| 10.0.1.0/24 | TCP | 443 | 允許讓private subnet的HTTPS連線連進來 |
| x.x.x.x | TCP | 22 | 允許特定IP可以使用SSH連進來 |
| 流出 | |||
| Destination | Protocol | Port Range | Comments |
| 0.0.0.0/0 | TCP | 80 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| 0.0.0.0/0 | TCP | 443 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
給Private subnet裡面的DB instance使用。
| 流入 | |||
|---|---|---|---|
| Source | Protocol | Port Range | Comments |
| WebServerSG-id | TCP | 3306 | 允許public subnet可以用DB connection(此處以MySQL為例)連進來 |
| 流出 | |||
| Destination | Protocol | Port Range | Comments |
| 0.0.0.0/0 | TCP | 80 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
| 0.0.0.0/0 | TCP | 443 | 允許套用這個rule的instance,可以直接連線到Internet,一般是拿來做系統更新用 |
安全群組,屬於instance level的安全管理機制,必須與EC2 instance綁在一起。在launch一個instance如果沒選擇sg時,AWS會自動將instance指定到一個預設的sg。
網路存取控制清單,屬於subnet level的安全管理機制,必須與subnet綁在一起。