在WiFi上优胜美地升级到10.10.3后,Rails服务器在网络上不可见 [英] Rails server not visible on network after Yosemite upgrade to 10.10.3 on WiFi

查看:67
本文介绍了在WiFi上优胜美地升级到10.10.3后,Rails服务器在网络上不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a rails server running on my machine that was available to the local network, everything worked fine and i could access my server from other devices using the local dress 192.168.x.x:3000, after the updating the os to 10.10.3 (i had Yosemite before but i can't remember the version) this no longer works, my firewall is disabled and i've tried to start the server using "rails server --binding=0.0.0.0" but it is still not visible for other devices on the network.

我现在看到的问题仅是当我使用WIFI时,如果我通过雷电和以太网连接一切正常

i now see that the problem is only when i'm using the WIFI if i connect via a thunderbolt and ethernet everything works fine

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

Does anyone know how to solve this problem ?

谢谢!

推荐答案

可以再次使用!

MacOS Yosemite完全删除了ipfw (IP防火墙),现在仅使用pf (数据包过滤器).因此,我们习惯的所有默认转发都消失了!

MacOS Yosemite completly removed ipfw (IP-Firewall) and now only uses pf (Packet Filter). So all the default forwarding, we are used to is gone!

为了使其再次正常工作,我使用了此出色的教程: Mac pfctl端口转发 Sal Ferrarello 中进行了更改,并对其进行了更改,以支持常规的Rails服务器.把它放在终端和.. 它再次正常工作!

To make it work again, I used this great tutorial: Mac pfctl Port Forwarding from Sal Ferrarello and changed it to support usual rails servers. Put it in the terminal and .. it Works again!

激活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

停止端口转发 (CAREFULL!再次停止!)

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

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

这仅在下次重启之前有效.我做了很多尝试,以使其自动运行,我更改了/etc/pf.conf ,我更改了pf守护程序..但没有任何效果!

this only works until next restart. I tried a lot to get it work automatically, I changed /etc/pf.conf, I changed the pf daemon .. but nothing works!

所以我创建了自己的守护进程,该守护进程仅在启动时加载我的开发端口,效果很好!

So I made my own Daemon which just loads my dev ports on startup, which works great!

/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>

这篇关于在WiFi上优胜美地升级到10.10.3后,Rails服务器在网络上不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