-
1. Private vs Public IP (IPv4)
-
2. Private vs Public IP (IPv4) Example
-
3. Private vs Public IP (IPv4) Fundamental Differences
-
4. Elastic IPs
-
5. Private vs Public IP (IPv4) in AWS EC2 (Hands On)
-
6. 실습
-
6-1. use SSH with public IP address
-
6-2. Stop an Instance and restart it
-
6-3. Elastic IP 설정법 (Associate Elastic IP address)
-
6-4. Elastic IP 해제하는 법 (Diassociate Elastic IP address)
-
⭐ AWS 요금 계산기

1. Private vs Public IP (IPv4)
▶ Networking has two sorts of IPs. IPv4 and IPv6:
- IPv4 : 1.160.10.240
- IPv6: 3ffe: 1900:4545:3:200:f8ff:fe21:67cf
▶ AWS supports IPv4 and IPv6 both
▶ IPv4 is still the most common format used online.
▶ IPv6 is newer and solves problems for the Internet of Things (IoT).
▶ IPv4 allows for 3.7 billion different addresses in the public space.
▶ IPv4: [0-255].[0-255].[0-255]. [0-255].
2. Private vs Public IP (IPv4) Example

▶ every computer can talk to one another and talk to other server over internet
- when you have public IP you’re accessible over the internet.
- when you have private IP you’re only accessible within your private network.
사설 IP는 직접 인터넷에 연결될 수 없다. 하지만 NAT(Network Address Translation)라는 기술을 사용하면, 사설 네트워크에 있는 장치도 인터넷과 통신할 수 있다. 이 NAT 장치와 프록시 역할을 할 인터넷 게이트 웨이를 통해 인터넷에 연결된다.
예를 들어, 집에서 공유기를 사용할 때, 내 컴퓨터나 스마트폰은 사설 IP(예: 192.168.x.x)를 가지지만, 공유기는 공인 IP를 갖고 있다. 내가 인터넷에 접속하면, 공유기가 내 사설 IP를 공인 IP로 변환해서 외부 서버와 통신하도록 해 준다. 반대로, 외부 서버에서 응답이 오면 공유기가 다시 내 사설 IP로 변환해서 내 장치로 데이터를 전달하는 방식이다.
이렇게 하면 사설 네트워크 내부 장치는 직접 인터넷에 노출되지 않고도 인터넷을 사용할 수 있다. 서버도 마찬가지로, 만약 사설 IP를 가진 서버를 외부에서 접근 가능하게 만들고 싶다면, 포트 포워딩이나 VPN 같은 방법을 이용해야 한다.
3. Private vs Public IP (IPv4) Fundamental Differences
2-1. Public IP:
▶ Public IP means the machine can be identified on the internet (WWW)
▶ Must be unique across the whole web (not two machines can have the same public IP).
▶ Can be ego-located easily
2-2. Private IP:
▶ Private IP means the machine can only be identified on a private network only
▶ The IP must be unique across private network.
▶ BUT two different private networks (two companies) can have the same IPs.
▶ Machines connect to WWW using a NAT + internet gateway (a proxy)
▶ Only a specified range of IPs can be used as private IP.
4. Elastic IPs
▶ When you stop and then start an EC2 instance, it can charge its public IP.
▶ If you need to have a fixed public IP for your instance, you need an Elastic IP.
▶ An Elastic IP is a public IPv4 you own as long as you don't delete it.
▶ You can attach it to one instance at a time.
▶ With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. (but its quite rare to use this way.)
▶ Because You can only have 5 Elastic IP in your account (you can ask AWS to increase that).
⭐ Overall, try to avoid using Elastic IP:
- They often reflect poor architectural decisions
- Instead, use a random public IP and register a DNS name to it.
- Because much more control and expansion for us
- Or, as use a Load Balancer and don't use a public IP which is the best pattern you can have for AWS
5. Private vs Public IP (IPv4) in AWS EC2 (Hands On)
▶ By default, your EC2 machine comes with:
- A private IP for the internal AWS Network
- A public IP, for the WWW.
▶ When we are doing SSH into our EC2 machines:
- We can't use a private IP, because we are not in the same network.
- We only can use the public IP if you don't have VPN.
▶ If your machine is stopped and then started, the public IP can change.
6. 실습
6-1. use SSH with public IP address
ssh -i "your-key.pem" ec2-user@your-ec2-public-ip

