Assign static IP to EC2 instance

GuruAtWork
3 min readMar 27, 2018

--

Tired of your EC2 instance url changing every time you start / stop your instance?

Read on to assign a static IP to your EC2 instance.

In console, EC2. Select your deep learning instance and record the instance ID.

Select Elastic IP’s from the EC2 menu. Then “Allocate new address.”

Allocate.

Close

From “Actions” > “Associate Address”

From the drop down “Instances” list, select the EC2 instance to map the static IP to.

Associate

Close

When in the menu section for ‘Elastic IP’ can see our elastic IP has been created.

Changing to the EC2 instance page and selecting our instance for deep learning, we can see the static IP has been assigned to this EC2 instance.

now instead of ssh’ing to the “Public DNS (IPv4)” address
(of form ec2–52–38–211–125.us-west-2.compute.amazonaws.com)

we can ssh to the “IPv4 Public IP” — in this case it is 52.38.211.125

Because it is an elastic IP, this appears as a clickable link (takes to the elastic IP page)

so now our ssh command to connect to our server looks like this.

ssh -i /path/to/your/password-file.pem ec2-user@52.38.211.125

or if using ssh tunnelling

ssh -i /path/to/your/password-file.pem -L 9999:127.0.0.1:8888 ec2-user@52.38.211.125

NB: you may need to shutdown and restart your EC2 instance for mapping to the new IP number to take effect, or wait a couple of minutes.

Now when restarting your EC2 instance, have one less thing to worry about.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — -

NB: if your EC2 security rules are set to ‘my ip’ then check your ‘my ip’ has been updated to your current ip.

--

--

GuruAtWork
GuruAtWork

Written by GuruAtWork

Machine Learning, data analysis and Artificial Intelligence developer.

No responses yet