AWS yum 不适用于私有子网(适用于公共子网)

Bur*_*ome 7 nat yum amazon-web-services amazon-vpc

我有一个带有私有子网和公共子网的 VPC - 每个子网都包含一个相同构建的 RHEL7 服务器。我相信 VPC 设置正确(见下文)。但是,公共服务器可以使用 yum,而私有服务器则不能。私人收到错误...

$ yum search apache
Failed to set locale, defaulting to C
Loaded plugins: amazon-id, rhui-lb
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/product/rhui-client-config-server-7.crt
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/rhui-client-config-server-7.key
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/product/content-rhel7.crt
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/content-rhel7.key
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/product/content-rhel7.crt
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/content-rhel7.key
Could not contact CDS load balancer rhui2-cds01.us-east-1.aws.ce.redhat.com, trying others.

Could not contact any CDS load balancers: rhui2-cds01.us-east-1.aws.ce.redhat.com, rhui2-cds02.us-east-1.aws.ce.redhat.com. 
Run Code Online (Sandbox Code Playgroud)

网络

我有一个使用 RHEL7 AMI 的 AWS VPC。

  • 我有一个 VPC 10.0.0.0/16
  • 我有一个公共子网 10.0.0.0/24
  • 我有一个私有子网 10.0.1.0/24
  • 我有一个互联网网关
  • 我有一个 NAT
  • 主要的主要路由表指向 NAT

    Destination Target Status Propagated
    10.0.0.0/16 local Active No
    0.0.0.0/0 eni-xxxxxxxx / i-xxxxxxxx Active No
    
    Run Code Online (Sandbox Code Playgroud)
  • 私有子网与主路由表相关联

  • 第二个(不是主要的)路由表指向网关

    Destination Target Status Propagated 
    10.0.0.0/16 local Active No
    0.0.0.0/0 igw-xxxxxxxx Active No
    
    Run Code Online (Sandbox Code Playgroud)
  • 公共子网与此路由表相关联

  • 所有安全组都对故障排除敞开大门
  • 我已启用 NAT 进行转发(有时会伪装...见下文)

    sysctl -q -w net.ipv4.ip_forward=1 net.ipv4.conf.eth0.send_redirects=0
    
    PRIVATE_SUBNETS="10.0.1.0/24"
    for SUBNET in $PRIVATE_SUBNETS; do
        iptables -t nat -C POSTROUTING -o eth0 -s $SUBNET -j MASQUERADE 2> /dev/null || iptables -t nat -A POSTROUTING -o eth0 -s $SUBNET -j MASQUERADE
    done
    
    Run Code Online (Sandbox Code Playgroud)
  • 公有和私有子网中有一台服务器

  • 两者都是从同一个 RHEL7 AMI 构建的。

测试

  • 在这一切期间,我是根...
  • 我曾尝试设置sslverify=0/etc/yum.repos.d/redhat-rhui.repo/etc/yum.repos.d/redhat-rhui-client-config.repo,然后执行yum clean all。它没有解决问题。
  • 私网和公网的服务器都可以ping通8.8.8.8
  • 两台服务器都能够将名称解析为 IP,包括 yum 存储库的名称。
  • 私有服务器和公共服务器似乎都可以看到并触摸到以下 RPM:

    $ rpm -Uvh ftp://ftp.pbone.net/mirror/ftp.sourceforge.net/pub/sourceforge/o/os/osolinux/update/RPMS.e/elinks-0.12-0.32.pre5mgc30.x86_64.rpm
    Retrieving ftp://ftp.pbone.net/mirror/ftp.sourceforge.net/pub/sourceforge/o/os/osolinux/update/RPMS.e/elinks-0.12-0.32.pre5mgc30.x86_64.rpm
    error: Failed dependencies:
        libgc.so.1()(64bit) is needed by elinks-0.12-0.32.pre5mgc30.x86_64
        libgpm.so.2()(64bit) is needed by elinks-0.12-0.32.pre5mgc30.x86_64
        libmozjs185.so.1.0()(64bit) is needed by elinks-0.12-0.32.pre5mgc30.x86_64
        libnss_compat_ossl.so.0()(64bit) is needed by elinks-0.12-0.32.pre5mgc30.x86_64
    
    Run Code Online (Sandbox Code Playgroud)

如果我尝试在私有服务器上加载新存储库,则会出现超时...

$ rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
Retrieving http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

curl: (7) Failed connect to pkgs.repoforge.org:80; Connection timed out
error: skipping http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm - transfer failed
Run Code Online (Sandbox Code Playgroud)
  • 打开或关闭伪装似乎没有区别。

=== 在这里发布其他人的编辑 ===
嗨迈克尔。感谢您的评论。

我确实使用了 traceroute 并看到数据包从有问题的专用服务器到达 NAT。我还看到离开服务器的数据包应该是转发的数据包。就是这样。而已。

我的印象是请求被存储库拒绝,因为 ping 和 Internet 远程 rpms 似乎工作......但我不知道为什么。我通过打开和关闭伪装得到相同的结果。

NAT 服务器是在创建 VPC 的过程中自动构建的。安全组是使用“场景 2”页面创建的……但目前是完全开放的。

Seb*_*ruz 2

在与问题中描述的情况非常相似的情况下,我能够通过将配置添加proxy/etc/yum.conf.

像这样:

echo "proxy=http://my.proxy.internal:3128/" >> /etc/yum.conf
Run Code Online (Sandbox Code Playgroud)