AWS - VPC & Networking Basic Information

Support HackTricks

AWS Networking in a Nutshell

A VPC contains a network CIDR like 10.0.0.0/16 (with its routing table and network ACL).

यह VPC नेटवर्क उपनेटवर्क में विभाजित है, इसलिए एक उपनेटवर्क सीधे VPC, रूटिंग टेबल और नेटवर्क ACL से संबंधित है।

फिर, नेटवर्क इंटरफेस जो सेवाओं (जैसे EC2 उदाहरण) से जुड़े होते हैं, उपनेटवर्क से सुरक्षा समूहों के साथ जुड़े होते हैं।

इसलिए, एक सुरक्षा समूह नेटवर्क इंटरफेस का उपयोग करते समय उजागर पोर्ट को सीमित करेगा, उपनेटवर्क से स्वतंत्र। और एक नेटवर्क ACL पूरे नेटवर्क के लिए उजागर पोर्ट को सीमित करेगा।

इसके अलावा, इंटरनेट तक पहुँचने के लिए, कुछ दिलचस्प कॉन्फ़िगरेशन हैं जिन्हें जांचना है:

  • एक उपनेटवर्क सार्वजनिक IPv4 पते स्वचालित रूप से असाइन कर सकता है

  • नेटवर्क में बनाए गए उदाहरण को IPv4 पते स्वचालित रूप से असाइन किया जा सकता है

  • एक इंटरनेट गेटवे को VPC से जुड़ा होना चाहिए

  • आप Egress-only इंटरनेट गेटवे का भी उपयोग कर सकते हैं

  • आपके पास एक NAT गेटवे एक निजी उपनेट में हो सकता है ताकि उस निजी उपनेट से बाहरी सेवाओं से कनेक्ट करना संभव हो, लेकिन इसे बाहर से पहुँचना संभव नहीं है

  • NAT गेटवे सार्वजनिक (इंटरनेट तक पहुँच) या निजी (अन्य VPCs तक पहुँच) हो सकता है

VPC

Amazon Virtual Private Cloud (Amazon VPC) आपको एक वर्चुअल नेटवर्क में AWS संसाधनों को लॉन्च करने की अनुमति देता है जिसे आपने परिभाषित किया है। इस वर्चुअल नेटवर्क में कई उपनेट, इंटरनेट गेटवे इंटरनेट तक पहुँचने के लिए, ACLs, सुरक्षा समूह, IPs...

Subnets

उपनेट सुरक्षा के एक उच्च स्तर को लागू करने में मदद करते हैं। समान संसाधनों का तार्किक समूह आपके बुनियादी ढांचे में प्रबंधन में आसानी बनाए रखने में भी मदद करता है।

  • मान्य CIDR एक /16 नेटमास्क से लेकर /28 नेटमास्क तक हैं।

  • एक उपनेट एक ही समय में विभिन्न उपलब्धता क्षेत्रों में नहीं हो सकता।

  • AWS प्रत्येक उपनेट के पहले तीन होस्ट IP पते को आंतरिक AWS उपयोग के लिए आरक्षित करता है: पहला होस्ट पता VPC राउटर के लिए उपयोग किया जाता है। दूसरा पता AWS DNS के लिए आरक्षित है और तीसरा पता भविष्य के उपयोग के लिए आरक्षित है।

  • उन्हें सार्वजनिक उपनेट कहा जाता है जिनका इंटरनेट तक सीधा पहुँच है, जबकि निजी उपनेट का नहीं।

Route Tables

Route tables एक VPC के भीतर एक उपनेट के लिए ट्रैफ़िक रूटिंग निर्धारित करते हैं। वे निर्धारित करते हैं कि कौन सा नेटवर्क ट्रैफ़िक इंटरनेट या VPN कनेक्शन की ओर अग्रेषित किया जाता है। आप आमतौर पर निम्नलिखित तक पहुँच पाएंगे:

  • स्थानीय VPC

  • NAT

  • इंटरनेट गेटवे / Egress-only इंटरनेट गेटवे (जो VPC को इंटरनेट तक पहुँच देने के लिए आवश्यक हैं)।

  • एक उपनेट को सार्वजनिक बनाने के लिए आपको अपने VPC में एक इंटरनेट गेटवे बनाना और जोड़ना होगा।

  • VPC एंडपॉइंट (निजी नेटवर्क से S3 तक पहुँचने के लिए)

