Imagine having an unix based system S1 - any common Linux distro with the most common out of the box setup - inside a network setup N1 which features a firewall F1 allowing some ports P1 and P2 forwarding from the internet to the machine through an external IP X1.
After configuring the firewall, you want to test on that clean Linux machine wether after serving some not-already deployed services you will be able to access them on X1:P1 and X1:P2.
Is there anything inside the operating system which will allow me to listen to that ports and help me testing the outbound connection? Any way to ask the OS to handle and reply on those ports? I know unix has built in support for accessing specific ports with virtual devices on a very useful and simple way: cat < /dev/tcp/127.0.0.1/22. Is there anything inverse for listening on the ports? Any built in util which starts a service on an arbitrary port and prints anything to console when receiving some raw data? Any crazy trick like re-setting the ping service to any arbitrary port?
Disclaimer: no, this isn't same as Test if a port on a remote system is reachable (without telnet), on this question the target service is not already deployed, and I want to test reachability despite nothing is listening yet with the aid of the OS.