我正在尝试在Amazon AWS中configurationNAT。
所以我有两个私有IP的EC2: 10.0.0.49和10.0.0.48 。 ( 10.0.0.0/24networking)节点在一个VPC中。 我可以从10.0.0.48 ping 10.0.0.49。
弹性IP 52.88.240.171指向10.0.0.49。
据我所知,我不能直接指向Elastic IP到节点。 因此,我正在尝试这种手动https://serverfault.com/a/568478/192282
在10.0.0.49:
sudo sysctl -q -w net.ipv4.ip_forward=1 net.ipv4.conf.eth0.send_redirects=0 sudo iptables -t nat -A POSTROUTING -o eth0 -s 10.0.0.0/24 -j MASQUERADE sudo iptables -L -n -v -x -t nat Chain PREROUTING (policy ACCEPT 6 packets, 457 bytes) pkts bytes target prot opt in out source destination Chain INPUT (policy ACCEPT 6 packets, 457 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 32 packets, 2732 bytes) pkts bytes target prot opt in out source destination Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 32 2732 MASQUERADE all -- * eth0 10.0.0.0/24 0.0.0.0/0 [root@ip-10-0-0-49 ~]#
在10.0.0.48上:
sudo route del default sudo route add default gw 10.0.0.49 sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.0.49 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
在Amazon AWS的“安全组”中,为每个EC2启用所有入站和出站stream量。
但是我仍然无法访问互联网10.0.0.48(节点没有Elastic IP)。 也许我错过了水手控制台? 什么可能是错的?
UPD。 每个EC2主机的resolv.conf:
[root@ip-10-0-0-49 ~]# cat /etc/resolv.conf ; generated by /sbin/dhclient-script search us-west-2.compute.internal nameserver 10.0.0.2 [ec2-user@ip-10-0-0-48 ~]$ cat /etc/resolv.conf ; generated by /sbin/dhclient-script search us-west-2.compute.internal nameserver 10.0.0.2
这是AWS控制台中“源/目标检查”的问题。 谢谢你,@ matt-houser!