Azure Network Security Group - Internet vs Any - azure

In the Image we can see AllowInternetOutboundRule is open to Internet. But does Internet here convey 0.0.0.0/0 IP?
If not, then what is difference between 'Internet' and 'Any'.
Also, does AllowInternetOutboundRule imply port 443 open to 0.0.0.0/0 or we will have to open 443 port to any?

Related

port 3389 won't open up on azure vm

when i try to do rdp, it doesn't work.
sudo netstat -plnt | grep rdp
tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN 106888/xrdp-sesman
The above command is supposed to return one more line having port 3389 as open, but it doesn't.
In the NSG, i have opened inbound connections on port 3389, and in a connection test in the azure console, it shows that inbound connections to the port is working.
This doesn't make sense to me.
I assume that you created a Windows/Linux VM from Market Place image, so by default 3389 is allowed inside Windows Firewall, for Linux this port 3389 might be your service running on this port. When you create a NSG rule form traffic outside, you must use private IP of your VM.
You need to make sure that your NSG is associated either to your NIC or SUBNET of VM, so I suggest you to test it using Network Watcher, use the same Remote IP address 200.200.200.200 and port 45654, it is up to you, it must has a public IP and a port from the source. For local IP address and port you put information about your VM (private IP). In my case it is not allowed port 3389.
Another test you can do, in case that you have another VM in the same SUBNET of this one, try to telnet PRIVATE_IP 3389.

can not access Azure VM thru port 8888

I set up an Azure ubuntu VM, created the network security group, added port 80 and 8888 rules. firewall is inactive. associated nsg to the subnet of the VM. Not able to remote connect to port 8888, but telnet to port 80 ok, and port 8080 also ok, even though there is no rule allowing 8080. I experimented and removed port 80 inbound rule, but still can access port 80.
netstat -ant | grep 8888 shows one process is listening
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN
It just appears that the access is not following my inbound rules but obeying some default. What can it be doing?
As you said, your service is listening on 127.0.0.1, the service is only accessed inside VM.
You should set your service listen on 0.0.0.0 or VM's private IP.
Four reasons:
Firewall on VM level.
No application listening on said ip\port.
Network security group attached to the vm\subnet blocking traffic.
Azure Firewall (highly unlikely, preview feature).
You appear to be rocking case number 3. How to edit NSG.

Azure VM endpoint: mapping public port to a different local port

I was wondering if it is possible to map a public ip port (e.g. port 80) to a different local/private ip port (e.g. port 81) on a Azure iaas VM. I believe this was doable in the old portal and it is doable via Add-AzureEndpoint (does the Add-AzureEndpoint add the endpoint to the network security group for the VM?) but is it feasible via the new azure portal?
There's a portproxy built into netsh that can do that for you without additional infrastructure: https://technet.microsoft.com/en-us/library/cc731068(v=ws.10).aspx#BKMK_1
netsh interface portproxy add v4tov4 listenport=81 connectport=80 connectaddress=127.0.0.1
If your VM runs Linux just use iptables.
iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 81
(i'm just winging the syntax for both commands here, don't copy paste but go through the documentation instead.)
If you need to use port-forwarding to map a unique external port to an internal port on your VM, use a load balancer and Network Address Translation (NAT) rules. For example, you may want to expose TCP port 8080 externally and have traffic directed to TCP port 80 on a VM. You can learn about creating an Internet-facing load balancer.
Reference:
https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-get-started-internet-arm-ps
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal
https://feedback.azure.com/forums/281804-azure-resource-manager/suggestions/13069704-allow-basic-port-forwarding-in-network-security-gr

how to configure security group in amazon EC2

