Can non-rfc1918 ranges in peered VPCs be overlapping if they are not exported? - google-compute-engine

If two VPCs are peered and both use non-RFC1918 subnetworks, can those subnetworks have overlapping CIDR ranges? Does it depend on whether import-subnet-routes-with-public-ip / export-subnet-routes-with-public-ip are used?
https://cloud.google.com/vpc/docs/vpc-peering says "A subnet CIDR range in one peered VPC network cannot overlap with a static route in another peered network. This rule covers both subnet routes and static routes." This mentions nothing about whether the routes are exported or not. Neither does https://cloud.google.com/vpc/docs/vpc-peering#interaction-subnet-subnet. So it seems that subnetworks cannot be overlapping. However, its not explicitly called out, and so is unclear.

Yes, non-rfc1918 ranges in a peered VPCs can be overlapped if both sides of the peering did not import the non-rfc1918 subnet.
i.e
import_subnet_routes_with_public_ip: false
All the ranges defined here in this documentation will be treated as non-public IP.
Non-public IP addresses from this documentation are always exchanged regardless of the value of allow_subnet_routes_with_public_ip. If those ranges overlap, then VPC peering is not allowed.
If allow_subnet_routes_with_public_ip is false, then the user can have overlapping public IP subnets, but those won't be exchanged.
If allow_subnet_routes_with_public_ip is true, then the user cannot have overlapping public IP subnets, otherwise the peering will be rejected.
If a non-public IP subnet. say 198.18.0.0/15, is expanded to 198.18.0.0/14 into the public range, then it will be treated as a public IP range subnet, and rules (2) and (3) above will apply to it.

Related

Varnish: Multiple IPs compare to ACL using Tilde

What would happen in Varnish if multiple IPs are in an X-Forward-For header which is compared to an ACL using the tilde operator?
Dummy example:
The request has the following HTTP header:
X-Forward-For: 160.12.34.56, 10.10.10.10
The Varnish config looks like this:
acl internal {
"10.10.10.10"
}
if ((std.ip(req.http.X-Forward.For, "0.0.0.0") ~ internal)){
# THIS CODE
}
else {
# OR THIS CODE
}
Which code block is executed?
Also, does the order of the IPs matter in the X-Forward-For header?
Does it change if there are 2 X-Forward-For headers, each with one of the two IPs?
Will it work?
The short answer to your question is no, it won't work.
std.ip() expects to receive a single IP address, not a collection. The conversion will fail, and the fallback value (second argument of the function) will be returned.
Here's a quick test script that illustrates this:
vcl 4.0;
import std;
backend default none;
sub vcl_recv {
set req.http.x-f = "1.2.3.4, 5.6.7.8";
return(synth(200,std.ip(req.http.x-f,"0.0.0.0")));
}
This example will return 0.0.0.0.
Does X-Forwarded-For need multiple IP addresses?
It does make sense to ask the question if your X-Forwarded-For header needs multiple IP addresses.
The idea is to indicate to the origin server what the IP address of the original client was.
In your case there is more than 1 proxy in front of the webserver, so a natural reaction is to chain the IP addresses in the X-Forwarded-For header.
A better solution would be to figure out what the IP address of the original client was, and set that value in X-Forwarded-For.
The best way to get this done is by leveraging the PROXY protocol, which Varnish supports.
Leverage the PROXY protocol
The PROXY protocol has the capability of transporting the HTTP protocol, but additionally keep track of the connection parameters of the original client.
Varnish supports this and allows you to set an extra listening port that listens for PROXY requests.
Here's an example of how you can start varnishd with PROXY support:
varnishd -a :80 -a :8443,PROXY -f /etc/varnish/default.vcl -s malloc,256m
As you can see, port 80 is still available for regular HTTP, but port 8443 was allocated for PROXY support.
If the proxy servers in front of Varnish support PROXY, Varnish will take the value from the original client and automatically set X-Forwarded-For with that value.
This way you always know who the client was, and you can safely perform your ACL check.
Additionally, there's also a PROXY module for Varnish, that can give you information about potential TLS termination that took place in front of Varnish.

OpenShift egress router not working

