[EC2] Why no Public IPv4, but can go to the Internet?
ec2-user@ip-10-16-60-224 ~$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default ip-10-16-48-1.a 0.0.0.0 UG 0 0 0 eth0
10.16.48.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
instance-data.a 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
ec2-user@ip-10-16-60-224 ~$ ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP group default qlen 1000
link/ether 06:bf:f7:bd:36:52 brd ff:ff:ff:ff:ff:ff
inet 10.16.60.224/20 brd 10.16.63.255 scope global dynamic eth0
valid_lft 3109sec preferred_lft 3109sec
inet6 2406:da18:e26:a403:977:a307:147f:a413/128 scope global dynamic
valid_lft 437sec preferred_lft 127sec
inet6 fe80::4bf:f7ff:febd:3652/64 scope link
valid_lft forever preferred_lft forever
ec2-user@ip-10-16-60-224 ~$ traceroute 1.1.1.1
traceroute to 1.1.1.1 (1.1.1.1), 30 hops max, 60 byte packets
1 ec2-18-141-171-15.ap-southeast-1.compute.amazonaws.com (18.141.171.15) 8.342 ms ec2-175-41-128-177.ap-southeast-1.compute.amazonaws.com (175.41.128.177) 7.433 ms ec2-18-141-171-1.ap-southeast-1.compute.amazonaws.com (18.141.171.1) 19.818 ms
2 100.65.32.224 (100.65.32.224) 3.347 ms 100.65.33.240 (100.65.33.240) 13.093 ms 100.65.34.176 (100.65.34.176) 23.462 ms
3 100.66.16.74 (100.66.16.74) 7.746 ms 100.66.16.202 (100.66.16.202) 7.773 ms 100.66.16.38 (100.66.16.38) 3.531 ms
4 100.66.19.190 (100.66.19.190) 5.059 ms 100.66.19.180 (100.66.19.180) 7.843 ms 100.66.18.228 (100.66.18.228) 16.918 ms
5 100.66.7.249 (100.66.7.249) 12.221 ms 100.66.6.247 (100.66.6.247) 10.830 ms 100.66.6.113 (100.66.6.113) 21.846 ms
6 100.66.4.89 (100.66.4.89) 80.326 ms 100.66.4.159 (100.66.4.159) 18.434 ms 100.66.4.9 (100.66.4.9) 11.122 ms
7 100.65.11.1 (100.65.11.1) 0.604 ms 100.65.9.97 (100.65.9.97) 0.322 ms 0.358 ms
8 203.83.223.30 (203.83.223.30) 1.243 ms 150.222.108.77 (150.222.108.77) 1.575 ms 52.93.10.76 (52.93.10.76) 1.316 ms
9 52.93.8.160 (52.93.8.160) 2.001 ms 150.222.108.66 (150.222.108.66) 1.870 ms 150.222.108.68 (150.222.108.68) 2.114 ms
10 52.93.11.127 (52.93.11.127) 1.386 ms 52.93.11.115 (52.93.11.115) 1.350 ms 52.93.11.125 (52.93.11.125) 1.338 ms
11 99.83.90.55 (99.83.90.55) 4.053 ms 4.046 ms 99.83.68.227 (99.83.68.227) 4.297 ms
12 172.70.140.3 (172.70.140.3) 2.673 ms * 172.70.144.5 (172.70.144.5) 2.274 ms
13 one.one.one.one (1.1.1.1) 1.755 ms 1.795 ms 1.771 ms
Thank you very much.
An EC2 instance only has a local network interface and knows nothing about its public IP; that public IP is set up in the Internet Gateway (IGW)'s NAT table, mapped to the instance's local IP address. If the instance is in a public subnet with routing to the IGW then it will have public access. Of course it could also be set up in a private/NAT subnet with outbound internet access via routing to a NAT Gateway or NAT Instance.
Relevant questions
Can't ssh to EC2 after assigning an additional public ip(elastic ip)
asked 5 months agoPublic ip address connectivity in AWS
asked 3 months agoAWS Nitro Enclave instance does not have public ipv4 address
asked a month ago[EC2] Why no Public IPv4, but can go to the Internet?
asked a month agoEc2 Not connecting to Internet
Accepted Answerasked 2 months agoVPN client endpoint interfaces have public IP, how to remove?
Accepted Answerasked 2 years agoEC2 instance in private subnet shows IPv4 address of NAT instance
asked 3 years agocloud-init not setting default route to NAT Gateway
asked 2 years agoNetwork transfer costs though NAT GW
Accepted Answerasked a year agoEC2 VM doesn't have Internet connection
asked 3 years ago
I didn't create any NAT GW yet, shouldn't it access to the internet? Thank you very much.