AWS‎ > ‎

VPC

インフラエンジニアに贈るAmazon VPC入門 #1 概要とルーティング | Developers.IO

"EC2-Classic" と "EC2-VPC"。


EIP も別立て。ここでは "Standard"  EIP と "vnc-~, eni-~" の区別になる。

[root@ip-10-0-0-45 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 06:44:E5:FF:C4:32
          inet addr:10.0.0.45  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::444:e5ff:feff:c432/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3300 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2516 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3061107 (2.9 MiB)  TX bytes:213729 (208.7 KiB)
          Interrupt:25

[root@ip-10-0-0-45 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.1        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.169.254 0.0.0.0         255.255.255.255 UH    0      0        0 eth0

[root@ip-10-0-0-45 ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search ap-northeast-1.compute.internal
nameserver 10.0.0.2

[root@ip-10-0-0-45 ~]# cat /var/lib/dhclient/dhclient-eth0.leases
lease {
  interface "eth0";
  fixed-address 10.0.0.45;
  option subnet-mask 255.255.255.0;
  option routers 10.0.0.1;
  option dhcp-lease-time 3600;
  option dhcp-message-type 5;
  option domain-name-servers 10.0.0.2;
  option dhcp-server-identifier 10.0.0.1;
  option interface-mtu 1500;
  option broadcast-address 10.0.0.255;
  option host-name "ip-10-0-0-45";
  option domain-name "ap-northeast-1.compute.internal";
  renew 4 2013/04/18 06:08:49;
  rebind 4 2013/04/18 06:32:43;
  expire 4 2013/04/18 06:40:13;
}

ごく普通の、NAT (マスカレード NAPT) の内側にあるサブネット上のノードのネットワーク設定に見える。10.0.0.1 が(あるいは、その上の方のどこかで)、Elastic IP が登録されていれば、外へ出られるようになるのだろう。 ∥ ネットワークアドレス変換 - Wikipedia

オール 0 と、オール 1 が使えないのは当たり前として、1 番目はゲートウェイと DHCP サーバ、2 番目は DNS(ただし、1 つ目のサブネットの 2 番目)だ。DNS は VPC に一つ。なぜならば、ルータ経由でサブネット間は通信できるので、DNS へは届く。3 番目は不明だが、今後への予約だろう。

よそのサブネットへの通信も、10.0.0.1 経由。

「Elastic IP はすべて NAT」←ここがピンとこなかった理由か。

以下、EC2-Classic。こちらは、適当に 8 ビットサブネットを切って、ゲートウェイの上で良い具合にルーティング。これ、効率悪そうだな。

[ec2-user@BAT-I3-DEV ~]$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 12:31:50:02:BE:84
          inet addr:10.158.189.110  Bcast:10.158.189.255  Mask:255.255.255.0
          inet6 addr: fe80::1031:50ff:fe02:be84/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37817 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39056 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4140286 (3.9 MiB)  TX bytes:2351440 (2.2 MiB)
          Interrupt:34

[ec2-user@BAT-I3-DEV ~]$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.158.189.1    0.0.0.0         UG    0      0        0 eth0
10.158.189.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0

[ec2-user@BAT-I3-DEV ~]$ cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search ap-northeast-1.compute.internal
nameserver 172.16.0.23

EC2-Classic では、ユーザには 8 ビット(10.~)のプライベートネットワークを使わせ、その上に 12 ビット(172.16.~)のプライベートネットワークがある構成。

さて。
Comments