AWS EC2-Windows Server cannot access outside network - amazon-ec2

I Setup a AWS VPC
There are different subnet such as publics subnet and private subnet
My target is created a demo that Windows Server from private subnet access public internet through third party's EC2-Firewall in AWS-VPC
I create a EC2-Firewall with different interface into different subnet (with Allow all policy and allow interface ping)
I also create a EC2-windows server into private subnet, but it cannot access outside network
The issue observed:
EC2-windows can ping local network (/24) include firewall's interface
EC2-windows cannot access (web-browsing/ping) outside network
EC2-windows tracert 8.8.8.8, all response "* * * * request timeout" (default gateway cannot be shown too)
EC2-windows's Ethernet changed to DHCP or changed to static with firewall's interface IP as a default gateway, issue also occurred
Background Information:
Network ACLs is default setting (Allow All)
Security groups is allow all traffic in both direction
AWS subnet - Routing table with two record: Destination: VPC subnet, Target: Firewall's interface & Destination: 0.0.0.0/0, Target: Firewall's interface
Firewall's interface (same subnet) can ping & RDP to EC2-Windows
Firewall has no traffic record "source with EC2-windows, destination: outside network"
EC2-Windows's internal firewall is turn off
Any setting am I missing to check? what should I check to found the root cause related to AWS or Windows setting?
More information after Wireshark on Windows and package capture on firewall:
EC2-Windows sent the "ping 8.8.8.8" & "ping firewall's interface IP" to Firewall's Interface MAC address (shown in Wireshark)
Firewall's interface packet capture only "ping firewall's interface IP" be shown
Is it mean that AWS-VPC drop my outside traffic? How can I fix it?

I found the answer. The root cause is "source/destination checks" of interface.
Since firewall will be able to send and receive traffic the source or destination is not itself when EC-Windows access outside network, AWS "source/destination checks" drop the packet of it.
After Disable source/destination checks, the issue is solved.

Related

Not able to access EC2 instance in same VPC via private IP

I have 2 EC2 instances (one window and one linux) in same subnet. I am trying to access one instance from another via private IP but I am not able to do so.
In security groups, both instances belong to same security groups and security group allows all traffic from the same security group.
I am not even able to ping one instance from another using private IP address.
Any pointers what could be wrong here.
By default the Windows firewall will deny all inbound requests (including ping), but the firewall also contains a list of Exceptions (otherwise it would block everything!). Those Exceptions are a set of rules that describe what connections should be allowed in out-of-the-box.
To allow any additional connections, you just add a new rule to the firewall. There is a Wizard in the Windows Firewall GUI for viewing and creating rules, but i find it easier to use a PowerShell one-liner like this to allow ping:
New-NetFirewallRule -DisplayName "Inbound LAN Ping" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -RemoteAddress 192.168.1.0/24 -Action Allow
Above will allow any IP's between 192.198.1.1 ... 192.168.1.255 to send ping requests to your Windows host (all other RemoteAddress will still be ignored). I'm assuming here your Linux machine's IP is for example 192.168.1.1 and your Windows machine's IP is 192.168.1.123.
As a rule of thumb, you should only open up the minimal number of ports, to as few IP/IP ranges as possible.
This will likely be the result of Windows firewall being enabled, with default settings it will block ping access (among other things).
Disabling it should enable inbound/outbound access to work for ping. This is a temporary measure and should not be considered a permanent workaround.
You should enable whitelisting in the Windows firewall to allow the ports you would like inbound or outbound to have network access to/from other resources within the network.
More information is available in this link.

forward vpn network to another interface

I have an RB750 with the follow setup:
- Interface 1 = WAN static IP
- Interface 2 = Static IP from a LAN network (LAN provided by another FW)
- MK as a IPSec/L2TP working well providing to clients the subnet x.x.x.x
I would like to redirect all traffic from VPN clients to the LAN network provided in Interface 2.
I mean; User setup in his computer the VPN with success, when connected they need to access the server z.z.z.z located inside the network provided in Interface 2.
Any ideas how to configure it?
You provide not much information, but if im not wrong
you can try NAT for example
/ip firewall nat add chain=srcnat action=masquerade out-interface="your Interface 2" src-address="your l2tp subnet x.x.x.x"

EC2 instance with EIP in Public subnet not connecting to Internet

