AWS ip ranges for network restrictions - amazon-web-services

My team is using AWS on on-premise server at clients HQ.
Client is asking IP adresses to set networking restrictions (outbound).
I found that AWS provides currently used ip ranges for their services.
For example:
S3 in eu-west-1 region has 8 ip prefixes
Rabbit MQ (mq.eu-west-1...) - seems doesn't have any specific ip ranges?
We could send ip prefixes from json file but I see few problems:
How to avoid ip ranges changes and clients network reconfiguration each time?
List of used ip ranges for each service is quite large
I'm having a stupid idea that maybe there is a way to have one ip for each AWS service? For example route all S3 traffic (by using other AWS services) through one endpoint?
Additionally, how to find Amazon MQ ip ranges? In the end we're using something like this: amqps://{username}:{password}#{url}.mq.eu-west-1.amazonaws.com:5671
Thanks in advance!
EDIT:
RabbitMQ broker seems to have static IP

Related

Why are AWS CLI not working from behind a IPv6 address?

I have problems using AWS CLI from an IPv6 address on Ubuntu 20.04.2 LTS.
Simple commands like aws lambda get-account-settings run idle indefinitely.
When switching to an IPv4 address, everythings works fine.
Same behavior when using Python's boto3 library.
Any ideas?
I think Lambda service does not have IPv6 (dual-stack) endpoints. Only some services in some regions support IPv6, such as S3 or EC2.
Even if they support IPv6 you have to make extra settings to use this as explained in the linked docs for S3 and EC2.
Lambda now has IPv6 endpoints as of early December 2021. It joins the list of about 8-10 AWS services which do support IPv6 (depending on how you count).
So for example:
aws lambda list-functions --endpoint https://lambda.us-west-2.api.aws
If you are also looking for other services, I have a blog post here showing all APIs with known IPv6-capable endpoints. Realistically speaking though, IPv4 will be necessary to interact with most AWS services for some time. If you are just trying to not interact with the IPv4 Internet, VPC Endpoints can help get internal IPv4s for many AWS services.

AWS Client VPN Client-Client Communication

I have an AWS Client VPN set up using certificate auth. I'm setting this up for a client-client access system, essentially as is described in this AWS scenario/example. It's all working, and I can ping from one client to another if I know their IP address.
My question is: in actual use, what use is this system if clients get assigned a random IP address every time they connect to the VPN, and there's no way to tell which clients are connected or what their IP addresses are without checking the AWS console or using the describe-client-vpn-connections CLI (which requires IAM credentials)?
Is there any way to:
Assign static IP addresses to specific clients, so they receive the same one every time they connect to the VPN?
Get a list of connected clients (with their CommonName and IP address)?
Use a connected client's host name / computer name instead of their random VPN IP address?
Any other way to connect from one client to another without having to use the AWS Console or describe-client-vpn-connections CLI to get a list of connected clients?
Much of what you're asking for is not possible. In many organizations, client-to-client communication is not the norm. For client-to-server communication, AWS Client VPN works well.
There is no way to assign static IP addresses to specific clients.
You can get a list of current connections and client IP addresses with the following AWS CLI command:
aws ec2 describe-client-vpn-connections --client-vpn-endpoint-id (endpoint ID)
You might be able to get your clients to register via a shared DNS server to get their VPN IP address.
I suspect you'll have better luck rolling your own VPN solution with something like OpenVPN, which much of the AWS Client VPN is built off of.

Googleapis.com - What are the IPs and Ports for firewall?

My organization has a firewall that restricts the traffic to or from the Internet, so i need the ip address and ports used by googleapis.com.
i want to access google cloud Speech-to-text api and dialogflow api
You can get full list of IP addresses here
https://www.gstatic.com/ipranges/goog.json
As far as I know its gets updated regularly and it covers all the IPs. However, this list is quite long.

Static IP to access GCP Machine Learning APIs via gRPC stream over HTTP/2

