IceVitaLemon
V2EX  ›  问与答

三台云主机加一个公网弹性 IP 的网络搭建问题

  •  
  •   IceVitaLemon · Apr 10, 2023 · 1973 views
    This topic created in 1304 days ago, the information mentioned may be changed or developed.
    有三台云主机 M1\M2\M3 和一个弹性 IP ,怎么样才能让三台云主机都能访问公网呢?
    现在 IP 绑定在 M1 上面,但是 M2\M3 都访问不了公网。
    尝试过将 M2\M3 的网关设置成 M1 ,ping 百度在 M1 上 tcpdump 能抓到返回的包,但是 M2\M3 上面却没收到。不太清除什么问题。
    13 replies  •  2023-04-10 20:33:47 +08:00
    yghack
    yghack
    Apr 10, 2023
    1
    iptables 和 ip 转发配置好了?
    我们一直在这么用,一个 vpc 只有一个进出口 ip
    IceVitaLemon
    IceVitaLemon
    OP
    Apr 10, 2023
    2
    @yghack ip 转发配置好了,但是 iptables 不太清除需要配置什么。第一次捣鼓麻烦指教一下
    opengps
    opengps
    Apr 10, 2023
    3
    vpc 专用网络结构,可以实现这种统一出口的效果,原理约等于一个路由器下挂着多台设备对外访问
    IceVitaLemon
    IceVitaLemon
    OP
    Apr 10, 2023
    4
    @opengps 感谢,还是要多买一个 NAT 网关才行
    40EaE5uJO3Xt1VVa
    40EaE5uJO3Xt1VVa
    Apr 10, 2023
    5
    iptables 转发 就可以实现你的需求。只是解决办法还有遇到的问题三言两语说不清,你看看这块吧。
    proxytoworld
    proxytoworld
    Apr 10, 2023
    6
    得开启路由功能把
    sarices
    sarices
    Apr 10, 2023
    7
    m1 没有网关功能吧,试试搞个透明网关
    yaoyaomoe
    yaoyaomoe
    Apr 10, 2023 via iPhone
    8
    m1 没有 forward 请求……
    不需要单独购买 nat 网关
    你把 m1 当成网关就行了……
    随便搜索了一个旧的东西可以参考
    https://medium.com/@exesse/how-to-make-a-simple-router-gateway-from-ubuntu-server-18-04-lts-fd40b7bfec9
    unnamedhao
    unnamedhao
    Apr 10, 2023
    9
    理论上网关设置好,路由就自动设置好了,网关加上 ip 转发,然后就完成了
    defunct9
    defunct9
    Apr 10, 2023
    10
    开 ssh ,让我上去配
    goodryb
    goodryb
    Apr 10, 2023
    11
    印象中应该是 M1 设置好路由转发,然后在 VPC 的路由器下的路由表中添加一条 default 路由指向 M1 即可

    不同云厂商可能设置略有不同
    ik
    ik
    Apr 10, 2023 via iPhone
    12
    华为云的话直接用 iptables 配就行

    阿里云需要在 vpc 里面写自定义网关(理论,售后工单提供的方案,没实践过,自己是在内网拨 vpn ,推送默认路由实现的)
    akira
    akira
    Apr 10, 2023
    13
    阿里云的话 是配置下 dnat snet 就好了,或者你工单问一下。

    一般我习惯是做 2 个 ip 入口,一个管理 一个业务。 出口再 单独要 1 个 ip
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1584 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 23:07 · PVG 07:07 · LAX 15:07 · JFK 18:07
    ♥ Do have faith in what you're doing.