Try using public ip
ssh -i .\EC2Tutorial.pem ec2-user@54.66.147.18

Try using public ip -> warning
ssh -i .\EC2Tutorial.pem ec2-user@172.31.7.68

왜? 사설 IPv4는 사설망에 속한다. 지금은 AWS 사설망에 연결되어 있지 않기 때문에 인터넷을 통해서만 AWS에 연결 가능하다. 공용 IP를 사용해야만 공용망에서 AWS에 액세스 할 수 있다. 공용망은 인터넷이 된다.
6-2. Stop an Instance and restart it



인스턴스를 재시작하면 공용 IP주소만 바뀐 것을 확인 해 볼 수 있다.
이전 공용IP로 SSH 재접속을 시도하면 접속이 되지 않는다.

바뀐 공용IP로 SSH 재접속을 시도하면 접속이 잘 된다.

6-3. Elastic IP 설정법 (Associate Elastic IP address)
인스턴스를 중지하고 싶은데 공용 IP 가 바뀌는 건 원하지 않을 때 사용하는 것이 Elastic IP (탄력적 IP) 이다.

Elastic IP 설정법
AWS 콘솔 → EC2 → Elastic IPs → Allocate Elastic IP → 생성된 IP 선택 → Associate Elastic IP → 대상 인스턴스 선택 → Associate 🚀






다시 Instance 탭으로 돌아가 보면 기존의 공용 IPv4 주소는 동일하지만, Elastic IP Address 필드에 공용 주소인 탄력적 IP주소가 표시된다. (내 경우, 한 번 인스턴스를 중지하고 재시작 했기 때문에 스크린샷에서는 새로운 공용 IP주소가 할당됨)

해당 Elastic IP 주소를 클릭하면 EC2의 Elastic IP 콘솔로 바로 이동하며 추가적인 정보를 얻을 수 있다.

이제 Elastic IP 주소로 SSH 를 시도하면 잘 연결되는 것을 볼 수 있다.
⭐ 그리고 인스턴스를 중지해도 공용 IP 주소가 그대로 남아 있는 것을 대시보드에서 확인 할 수 있다.
⭐ 인스턴스를 재시작 해도 Elastic IP 주소는 여전히 그대로 연결되어 있고 공용 IP 주소도 변경되지 않는다.


6-4. Elastic IP 해제하는 법 (Diassociate Elastic IP address)
AWS 콘솔 → EC2 → Elastic IPs → IP 선택 → Disassociate Elastic IP → 확인 후 Disassociate → Release Elastic IP address 🚀




⭐ Release Elastic IP address 까지 완료해야 요금이 부과되지 않음.
⭐ AWS 요금 계산기
https://aws.amazon.com/ko/vpc/pricing/
논리적으로 격리된 가상 네트워크 - Amazon VPC 요금 - Amazon Web Services
Amazon Virtual Private Cloud(VPC) 자체를 생성하고 사용하는 데 추가 비용은 없지만 사용량 기반 요금으로 선택적 VPC 기능에 대해 비용을 지불할 수 있습니다. AWS는 Amazon VPC에 대한 제어, 연결, 모니터링
aws.amazon.com
AWS 요금 계산기 → 퍼블릭 IPv4 주소 탭



⭐ AWS에서는 공용 IPv4를 사용하거나 사용하지 않거나 여부와 상관 없이, 공용 IPv4이든 탄력적 IPv4이든 관계 없이 모든 IPv4 에는 시간당 $0.005 요금이 부과된다.
⭐ 현재(2025.02.02) 환율을 반영해서 원화로 계산 해 보면, 하나의 IPv4 주소를 한 달 동안 할당받아서 사용한다고 가정해 볼 때, 시간 당 7.29원, 하루(24시간) 175원이 과금된다. 한달로 계산 해 보면 3.6 달러인 5,249원이 부과된다.
⭐ 결론은 뭐다? 인스턴스와 탄력적 IPS를 사용하지 않는다면 해당 비용을 지불하지 않도록 반드시 종료해야 한다는 것이다.
⭐ AWS 에서는 계정마다 매월 750 시간의 무료 공용 IPv4 주소가 제공된다. 따라서 EC2 인스턴스를 연습용으로 생성하는 경우 IPv4의 월 750 시간을 초과하지 않도록 실습이 끝나면 해당 인스턴스를 반드시 종료하도록 하자.
'AWS' 카테고리의 다른 글