I am new to this Aws security to deploy in amazon webservice.
When i restrict security groups with some IP address, my application runs dead slow or it may not run also, thats the reason i am getting connection time out when i try to call webservice which is deployed in aws. When i open the IP address restriction in Security groups it works fine.
How to configure my AWS using security groups. so that my application is accessible to only to some restricted networks.
Please help me put on this.
Below are the my security group details
INBOUND
Type Protocol Port range Source
MYSQL TCP 3306 X.X.X.X/X
SSH TCP 22 X.X.X.X/X
HTTP TCP 80 X.X.X.X/X
OUBOUND
Type Protocol Port range Source
MYSQL TCP 3306 0.0.0.0/0
SSH TCP 22 0.0.0.0/0
HTTP TCP 80 0.0.0.0/0
i am using hibernate for DB connection from my web application. But everytime i am getting connection timeout with the above security group. but if i remove the IP address restrictions it works fine.
Note: DB connection works fine from mysql workbench
<property name="hibernate.connection.url">jdbc:mysql://schemaname.amazonDBInsatnce:3306/test</property>
Security Groups will not "slow down" access to an Amazon EC2 instance. They are used to determine which ports are open to a given range of IP addresses. Either the traffic is allowed through, or it is not.
Security Groups can be defined for Inbound and Outbound traffic. By default, all Inbound traffic is denied and all Outbound traffic is permitted.
It is possible that your application is trying to access some external service and is timing-out, hence causing delays. Permitted all Outbound traffic is usually acceptable, so try that first and see if your application performs better.
Also, check the log files that your application is producing to see if any errors are being generated, which will give you a hint as to what might be happening.

AWS ubuntu instance can't reach the world

I created a new ubuntu instance in AWS, I can ssh connect to it successfully.
However when I try to install packages using this command, it won't work :
sudo apt-get install apache2
...
...
0% [Connecting to ap-southeast-2.ec2.archive.ubuntu.com (91.189.91.23)]^Cubuntu#ip-10-1-0-99:/etc$
This never moves forward !
I tried ping google.com.au, also no response.
Here is the VPC config of AWS:
Network ACL :
Outbound:
Rule # Type Protocol Port Range Destination Allow / Deny
100 ALL Traffic ALL ALL 0.0.0.0/0 ALLOW
* ALL Traffic ALL ALL 0.0.0.0/0 DENY
Inbound :
Rule # Type Protocol Port Range Source Allow / Deny
10 HTTP (80) TCP (6) 80 0.0.0.0/0 ALLOW
120 HTTPS (443) TCP (6) 443 0.0.0.0/0 ALLOW
140 SSH (22) TCP (6) 22 0.0.0.0/0 ALLOW
* ALL Traffic ALL ALL 0.0.0.0/0 DENY
security Group outbound settings :
Type Protocol Port Range Destination
ALL Traffic ALL ALL 0.0.0.0/0
Routing table setting:
Destination Target Status Propagated
10.1.0.0/24 local Active No
0.0.0.0/0 igw-cfe30caa Active No
What could be wrong here ?
EDIT: nslookup & dig command works fine!
Thanks !
Your inbound network ACL is only allowing traffic addressed to inbound TCP ports 22, 80, and 443. It doesn't allow the responses for your outbound requests, on your ephemeral ports.
$ cat /proc/sys/net/ipv4/ip_local_port_range
32768 61000
You need a rule in the network ACL to allow TCP 32768 through 61000... or, better, don't use the inbound network ACL at all -- set it back to the default, to allow all.
You almost certainly don't need to use network ACLs unless you have a particularly complex network configuration. The inbound rules in the security group are usually sufficient to control access to an instance. Inbound security group rules deny by default, and unlike Network ACLs, which are stateless packet filters, security groups are stateful, TCP session-aware.
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Security.html#VPC_Security_Comparison
Important: do not add the ephemeral port rule discussed above to the security group inbound rules. Since security groups are stateful, you only want to "allow" traffic in the direction where you want TCP sessions to be initiated. Responses to established TCP sessions are allowed automatically by security group rules, but not network ACL rules, because they're implemented differently.
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_ACLs.html
* ALL Traffic ALL ALL 0.0.0.0/0 DENY - Wrong
* ALL Traffic ALL ALL 0.0.0.0/0 Allow - Right
Please allow Outbound, if you want to connect to external servers like google.com
or even want to update- sudo apt-get update
You can allow the outbound using AWS front-end goto Security Groups -> Outbound
Make sure you select the right group for your AWS instance

Resources