I have a strange problem wherein I am able to connect to an EC2 instance in a public subnet in AWS VPC using RDP and HTTP. However after successfully connecting to the instance through RDP, i am not able to connect to Internet (from the instance).
a) I created a non-default AWS VPC and associated an IGW to it. The address range of VPC is 10.0.0.0/16. A subnet with the address space 10.0.5.0/24 was created
c) In order to make the subnet public, i decided to retain the Main Route Table as it is and created an additional Route table with the following entries
10.0.0.0/16 local
0.0.0.0/0 igw
d) This route table was associated with the subnet 10.0.5.0/24. This makes it a public subnet
e) The NACL is set to allow:
INBOUND traffic HTTP(80),HTTPS(80),SSH(22), RDP(3389) for IPV4 and NACL
outbound traffic ALL TRAFFIC ALL PROTOCOL ALL PORT Range Destination 0.0.0.0/0
f) The security group settings are:
Inbound All traffic All All 0.0.0.0/0
Outbound All traffic All All 0.0.0.0/0
g) I created a single EC2 instance in the public subnet and assigned a Elastic EIP to it. I am able to connect to this using RDP and able to access the IIS Welcome page by typing the public DNS name of the EC2 in my local browser. However, from the instance when i open IE and try accessing any popular websites i am not able to access the Internet. I always get a 'Can't reach this page'
h) I disabled Windows Firewall and tried accessing Internet. But still it didnt work.
i) The tracert output just shows Request timed Out in all the lines.
Any help would be appreciated.
Thanks and Regards
Govind
First, verify that the following conditions are met:
The route table in the instance’s subnet has a default route to an
internet gateway. The security group attached to the instance’s
elastic network interface must allow outbound traffic on the following
ports: Port 80 for HTTP traffic Port 443 for HTTPs traffic Identify
the network access control lists (ACLs) that are associated with the
subnet that the instance is located on. These network ACLs must have
rules to allow inbound and outbound traffic on ports 80 and 443.
You don't need to open all the ports to enable outgoing web traffic.
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-connect-internet-gateway/
Finally i was able to fix this issue. I added
ALL TCP TCP (6) 0 - 65535 0.0.0.0/0 ALLOW
as an INBOUND rule in NACL. Immediately i was able to access the Internet from the browser in Ec2 instance.
However i am not convinced that all the ports should be opened to use browser on an EC2 instance in the public subnet. Is there a better way to do this ?
Can i consider setting up a Forward Proxy server as a solution for browser based outgoing traffic as in this case ? Please suggest

Configure windows firewall, to only allow VPN traffic

It is possible to block a specific application when VPN is not connected.
Block torrent program if VPN is not connected.
The essence is simple: Windows has two network groups "Public" and "Private". The application is blocked when you are on the Private network, but is not blocked over the Public network.
What I want is to allow the VPN connection to be made over the Private network connection, but don't allow ANY other connections over Private (nor inbound, nor outbound). Then, when the VPN connection is made (Public network) allow all connections over that Public network.
My ethernet connection is set to Private network, my VPN is set to Public network.
Outound rules:
In the Private Profile, I set "Outbound connections:" to "Block" (allow is default)
In the Public Profile, I set "Outbound connections:" to "Block" (allow is default)
I removed all outbound rules, besides mDNS (UDP local 5353 to remote any)
I added a rule: allow, all profiles, UDP, local port any, remote port 53 (for DNS lookup)
I added the VPN program: All profiles, Allow, any protocol, any local port, any remote port
Inbound Rules:
I added the VPN program: All profiles, Allow, UDP & TCP, any local port, any remote port
So far, so good! With these configurations, my VPN program can create a connection, and obtains a new IP address. However, all other connections are still blocked.
Now the problem, I created one more outbound rule to allow everything for the Public profile. Windows firewall tells me that both the Private and Public profile are active (when VPN is connected). Though, when i open Firefox I have no connection at all...
If I set that last outbound rule to allow all for private, I have a connection when the VPN drops, but NO connection when VPN is on.
If I set that last outbound rule to allow all for public & private, I have a connection both when VPN is connected and not.
My Question: What do I need to change to allow all when Private & Public network are active, but block when only Private is active.
note: I also tried to allow all outbound by default, and set a rule to block all outbound under private. So far this method failed as well. It seems as if the Private rules override the Public rules?
It seems you do all right except your VPN connection must be in a "Private Network" group and your WAN broadband connection in a "Public Network" group to have it working with your firewall settings.
Simply change in "Network and Sharing Center" your active VPN connection to "Work Network" and WAN broadband connection to "Public Network" to do so.
Firewall should "Allow" all Outbound connections for a "Private Profile" but "Deny" all Outbound connections for a "Public Profile" and "Domain Profile (Win7 only)".
It works on Windows 7/8/8.1/10

Do I need to set up route table for my laptop to ssh to an instance with public IP?

Let me first describe my operational steps:
I set up a VPC with CIDR 10.20.0.0/16 (and I created and attached to it an IGW, igw-14ed6f75).
And then I set up a subnet subnet_A 10.20.1.0/24. This subnet's route table is 10.20.0.0/16 -->local (NOTE: I did not set route of 0.0.0.0/0 --> igw-14ed6f75 in this route table)
I started an instance instance_A in subnet_A, and its automatically created public IP is 52.53.245.253. (BTW, the key pair used for this instance is bastion_box)
I wanted to ssh to instance_A by ssh -i ~/.ssh/bastion_box.pem ec2-user#52.53.245.253
Result/Observation: I can't ssh into instance_A
Now I added one route 0.0.0.0/0 --> igw-14ed6f75 into the route-table associated with subnet_A, and then I do the ssh operation again ssh -i ~/.ssh/bastion_box.pem ec2-user#52.53.245.253
Result/Observation: I can successfully ssh into instance_A now
Here is my question: why do we need the route of 0.0.0.0/0 --> igw-14ed6f75 to be able to successfully ssh into the instance? I thought this rule is for the instance connect out to Internet, but not for the outside machines to connect in the subnet.
TCP connections are two-way connections. The server needs to be able to send traffic to the client (and once the initial handshake is done, the two are indistinguishable). Without an egress route, the server could not send any packets back to the client to establish the connection.
From http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html (bold added):
To enable access to or from the Internet for instances in a VPC
subnet, you must do the following:
Attach an Internet gateway to your VPC.
Ensure that your subnet's route table points to the Internet gateway.
Ensure that instances in your subnet have public IP addresses or Elastic IP addresses.
Ensure that your network access control and security group rules allow the
relevant traffic to flow to and from your instance.

Resources