1. Private vs Public IP (IPv4)
▶ Networking has two sorts of IPs. IPv4 and IPv6:
- IPv4 : 1.160.10.240
- IPv6: 3ffe: 1900:4545:3:200:f8ff:fe21:67cf
▶ AWS supports IPv4 and IPv6 both
▶ IPv4 is still the most common format used online.
▶ IPv6 is newer and solves problems for the Internet of Things (IoT).
▶ IPv4 allows for 3.7 billion different addresses in the public space.
▶ IPv4: [0-255].[0-255].[0-255]. [0-255].
2. Private vs Public IP (IPv4) Example

▶ every computer can talk to one another and talk to other server over internet
- when you have public IP you’re accessible over the internet.
- when you have private IP you’re only accessible within your private network.
사설 IP는 직접 인터넷에 연결될 수 없다. 하지만 NAT(Network Address Translation)라는 기술을 사용하면, 사설 네트워크에 있는 장치도 인터넷과 통신할 수 있다. 이 NAT 장치와 프록시 역할을 할 인터넷 게이트 웨이를 통해 인터넷에 연결된다.
예를 들어, 집에서 공유기를 사용할 때, 내 컴퓨터나 스마트폰은 사설 IP(예: 192.168.x.x)를 가지지만, 공유기는 공인 IP를 갖고 있다. 내가 인터넷에 접속하면, 공유기가 내 사설 IP를 공인 IP로 변환해서 외부 서버와 통신하도록 해 준다. 반대로, 외부 서버에서 응답이 오면 공유기가 다시 내 사설 IP로 변환해서 내 장치로 데이터를 전달하는 방식이다.
이렇게 하면 사설 네트워크 내부 장치는 직접 인터넷에 노출되지 않고도 인터넷을 사용할 수 있다. 서버도 마찬가지로, 만약 사설 IP를 가진 서버를 외부에서 접근 가능하게 만들고 싶다면, 포트 포워딩이나 VPN 같은 방법을 이용해야 한다.
3. Private vs Public IP (IPv4) Fundamental Differences
2-1. Public IP:
▶ Public IP means the machine can be identified on the internet (WWW)
▶ Must be unique across the whole web (not two machines can have the same public IP).
▶ Can be ego-located easily
2-2. Private IP:
▶ Private IP means the machine can only be identified on a private network only
▶ The IP must be unique across private network.
▶ BUT two different private networks (two companies) can have the same IPs.
▶ Machines connect to WWW using a NAT + internet gateway (a proxy)
▶ Only a specified range of IPs can be used as private IP.
4. Elastic IPs
▶ When you stop and then start an EC2 instance, it can charge its public IP.
▶ If you need to have a fixed public IP for your instance, you need an Elastic IP.
▶ An Elastic IP is a public IPv4 you own as long as you don't delete it.
▶ You can attach it to one instance at a time.
▶ With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. (but its quite rare to use this way.)
▶ Because You can only have 5 Elastic IP in your account (you can ask AWS to increase that).
⭐ Overall, try to avoid using Elastic IP:
- They often reflect poor architectural decisions
- Instead, use a random public IP and register a DNS name to it.
- Because much more control and expansion for us
- Or, as use a Load Balancer and don't use a public IP which is the best pattern you can have for AWS
5. Private vs Public IP (IPv4) in AWS EC2 (Hands On)
▶ By default, your EC2 machine comes with:
- A private IP for the internal AWS Network
- A public IP, for the WWW.
▶ When we are doing SSH into our EC2 machines:
- We can't use a private IP, because we are not in the same network.
- We only can use the public IP if you don't have VPN.
▶ If your machine is stopped and then started, the public IP can change.
6. 실습
6-1. use SSH with public IP address
ssh -i "your-key.pem" ec2-user@your-ec2-public-ip

Try using public ip
ssh -i .\EC2Tutorial.pem ec2-user@54.66.147.18

