What's the easiest way to test a gateway?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 02:33:06

问题


I want to test a toy gateway I wrote. The testing will occur on Linux machines. I would like to do this in the easiest way possible, ideally writing no code and using existing utilities. This boils down to two questions:

  1. Is there an existing utility that can send packets with simple stuff in them(like a string that I supply) to a host through a user-specified gateway, without reconfiguring Linux's network settings? If so, what syntax would I use for the utility?

  2. Is there a simple utility I can run on the receiving end to verify that the correct packet was received? If so, what syntax would I use for the utility?


回答1:


I don't know about the first, but I don't think it's that hard to modify your routing table:

route add -host 1.2.3.4 gw 5.6.7.8

(replace 1.2.3.4 by your target IP and 5.6.7.8 by the IP of your gateway).

For 2.: On the target server type netcat -l 1234 and on the client then type netcat 1.2.3.4 1234. (1234 is a "random" port number)(depending on your distribution netcat might be called simple "nc".) If a connection gets established you can just type data on the client or the server machine, press enter and see the data arriving on the other machine.




回答2:


The easiest would probably be the nc(1). Assuming your gateway IP is 192.168.1.1 and you are using TCP, then on the server, listening on port 8888:

~$ nc -k -l 8888

On the client:

~$ nc 192.168.1.1 8888
  your input
  ...
  ^C


来源:https://stackoverflow.com/questions/4910422/whats-the-easiest-way-to-test-a-gateway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!