玩转 TCP/IP
我想学习和使用 python、java 或 c++ 的 tcp/ip 库。但我只有一台电脑。是否有可能“伪造”远程计算机来模拟远程主机,在 NAT 下结束一切?
I'd like to learn and play with tcp/ip libraries for python, java or c++. But I only have one computer. Is it possible to "fake" remote computers to emulate remote hosts, under NAT end everything?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
最简单的方法是在同一台计算机上运行服务器和客户端,并使用“环回”IP 地址:127.0.0.1,该地址始终连接到本地主机。我在测试过程中已经这样做过很多次了。例如,在端口 NNN 上运行本地 Web 服务器,然后在浏览器中输入 http://127.0.0.1:NNN/ 事实上,127.XYZ 应该始终与本地计算机通信。
The simplest way is to run both the server and client on the same computer and use the "loopback" IP address: 127.0.0.1 which always connects to the local host. I've done this many times during testing. For example, run a local webserver on port NNN and then in the browser enter http://127.0.0.1:NNN/ In fact, 127.X.Y.Z should always talk to the local machine.
如果您使用的是Linux,您可以配置
dummy
接口,然后将您的客户端/服务器绑定到不同的虚拟接口。您应该能够像其他接口一样在这些接口上运行 ipchains。
If you are using linux, you can configure
dummy
interfaces, then bind your client / server to different dummy interfaces.You should be able to run ipchains on these interfaces just like any other.
您可以从自己计算机上的程序之间的通信开始。
您可以使用 VirtualBox、VMWare、VirtualPC 等虚拟机软件来创建本质上是您的第二台计算机并与其进行通信(尽管网络拓扑可能非常不寻常 - 还有更多需要了解的内容)
如果您想要与远程的东西交谈,你可以从亚马逊之类的公司租用一个运行 Linux 或 Windows 的小型云服务器,一小时几美分,然后在上面安装你想要的任何东西。
You can start out with talking between programs on your own computer.
You can use virtual machine software such as VirtualBox, VMWare, VirtualPC, etc to create what is essentially a second machine within yours and talk to that (though the network topology may be very slightly unusual - something more to learn about)
If you want to talk to something remote, you can rent a small cloud server running linux or windows from the likes of Amazon for pennies an hour and install whatever you want on it.
使用虚拟盒在系统中安装操作系统。对于任何网络应用程序来说,这是最好的。您不必在两个不同的系统上工作,并且可以轻松查看两端发生的情况
Use virtual box to install OS in your system. for any networking application, this is best. You dont have to work on two different system and its easy to see whats happening at both ends
运行到服务器以侦听您的网络适配器或本地主机。然后向同一 IP 和端口发出请求。从逻辑上讲,这一切都将在网络驱动程序内发生,但如果该 IP 地址被寻址到另一台计算机,它的行为方式仍然相同(除非防火墙配置等)
Run to server to listen on your network adapter, or localhost. Then issue requests to that same IP and Port. Logically, it will all take place within the network driver(s), but it will still behave the same way if that IP address were addressed to another machine (barring Firewall configurations, etc)