If we are not getting connected to our instance, then there must be some below-mentioned issues:
- Username and password issue
- IGW Mapping
- Ports enable or disable on Security Group
- VNIC (Virtual Network Interface Card)
- OS Firewall
- RDP Service
Troubleshoot to get access when the primary NIC card of EC2 instance is misconfigured.
Steps we need to follow:
- Create a VPC
- Launch a Windows instance in the VPC, created by you
- Login to Web Server and disable NIC card
- Create an ENI in the same AZ
- Attach NIC card to the instance
- Provide an Elastic IP to NIC card
- Login to the web server instance using Elastic IP
- Enable primary NIC card
- Detach secondary NIC card from the web server
- Login to the web server instance using the previous IP address
Fig: Recover Instance When NIC Card Is Misconfigured |
Step 1: Create a VPC named 'webshack-vpc':
Follow the below-mentioned link to create a VPC:
Step 2: Launch a Windows instance in the VPC, created by you:
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Launch Instance ➔ Select 'Free tier only' ➔ Select 'Microsoft Windows Server 2008 R2 Base' AMI ➔ Next ➔ In Configure Instance Details: Select number of instances: '1'➔ Select Network: 'webshack-vpc' ➔ Subnet: select public subnet ➔ Next ➔ Next ➔ Click to add a Name tag ➔ Name: webshack-web-server ➔ Next ➔ Review and Launch ➔ Launch ➔ Choose an existing key pair or create a new one ➔ Launch Instances ➔ Vie Instances.
In the description of this Web Server, in the Network interfaces section, we can see that there is only one NIC card named 'eth0'.
Decrypt password and save in a safe place.
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select Instance 'webshack-web-server' ➔ Actions ➔ Get Windows Password ➔ Browse ➔ Provide Private Key ➔ Decrypt Password ➔ Copy password to notepad and save it to a safe place.
Step 3: Login to Web Server and disable NIC card:
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select Instance ➔ From Description copy Public IP ➔ Go to Run ➔ type 'mstsc' ➔ paste Public IP ➔ Connect ➔ Username: Administrator ➔ Password: <paste from notepad> ➔ Connect.
Now, we will disable the primary NIC card for the practical purpose:
In this RDP connection go to Run ➔ type command 'control.exe /name Microsoft.NetworkandSharingCenter' ➔ Change Adapter Settings ➔ Right Click on Local Area Connection ➔ Disable ➔ Close RDP connection.
Now we are not able to do any work on this instance and we need to close this RDP connection.
[1] Try to ping to the Web Server:
Go to Security Group and verify icmp service is running or not:
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select instance named webshack-web-server ➔ In the Description, navigate to Security Groups ➔ Click on Inbound Rules ➔ We can see port for icmp is not open. So, first, we need to open it.
Click on the name of your SG just before View Inbound Rules ➔ Edit Inbound Rules ➔ Type: All ICMP-IPv4 ➔ Source: provide IP or click on Anywhere ➔ Save.
Now try to ping Web Server. There is some network error, means, the network card which is providing me access is misconfigured.
[2] From AWS console, in status check we can see, one status check is failed.
[3] Now, verify the Instance Screenshot:
One more possibility we could have that there could be a blue dump error. We can verify this in Screenshot:
Select instance ➔ Actions ➔ Instance Settings ➔ Get instance Screenshot.
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select Instance ➔ Actions ➔ Instance Settings ➔ Get Instance Screenshot.
This will display the screen of the instance. If this is running, it means the instance is running on the AWS console, otherwise, there could be a blue screen or any other error message.
[4] Check System logs:
To get system logs, we need to navigate to:
Select instance ➔ Actions ➔ Instance Settings ➔ Get System Log.
In logs, we can see Windows is ready to use.
[4] Try to access RDP session after reboot.
As a reboot just restarts the operating system services. So, this thing is not going to help us.
[5] Try to perform Stop and Start.
If we are not using an Elastic IP, then our IP would be changed. So we need to access by using updated IP. Again, this is not going to help us.
We cannot detach the primary interface card. So, we will create a secondary Network Interface Card. This new card inside AWS is known as Elastic Network Interface (ENI). We say this elastic because this NIC card can detach and attach to other instances as well, but one time at an instance only. One side of this card will attach to the public subnet and another side will connect to the Web server instance. As we connect NIC card to subnet, this will provide an IP to this NIC card.
Hurray!!!
We are through.
Very soon, this will be in the available state.
Yaayyyy!
Getting Access.
TROUBLESHOOTING:
Suppose, we are not aware of what the issue is, then we need to do some troubleshooting:[1] Try to ping to the Web Server:
Go to Security Group and verify icmp service is running or not:
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select instance named webshack-web-server ➔ In the Description, navigate to Security Groups ➔ Click on Inbound Rules ➔ We can see port for icmp is not open. So, first, we need to open it.
Click on the name of your SG just before View Inbound Rules ➔ Edit Inbound Rules ➔ Type: All ICMP-IPv4 ➔ Source: provide IP or click on Anywhere ➔ Save.
Now try to ping Web Server. There is some network error, means, the network card which is providing me access is misconfigured.
[2] From AWS console, in status check we can see, one status check is failed.
Status Check fails due to two reasons: 1. System Status Checks and 2. Instance Status Checks.
We can verify what is the exact reason from Status Check:
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select instances ➔ In bottom click on Status Check:
Here, we can see that the Instance Status Check is failed.
[3] Now, verify the Instance Screenshot:
One more possibility we could have that there could be a blue dump error. We can verify this in Screenshot:
Select instance ➔ Actions ➔ Instance Settings ➔ Get instance Screenshot.
AWS ➔ Services ➔ EC2 ➔ Instances ➔ Select Instance ➔ Actions ➔ Instance Settings ➔ Get Instance Screenshot.
[4] Check System logs:
To get system logs, we need to navigate to:
Select instance ➔ Actions ➔ Instance Settings ➔ Get System Log.
In logs, we can see Windows is ready to use.
[4] Try to access RDP session after reboot.
As a reboot just restarts the operating system services. So, this thing is not going to help us.
[5] Try to perform Stop and Start.
If we are not using an Elastic IP, then our IP would be changed. So we need to access by using updated IP. Again, this is not going to help us.
There are two ways to access our Web Server:
- Using secondary ENI (Elastic Network Interface)
- Detach and Attach
Using Secondary ENI:
We cannot detach the primary interface card. So, we will create a secondary Network Interface Card. This new card inside AWS is known as Elastic Network Interface (ENI). We say this elastic because this NIC card can detach and attach to other instances as well, but one time at an instance only. One side of this card will attach to the public subnet and another side will connect to the Web server instance. As we connect NIC card to subnet, this will provide an IP to this NIC card.
Now, we can see there are two ways to reach the Web-server instance. The first way is via using primary NIC card, which is disabled and the second way is via using a secondary NIC card. Traffic cannot pass from your subnet to an instance until it is passing through a Security Group. So, we need to provide a Security Group to secondary NIC card. We can create a new SG or can use an existing one. Also, we need to provide an Elastic IP to the secondary NIC card, because this only has a private IP. So, we need to provide two things to this secondary NIC card: 1) a Security Group and 2) an Elastic IP.
Step 4: Create an ENI in the same AZ:
AWS ➔ Services ➔ EC2 ➔ Network Interfaces ➔ Create Network Interface ➔ Description: eni-nic2 ➔ Subnet: <Select public subnet of your VPC> ➔ IPv4 Private IP: Auto-assign (use custom, if specifically want to provide an IP from our Subnet) ➔ Elastic Fabric Adapter: do not tick because we are not going to create a "Fiber Channel Network Card" ➔ Security groups: select one or more SGs from list ➔ Create.
Very soon we can see that it is in the available state.
Step 5: Attach NIC card to the instance:
AWS ➔ Services ➔ EC2 ➔ Network Interfaces ➔ Select NIC card created by you ➔ Attach ➔ Instance ID: <select webshack-web-server instance from drop-down list> ➔ Attach.
Now, this card is attached to our web server instance, which we can verify in the description by selecting the web server instance from EC2 service. There would be two network cards; eth0 and eth1.
Step 6: Provide an Elastic IP to NIC card:
Allocate an Elastic IP:
AWS ➔ Services ➔ EC2 ➔ Elastic IPs ➔ Allocate new address ➔ IPv4 address pool: Amazon pool ➔ Allocate ➔ Close.
Associate to NIC card:
Select Elastic IP ➔ Actions ➔ Associate address ➔ Resource type: Network Interface ➔ Network Interface: <select 'eni-nic2' NIC card> ➔ Private IP: <select from drop-down list> ➔ Reassociation: <if we have any elastic IP, for our web server, then we can provide here> ➔ Associate ➔ Close.
Step 7: Login to the web server instance using Elastic IP:
AWS ➔ Services ➔ EC2 ➔ Select webshack-web-server instance ➔ Copy Elastic IP from the description ➔ go to Run ➔ type 'mstsc' ➔ paste copied Elastic IP ➔ Connect ➔ Username: administrator ➔ Paste password from notepad ➔ Connect.
Hurray!!!
We are through.
Step 8: Enable primary NIC card:
In this RDP connection go to Run ➔ type command 'control.exe /name Microsoft.NetworkandSharingCenter' ➔ Change Adapter Settings ➔ Right Click on disabled Local Area Connection ➔ Enable (OR just double click to enable that LAN connection) ➔ Close RDP connection.
Step 9: Detach secondary NIC card from the web server:
AWS ➔ Services ➔ EC2 ➔ Network Interfaces ➔ Select NIC card named 'eni-nic2' ➔ Detach ➔ Yes, Detach.Very soon, this will be in the available state.
Step 10: Login to the web server instance using the previous IP address:
AWS ➔ Services ➔ EC2 ➔ Select webshack-web-server instance ➔ Copy previous public IP from description ➔ go to Run ➔ type 'mstsc' ➔ paste copied IP ➔ Connect ➔ Username: administrator ➔ password: paste from notepad ➔ Connect.Yaayyyy!
Getting Access.
No comments:
Post a Comment