निम्नलिखित छवियों में आप एक डिफ़ॉल्ट सार्वजनिक नेटवर्क और एक निजी नेटवर्क के बीच के अंतर देख सकते हैं:

ACLs

नेटवर्क एक्सेस कंट्रोल सूचियाँ (ACLs): नेटवर्क ACLs फ़ायरवॉल नियम हैं जो एक उपनेट के लिए आने वाले और जाने वाले नेटवर्क ट्रैफ़िक को नियंत्रित करते हैं। इन्हें विशिष्ट IP पते या रेंजों के लिए ट्रैफ़िक को अनुमति देने या अस्वीकार करने के लिए उपयोग किया जा सकता है।

  • सुरक्षा समूहों का उपयोग करके पहुँच को अनुमति/अस्वीकृत करना सबसे सामान्य है, लेकिन यह स्थापित रिवर्स शेल को पूरी तरह से काटने का एकमात्र तरीका है। सुरक्षा समूहों में संशोधित नियम पहले से स्थापित कनेक्शनों को रोकते नहीं हैं

  • हालाँकि, यह पूरे उपनेटवर्क पर लागू होता है, इसलिए चीज़ों को प्रतिबंधित करते समय सावधान रहें क्योंकि आवश्यक कार्यक्षमता प्रभावित हो सकती है

Security Groups

सुरक्षा समूह एक वर्चुअल फ़ायरवॉल हैं जो VPC में उदाहरणों के लिए इनबाउंड और आउटबाउंड नेटवर्क ट्रैफ़िक को नियंत्रित करते हैं। संबंध 1 SG से M उदाहरणों (आमतौर पर 1 से 1)। आमतौर पर इसका उपयोग उदाहरणों में खतरनाक पोर्ट खोलने के लिए किया जाता है, जैसे कि उदाहरण के लिए पोर्ट 22:

Elastic IP Addresses

An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is allocated to your AWS account, and is yours until you release it. By using an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.

Connection between subnets

By default, all subnets have the automatic assigned of public IP addresses turned off but it can be turned on.

A local route within a route table enables communication between VPC subnets.

यदि आप एक उपनेट को एक अलग उपनेट से जोड़ रहे हैं तो आप अन्य उपनेट से जुड़े उपनेट्स तक पहुँच नहीं सकते, आपको उनके साथ सीधे कनेक्शन बनाना होगा। यह इंटरनेट गेटवे पर भी लागू होता है। आप इंटरनेट तक पहुँचने के लिए एक उपनेट कनेक्शन के माध्यम से नहीं जा सकते, आपको अपने उपनेट में इंटरनेट गेटवे असाइन करना होगा।

VPC Peering

VPC पीयरिंग आपको दो या दो से अधिक VPCs को एक साथ जोड़ने की अनुमति देता है, IPV4 या IPV6 का उपयोग करते हुए, जैसे कि वे एक ही नेटवर्क का हिस्सा हों।

एक बार जब पीयर कनेक्टिविटी स्थापित हो जाती है, तो एक VPC में संसाधन दूसरे में संसाधनों तक पहुँच सकते हैं। VPCs के बीच कनेक्टिविटी मौजूदा AWS नेटवर्क अवसंरचना के माध्यम से लागू की जाती है, और इसलिए यह उच्च उपलब्धता के साथ होती है जिसमें कोई बैंडविड्थ बाधा नहीं होती। चूंकि पीयर्ड कनेक्शन ऐसे काम करते हैं जैसे वे एक ही नेटवर्क का हिस्सा हों, आपके CIDR ब्लॉक रेंज के उपयोग के मामले में कुछ प्रतिबंध हैं। यदि आपके पास अपने VPC के लिए ओवरलैपिंग या डुप्लिकेट CIDR रेंज हैं, तो आप VPCs को एक साथ पीयर नहीं कर पाएंगे। प्रत्येक AWS VPC केवल अपने पीयर के साथ संवाद करेगा। उदाहरण के लिए, यदि आपके पास VPC 1 और VPC 2 के बीच एक पीयरिंग कनेक्शन है, और VPC 2 और VPC 3 के बीच एक और कनेक्शन है, जैसा कि दिखाया गया है, तो VPC 1 और 2 एक-दूसरे के साथ सीधे संवाद कर सकते हैं, जैसे कि VPC 2 और VPC 3, हालाँकि, VPC 1 और VPC 3 नहीं कर सकते। आप एक VPC के माध्यम से दूसरे तक पहुँच नहीं सकते।