i configured an egress router like described here:
https://docs.openshift.com/container-platform/3.3/admin_guide/managing_pods.html#admin-guide-controlling-egress-traffic
But it does not work.
In my understanding, the options will be resolved like this:
name: EGRESS_SOURCE <-- This is the network where the nodes live (in my case the vm where the Containers are running on)
value: 192.168.12.99
name: EGRESS_GATEWAY <-- The gateway over which the destination ip address is routable.
value: 192.168.12.1
name: EGRESS_DESTINATION <--- The destination ip of the application i want to reach. In my case its a mongoDB living in a classical VM.
value: 203.0.113.25
Am i right or do i miss something ?
How would i be able to reach the target ?
Do i need to address the source ip to access the MongoDB or do i simply address the IP of my MongoDB an the traffic gets nat'd the way over my egress router (This is how i understood the traffic flow will be btw.) ?
How can i troubleshoot this kind of problem ?
Best Regards,
Marcus
Ok, it worked by now. I created a service and adressed the ip of this service to reach my destination.
The alternative way is to address the ip of the container.
So from inside the container to reach your original destination don't use the original ip, rather use the egress pod ip or preferred use the ip of the created service.
!!Attention: The destination ip must be outside of the host/node ip range otherwise it would not work. It seems that, if you use a destination ip from your host/node range, the standard gw will get the request and i think it will discard it. !!
And i would suggest to use the egress router image from redhat, instead the origin, which is stated in the official document from redhat...
image: registry.access.redhat.com/openshift3/ose-egress-router

Subnet Mask /23 till second octect 255.255.254.0

I am currently getting subnet Mask /23 till second octect 255.255.254.0.
My ip address is 10.11.17.111, and broadcast ip is 10.11.17.254.
So while pinging the server, is it correct, if we are pining on
10.11.16.255. Since it is not broadcast ip.
What I think you're asking is if whether or not you can use 10.11.16.255 for a host, given your subnet mask. Please try re-wording your question if that's not the case.
With your netmask, it is totally acceptable to use 10.11.16.255 for a host. It's not a broadcast address, nor a network ID. It's the same as any other IP in this case.

Can I use "new ServerSocket(0)" with openshift

I have developed an application that allows multiple players to play together on line at various games such shifumi, poker, chess and so on. It works very well on my localhost. I would like to publish it. So I decided to use openshift to do this.
But there is a problem.
It seems it come from this statement : new ServerSocket(0). I do this inside the doPost method of an HttpServlet.
Could you tell me I don't have the permission to do this (new ServerSocket(0)) inside an openshift server?
I think you have a couple of issues going on here.
The first is that when you call new ServerSocket(0), it is going to try to find a socket that it can bind to, probably on either 0.0.0.0 (all ip addresses/interfaces) or 127.0.0.1, neither of which is allowed on OpenShift.
According to the documentation (located here: http://download.java.net/jdk7/archive/b123/docs/api/java/net/ServerSocket.html) you can use one of the overloaded methods to provide an ip address to bind to, which should be your OPENSHIFT__IP (where could be jbosseap, jbossas, wildfly, jbossews, etc).
ServerSocket(int port, int backlog, InetAddress bindAddr)
Your second issue is a bit more complicated, basically what ports you can bind to. OpenShift allows user code to bind to ports 15000-20000, depending on what ports are not being used by other applications or services. However, none of those ports are open to the public internet, they are all internal ports for internal communications, so if you are trying to let a client connect to them, it won't work. The only ports that are publicly available are 80/443/8000/8443, and your application must bind to port 8080 on your OPENSHIFT__IP to be able to be reached using your app-domain.rhcloud.com public url. You can check out this article to read more about how all of the binding and routing works: https://developers.openshift.com/en/managing-port-binding-routing.html
Hopefully that answers the question about why that piece of code is not working.

CNAME value instead of HOST value

If we have a customer with a cname record, sub1.notourserver.com, pointing to something like abcdefg.ourserver.com, we read the host as sub1.notoursever.com. Is it possible for us to somehow get the value abcdefg.ourserver.com from this request? We have a subdomain route setup, but it is not picking up on it because the host does not match our SERVER_NAME config setting.
HTTP does not provide that information, and so neither can Flask/Werkzeug. You need to use in Flask/Werkzeug the (sub)domain names actually used by clients.
If you really can not do that, you need to hack a WSGI middleware that maintains an explicit mapping (or makes DNS requests) and patches environ['HTTP_HOST'].