Try using public ip -> warning
ssh -i .\EC2Tutorial.pem ec2-user@172.31.7.68

왜? 사설 IPv4는 사설망에 속한다. 지금은 AWS 사설망에 연결되어 있지 않기 때문에 인터넷을 통해서만 AWS에 연결 가능하다. 공용 IP를 사용해야만 공용망에서 AWS에 액세스 할 수 있다. 공용망은 인터넷이 된다.
6-2. Stop an Instance and restart it



인스턴스를 재시작하면 공용 IP주소만 바뀐 것을 확인 해 볼 수 있다.
이전 공용IP로 SSH 재접속을 시도하면 접속이 되지 않는다.

바뀐 공용IP로 SSH 재접속을 시도하면 접속이 잘 된다.

6-3. Elastic IP 설정법 (Associate Elastic IP address)
인스턴스를 중지하고 싶은데 공용 IP 가 바뀌는 건 원하지 않을 때 사용하는 것이 Elastic IP (탄력적 IP) 이다.

Elastic IP 설정법
AWS 콘솔 → EC2 → Elastic IPs → Allocate Elastic IP → 생성된 IP 선택 → Associate Elastic IP → 대상 인스턴스 선택 → Associate 🚀






다시 Instance 탭으로 돌아가 보면 기존의 공용 IPv4 주소는 동일하지만, Elastic IP Address 필드에 공용 주소인 탄력적 IP주소가 표시된다. (내 경우, 한 번 인스턴스를 중지하고 재시작 했기 때문에 스크린샷에서는 새로운 공용 IP주소가 할당됨)

해당 Elastic IP 주소를 클릭하면 EC2의 Elastic IP 콘솔로 바로 이동하며 추가적인 정보를 얻을 수 있다.

이제 Elastic IP 주소로 SSH 를 시도하면 잘 연결되는 것을 볼 수 있다.
⭐ 그리고 인스턴스를 중지해도 공용 IP 주소가 그대로 남아 있는 것을 대시보드에서 확인 할 수 있다.
⭐ 인스턴스를 재시작 해도 Elastic IP 주소는 여전히 그대로 연결되어 있고 공용 IP 주소도 변경되지 않는다.


6-4. Elastic IP 해제하는 법 (Diassociate Elastic IP address)
AWS 콘솔 → EC2 → Elastic IPs → IP 선택 → Disassociate Elastic IP → 확인 후 Disassociate → Release Elastic IP address 🚀




⭐ Release Elastic IP address 까지 완료해야 요금이 부과되지 않음.
⭐ AWS 요금 계산기
https://aws.amazon.com/ko/vpc/pricing/
논리적으로 격리된 가상 네트워크 - Amazon VPC 요금 - Amazon Web Services
Amazon Virtual Private Cloud(VPC) 자체를 생성하고 사용하는 데 추가 비용은 없지만 사용량 기반 요금으로 선택적 VPC 기능에 대해 비용을 지불할 수 있습니다. AWS는 Amazon VPC에 대한 제어, 연결, 모니터링
aws.amazon.com
AWS 요금 계산기 → 퍼블릭 IPv4 주소 탭



⭐ AWS에서는 공용 IPv4를 사용하거나 사용하지 않거나 여부와 상관 없이, 공용 IPv4이든 탄력적 IPv4이든 관계 없이 모든 IPv4 에는 시간당 $0.005 요금이 부과된다.
⭐ 현재(2025.02.02) 환율을 반영해서 원화로 계산 해 보면, 하나의 IPv4 주소를 한 달 동안 할당받아서 사용한다고 가정해 볼 때, 시간 당 7.29원, 하루(24시간) 175원이 과금된다. 한달로 계산 해 보면 3.6 달러인 5,249원이 부과된다.
⭐ 결론은 뭐다? 인스턴스와 탄력적 IPS를 사용하지 않는다면 해당 비용을 지불하지 않도록 반드시 종료해야 한다는 것이다.
⭐ AWS 에서는 계정마다 매월 750 시간의 무료 공용 IPv4 주소가 제공된다. 따라서 EC2 인스턴스를 연습용으로 생성하는 경우 IPv4의 월 750 시간을 초과하지 않도록 실습이 끝나면 해당 인스턴스를 반드시 종료하도록 하자.