VPC Flow Logs

Within your VPC, you could potentially have hundreds or even thousands of resources all communicating between different subnets both public and private and also between different VPCs through VPC peering connections. VPC Flow Logs allow you to capture IP traffic information that flows between your network interfaces of your resources within your VPC.

Unlike S3 access logs and CloudFront access logs, the log data generated by VPC Flow Logs is not stored in S3. Instead, the log data captured is sent to CloudWatch logs.

Limitations:

  • If you are running a VPC peered connection, then you'll only be able to see flow logs of peered VPCs that are within the same account.

  • If you are still running resources within the EC2-Classic environment, then unfortunately you are not able to retrieve information from their interfaces

  • Once a VPC Flow Log has been created, it cannot be changed. To alter the VPC Flow Log configuration, you need to delete it and then recreate a new one.

  • The following traffic is not monitored and captured by the logs. DHCP traffic within the VPC, traffic from instances destined for the Amazon DNS Server.

  • Any traffic destined to the IP address for the VPC default router and traffic to and from the following addresses, 169.254.169.254 which is used for gathering instance metadata, and 169.254.169.123 which is used for the Amazon Time Sync Service.

  • Traffic relating to an Amazon Windows activation license from a Windows instance

  • Traffic between a network load balancer interface and an endpoint network interface

For every network interface that publishes data to the CloudWatch log group, it will use a different log stream. And within each of these streams, there will be the flow log event data that shows the content of the log entries. Each of these logs captures data during a window of approximately 10 to 15 minutes.

VPN

Basic AWS VPN Components

  1. Customer Gateway:

  • A Customer Gateway is a resource that you create in AWS to represent your side of a VPN connection.

  • It is essentially a physical device or software application on your side of the Site-to-Site VPN connection.

  • You provide routing information and the public IP address of your network device (such as a router or a firewall) to AWS to create a Customer Gateway.

  • It serves as a reference point for setting up the VPN connection and doesn't incur additional charges.

  1. Virtual Private Gateway:

  • A Virtual Private Gateway (VPG) is the VPN concentrator on the Amazon side of the Site-to-Site VPN connection.

  • It is attached to your VPC and serves as the target for your VPN connection.

  • VPG is the AWS side endpoint for the VPN connection.

  • It handles the secure communication between your VPC and your on-premises network.

  1. Site-to-Site VPN Connection:

  • A Site-to-Site VPN connection connects your on-premises network to a VPC through a secure, IPsec VPN tunnel.

  • This type of connection requires a Customer Gateway and a Virtual Private Gateway.

  • It's used for secure, stable, and consistent communication between your data center or network and your AWS environment.

  • Typically used for regular, long-term connections and is billed based on the amount of data transferred over the connection.

  1. Client VPN Endpoint:

  • A Client VPN endpoint is a resource that you create in AWS to enable and manage client VPN sessions.

  • It is used for allowing individual devices (like laptops, smartphones, etc.) to securely connect to AWS resources or your on-premises network.

  • It differs from Site-to-Site VPN in that it is designed for individual clients rather than connecting entire networks.

  • With Client VPN, each client device uses a VPN client software to establish a secure connection.

Site-to-Site VPN

Connect your on premisses network with your VPC.

  • VPN connection: A secure connection between your on-premises equipment and your VPCs.

  • VPN tunnel: An encrypted link where data can pass from the customer network to or from AWS.

