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:
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?
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?
The easiest would probably be the
nc(1)
. Assuming your gateway IP is192.168.1.1
and you are using TCP, then on the server, listening on port8888
:On the client:
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 typenetcat 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.