What is the easiest way to check the gateway?

I want to check the toy gateway that I wrote. Testing will take place on Linux machines. I would like to do this in the easiest way, write code perfectly and use existing utilities. It comes down to two questions:

  • Is there an existing utility that can send packets with simple elements in them (for example, the line I provide) to the host through the gateway specified by the user, without reconfiguring the Linux network settings? If so, what syntax would I use for this utility?

  • Is there a simple utility that I can run on the receiving side to make sure that the correct package is received? If so, what syntax would I use for this utility?

0
source share
2 answers

I don’t know about the first, but I don’t think it is difficult to change your routing table:

route add -host 1.2.3.4 gw 5.6.7.8

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

For 2 .: On the target type server netcat -l 1234and on the client, enter netcat 1.2.3.4 1234. (1234 is a "random" port number) (depending on your distribution, netcat can be called simply "nc".) If the connection is established, you can simply enter data on a client or server computer, press enter and see the data coming in on another machine.

+2
source

The simplest can be nc(1). Assuming your gateway IP address 192.168.1.1and you are using TCP, then on the server, listening on the port 8888:

~$ nc -k -l 8888

On the client:

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

Source: https://habr.com/ru/post/1790872/


All Articles