Each VPN connection includes two VPN tunnels which you can simultaneously use for high availability.

  • Customer gateway: An AWS resource which provides information to AWS about your customer gateway device.

  • Customer gateway device: A physical device or software application on your side of the Site-to-Site VPN connection.

  • Virtual private gateway: The VPN concentrator on the Amazon side of the Site-to-Site VPN connection. You use a virtual private gateway or a transit gateway as the gateway for the Amazon side of the Site-to-Site VPN connection.

  • Transit gateway: A transit hub that can be used to interconnect your VPCs and on-premises networks. You use a transit gateway or virtual private gateway as the gateway for the Amazon side of the Site-to-Site VPN connection.

Limitations

  • IPv6 traffic is not supported for VPN connections on a virtual private gateway.

  • An AWS VPN connection does not support Path MTU Discovery.

In addition, take the following into consideration when you use Site-to-Site VPN.

  • When connecting your VPCs to a common on-premises network, we recommend that you use non-overlapping CIDR blocks for your networks.

Client VPN

Connect from your machine to your VPC

Concepts

  • Client VPN endpoint: The resource that you create and configure to enable and manage client VPN sessions. It is the resource where all client VPN sessions are terminated.

  • Target network: A target network is the network that you associate with a Client VPN endpoint. A subnet from a VPC is a target network. Associating a subnet with a Client VPN endpoint enables you to establish VPN sessions. You can associate multiple subnets with a Client VPN endpoint for high availability. All subnets must be from the same VPC. Each subnet must belong to a different Availability Zone.

  • Route: Each Client VPN endpoint has a route table that describes the available destination network routes. Each route in the route table specifies the path for traffic to specific resources or networks.

  • Authorization rules: An authorization rule restricts the users who can access a network. For a specified network, you configure the Active Directory or identity provider (IdP) group that is allowed access. Only users belonging to this group can access the specified network. By default, there are no authorization rules and you must configure authorization rules to enable users to access resources and networks.

  • Client: The end user connecting to the Client VPN endpoint to establish a VPN session. End users need to download an OpenVPN client and use the Client VPN configuration file that you created to establish a VPN session.

  • Client CIDR range: An IP address range from which to assign client IP addresses. Each connection to the Client VPN endpoint is assigned a unique IP address from the client CIDR range. You choose the client CIDR range, for example, 10.2.0.0/16.

  • Client VPN ports: AWS Client VPN supports ports 443 and 1194 for both TCP and UDP. The default is port 443.

  • Client VPN network interfaces: When you associate a subnet with your Client VPN endpoint, we create Client VPN network interfaces in that subnet. Traffic that's sent to the VPC from the Client VPN endpoint is sent through a Client VPN network interface. Source network address translation (SNAT) is then applied, where the source IP address from the client CIDR range is translated to the Client VPN network interface IP address.

  • Connection logging: You can enable connection logging for your Client VPN endpoint to log connection events. You can use this information to run forensics, analyze how your Client VPN endpoint is being used, or debug connection issues.

  • Self-service portal: You can enable a self-service portal for your Client VPN endpoint. Clients can log into the web-based portal using their credentials and download the latest version of the Client VPN endpoint configuration file, or the latest version of the AWS provided client.

Limitations

  • Client CIDR ranges cannot overlap with the local CIDR of the VPC in which the associated subnet is located, or any routes manually added to the Client VPN endpoint's route table.

  • Client CIDR ranges must have a block size of at least /22 and must not be greater than /12.

  • A portion of the addresses in the client CIDR range are used to support the availability model of the Client VPN endpoint, and cannot be assigned to clients. Therefore, we recommend that you assign a CIDR block that contains twice the number of IP addresses that are required to enable the maximum number of concurrent connections that you plan to support on the Client VPN endpoint.

  • The client CIDR range cannot be changed after you create the Client VPN endpoint.

  • The subnets associated with a Client VPN endpoint must be in the same VPC.

  • You cannot associate multiple subnets from the same Availability Zone with a Client VPN endpoint.

  • A Client VPN endpoint does not support subnet associations in a dedicated tenancy VPC.

  • Client VPN supports IPv4 traffic only.

  • Client VPN is not Federal Information Processing Standards (FIPS) compliant.

  • If multi-factor authentication (MFA) is disabled for your Active Directory, a user password cannot be in the following format.

SCRV1:<base64_encoded_string>:<base64_encoded_string>
  • The self-service portal is not available for clients that authenticate using mutual authentication.

Support HackTricks

Last updated