【问题标题】:Rails server not visible on network after Yosemite upgrade to 10.10.3 on WiFi优胜美地在 WiFi 上升级到 10.10.3 后,Rails 服务器在网络上不可见
【发布时间】:2015-06-19 17:05:12
【问题描述】:

我的机器上运行着一个可用于本地网络的 Rails 服务器,一切正常,在将操作系统更新到 10.10 后,我可以使用本地设备 192.168.xx:3000 从其他设备访问我的服务器。 3(我以前有 Yosemite,但我不记得版本)这不再有效,我的防火墙被禁用,我尝试使用“rails server --binding = 0.0.0.0”启动服务器,但它仍然没有对网络上的其他设备可见。

编辑:我现在看到问题仅在于我使用 WIFI 时,如果我通过迅雷和以太网连接一切正常

有人知道如何解决这个问题吗?

谢谢!

【问题讨论】:

  • 可能无线在不同的子网上?即使它们在同一个网络上,您的机器每个接口也会有不同的 IP

标签: ruby-on-rails macos networking osx-yosemite


【解决方案1】:

问题似乎是无线路由器需要重新启动,在我尝试了一切之后,重新启动了 mac(运行服务器的那个)和我尝试连接的设备,我重新启动了路由器,如果它开始起作用的一些奇怪原因。

也许这些信息会对其他人有所帮助

【讨论】:

    【解决方案2】:

    再次工作!

    MacOS Yosemite 完全删除了 ipfw (IP-Firewall),现在只使用 pf (Packet Filter)。所以所有我们习惯的默认转发都没有了!

    为了让它再次工作,我使用了这个很棒的教程:来自 Sal FerrarelloMac pfctl Port Forwarding 并对其进行了更改以支持常用的 Rails 服务器。把它放在终端和.. 它再次工作!

    成功的过程(终端命令)

    激活 Rails 端口转发 (如果需要,添加更多)

    echo "
    rdr pass inet proto tcp from any to any port 3000 -> 127.0.0.1 port 3000
    rdr pass inet proto tcp from any to any port 3001 -> 127.0.0.1 port 3001
    rdr pass inet proto tcp from any to any port 3002 -> 127.0.0.1 port 3002
    rdr pass inet proto tcp from any to any port 3003 -> 127.0.0.1 port 3003
    rdr pass inet proto tcp from any to any port 3004 -> 127.0.0.1 port 3004
    rdr pass inet proto tcp from any to any port 3005 -> 127.0.0.1 port 3005
    rdr pass inet proto tcp from any to any port 3006 -> 127.0.0.1 port 3006
    rdr pass inet proto tcp from any to any port 3007 -> 127.0.0.1 port 3007
    rdr pass inet proto tcp from any to any port 3008 -> 127.0.0.1 port 3008
    rdr pass inet proto tcp from any to any port 3009 -> 127.0.0.1 port 3009
    rdr pass inet proto tcp from any to any port 3010 -> 127.0.0.1 port 3010
    rdr pass inet proto tcp from any to any port 4242 -> 127.0.0.1 port 4242
    rdr pass inet proto tcp from any to any port 9292 -> 127.0.0.1 port 9292
    " | sudo pfctl -ef -
    

    显示当前转发规则 (检查哪些规则有效)

    sudo pfctl -s nat
    

    停止端口转发 (小心!再次停止!)

    sudo pfctl -F all -f /etc/pf.conf
    

    .. 我仍然想念 SnowLeopard,如今开发人员的生活是如此轻松 ..


    更新:

    这仅在下次重新启动之前有效。我尝试了很多让它自动工作,我更改了 /etc/pf.conf,我更改了 pf 守护进程.. 但没有任何效果!

    所以我制作了自己的守护程序,它只在启动时加载我的开发端口,效果很好!

    /Library/LaunchDaemons/dev.development.servers.plist

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
            <key>Label</key>
            <string>dev.development.servers</string>
            <key>ProgramArguments</key>
            <array>
                    <string>/bin/sh</string>
                    <string>-c</string>
                    <string>
                      echo "
                      rdr pass inet proto tcp from any to any port 3000 -> 127.0.0.1 port 3000
                      rdr pass inet proto tcp from any to any port 3001 -> 127.0.0.1 port 3001
                      rdr pass inet proto tcp from any to any port 3002 -> 127.0.0.1 port 3002
                      rdr pass inet proto tcp from any to any port 3003 -> 127.0.0.1 port 3003
                      rdr pass inet proto tcp from any to any port 3004 -> 127.0.0.1 port 3004
                      rdr pass inet proto tcp from any to any port 3005 -> 127.0.0.1 port 3005
                      rdr pass inet proto tcp from any to any port 3006 -> 127.0.0.1 port 3006
                      rdr pass inet proto tcp from any to any port 3007 -> 127.0.0.1 port 3007
                      rdr pass inet proto tcp from any to any port 3008 -> 127.0.0.1 port 3008
                      rdr pass inet proto tcp from any to any port 3009 -> 127.0.0.1 port 3009
                      rdr pass inet proto tcp from any to any port 3010 -> 127.0.0.1 port 3010
                      rdr pass inet proto tcp from any to any port 4242 -> 127.0.0.1 port 4242
                      rdr pass inet proto tcp from any to any port 9292 -> 127.0.0.1 port 9292
                      " | sudo pfctl -ef -
                    </string>
            </array>
            <key>RunAtLoad</key>
            <true/>
            <key>UserName</key>
            <string>root</string>
    </dict>
    </plist>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-13
      • 1970-01-01
      • 1970-01-01
      • 2014-12-16
      • 2015-03-05
      • 2021-02-08
      相关资源
      最近更新 更多