We're living behind a corporate proxy/firewall, that can only consume static IP rules and not FQDNs.
For our project, we need to access Google Speech To Text API: https://speech.googleapis.com. If outside of corporate network, we use gRPC stream over HTTP/2 to do that.
The ideal scenario looks like:
Corporate network -> static IP in GCP -> forwarded gRPC stream to speech.googleapis.com
What we have tried is creating a global static external IP, but failed when configuring the Load Balancer, as it can only connect to VMs and not APIs.
Alternatively, we were thinking to use output of nslookup speech.googleapis.com IP address ranges and update it daily, though it seems pretty 'dirty'.
I'm aware we can configure a compute engine resource / VM and forward the traffic, but this really doesn't seem like an elegant solution either. Preferably, we can achieve that with existing GCP networking components.
Many thanks for any pointers!
Google does not publish a CIDR block for you to use. You will have daily grief trying to whitelist IP addresses. Most of Google's API services are fronted by the Global Frontend (GFE). This uses HTTP Host headers to route traffic and not IP addresses, which will cause routing to fail.
Trying to lookup the IP addresses can be an issue. DNS does not have to return all IP addresses for name resolution in every call. This means that a DNS lookup might return one set of addresses now and a different set an hour from how. This is an edge example of grief you will cause yourself with whitelisting IP addresses.
Solution: Talk to your firewall vendor.
Found a solution thanks to clever networking engineers from Google, posting here for future reference:
You can use a CNAME in your internal DNS to point *.googleapis.com to private.googleapis.com. This record in public DNS points to two public IP addresses (199.36.153.8/30) that are not reachable from the public internet but through a VPN tunnel or Cloud interconnect only.
So if setting up a VPN tunnel to a project in GCP is possible (and it should be quite easy, see https://cloud.google.com/vpn/docs/how-to/creating-static-vpns), then this should solve the problem.

Is the a way to extract IP range used by a service hosted in Amazon Kinesis firehose?

we have an application that runs on different client systems which sends data to Amazon Kinesis Data firehose. But the client has firewall which restricts outbound traffic only to whitelisted IP addresses and does not allow domain names in their firewall regulation. I am not that familiar with aws but read that the amazon IP keeps changing. Because of this we are having problem to whitelist the IP address in the client firewall.
I came across following pages tha mentions that aws public IP address ranges available in JSON Format.
https://aws.amazon.com/blogs/aws/aws-ip-ranges-json/
https://ip-ranges.amazonaws.com/ip-ranges.json
It's a huge list and multiple entries for the same region. can you suggest a way to somehow extract IP range that our service will use so that we can whitelist them in the client's firewall? Any other alternative is also welcomed.
Thanks in advance for any help and/or suggestions.
Firehose has regional endpoints that are listed on this page:
https://docs.aws.amazon.com/general/latest/gr/rande.html
Using the us-east-2 endpoint as an example...
Right now, firehose.us-east-2.amazonaws.com resolves, for me, to 52.95.17.2 which currently features in the ip-ranges.json document as:
service: AMAZON region: us-east-2 ip_prefix: 52.95.16.0/21
If you wanted to know which ranges to whitelist on the firewall, you'd need to get all of the ranges for AMAZON in us-east-2 (currently 34 if you include IPv6 addresses). Note: That assumes all of the endpoints fall under the AMAZON service marker and you'll be whitelisting far more services than just firehose if you whitelisted that.
Previous contact with AWS support suggests that ranges can be added without warning, so you'd need to frequently check the published ranges and update the firewall to avoid a situation where the endpoint resolved to a new IP address that wasn't whitelisted.
If you did want to go the route of frequent checks and whitelisting, then a python script like this could be used to retrieve the relevant IP ranges:
#!/usr/bin/env python
import requests
aws_response = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json')
response_json = aws_response.json()
for prefix in response_json.get('prefixes'):
if prefix.get('service') == 'AMAZON' and prefix.get('region') == 'us-east-2':
print(prefix.get('ip_prefix'))