阻止到某个 IP 的传出连接以进行失败测试?
我们在 Windows Server 2003 上使用 Coldfusion 9。我们正在对一些通过 CFLDAP 与 LDAP 交互的代码以及通过 Java 与 LDAPS 交互的代码进行“故障转移”测试(用于密码更改)。
本质上,我们希望拥有 LDAP 服务器 IPS 的列表,并在发生连接故障时切换到新服务器。
是否有一种快速方法可以阻止从操作系统级别到 IP 的出站连接以模拟 LDAP 服务器中断,而无需实际断开其与网络的连接或将其关闭?
We are using Coldfusion 9 on Windows Server 2003. We are testing a "failover" on some code that interacts with LDAP through CFLDAP and LDAPS through Java (for password changes).
Essentially we want to have a list of LDAP server IPS and switch to a new server when a connection failure occurs.
Is there a quick way to block outbound connections to an IP from an OS level to mimic an LDAP server outage without actually disconnecting it from the network or shutting it off?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将您想要显示为离线的 IP 添加到 /etc/hosts 中,指向 127.0.0.1
Add the IP that you want to appear as offline to /etc/hosts as pointing to 127.0.0.1
ColdFusion 没有内置任何东西来促进这一点。经过一番谷歌搜索后,我认为 @Adam Tuttle 的解决方案可能是 Windows 盒子的最佳选择,但看来您也可以使用 Windows防火墙实现此效果。在 *nix 盒子上看起来像 "iptables"命令可以阻止出站流量。
ColdFusion doesn't have anything built in to facilitate this. After some Googling, I think @Adam Tuttle's solution is probably the best bet for Windows boxes, however it appears you can also use the Windows Firewall to achieve this effect. On *nix boxes looks like the "iptables" command can stop outbound traffic.
Sniffy 允许您阻止 Java 应用程序中的传出网络连接(Coldfusion 基于 Java) - 每当您尝试与受限主机建立新连接时,它都会抛出
ConnectException
。只需将
-javaagent:sniffy.jar=5559
添加到您的 JVM 参数中,并将浏览器指向localhost:5559
- 它将打开一个网页,其中包含所有已发现的与下游系统的连接以及禁用某些连接的控件。如果您的应用程序是基于 Web 的,您甚至可以直接从在浏览器中打开的应用程序中执行此操作 - 请参阅此处的演示:http://demo.sniffy.io/owners?lastName=
单击右下角的小部件,选择
网络连接
选项卡,禁用并连接到localhost:8967
(数据库)并重新加载页面以查看其运行情况。免责声明:我是 Sniffy 的作者
Sniffy allows you to block outgoing network connections in your Java applications (Coldfusion is based on Java) - it will throw a
ConnectException
whenever you try to establish a new connection to restricted host.Just add
-javaagent:sniffy.jar=5559
to your JVM arguments and point your browser tolocalhost:5559
- it will open a web page with all discovered connections to downstream systems and controls to disable certain connections.If your application is web-based, you can even do it directly from your application opened in browser - see a demo here: http://demo.sniffy.io/owners?lastName=
Click on a widget in bottom-right corner, select
Network Connections
tab, disable and connection tolocalhost:8967
(database) and reload a page to see it in action.Disclaimer: I'm the author of Sniffy