Image

Knowledge base → Port forwarding using rinetd in Linux Debian 12

[Virtual servers]
Date of publication: 23.12.2023

To solve problems with port forwarding in Linux Debian, we will use the rinetd service; this service allows you to configure ip:port forwarding from one server to the ip:port of another server.

1. Installing the service

apt install rinetd

2. Configuration

vi /etc/rinetd.conf
# bindadress bindport connectaddress connectport options...
# 0.0.0.0 80 192.168.1.2 80
# ::1 80 192.168.1.2 80
# 0.0.0.0 80 fe80::1 80
# 127.0.0.1 4000 127.0.0.1 3000
# 127.0.0.1 4000/udp 127.0.0.1 22 [timeout=1200]
# 127.0.0.1 8000/udp 192.168.1.2 8000/udp [src=192.168.1.2,timeout=1200]

0.0.0.0 1234 89.104.77.7 443

We added a line where we allow connecting to any IP address present on the server and use ip 89.104.77.7 and port 443 as a remote server.

2.1 Restart the service

service rinetd restart

Now you can check if you connect to the server, in our case the server has one IP address 89.111.187.235 on port 1234 and we will see that forwarding works.

If you use several IP addresses on the server and want to allow connections only from this IP address, replace the configuration in the /etc/rinetd.conf file with this:

89.111.187.235 1234 89.104.77.7 443

2.2 Add the service to startup

systemctl enable rinetd

Ready.





said
30.01.2024 13:52
Hi ! I read your tutorial about Port forwarding using rinetd in Linux Debian 12 and would like to know more about this, specifically about the two following aspects:

1 Is this tutorial specific to virtual servers as it could be understood from the line below the title or it can be done on a physical machine?

2 Is it possible to use one physical server which is connected to internet to redirect the traffic to multiple physical or virtual servers which are in my local network?

Kindly to all your team!
Support Synay
30.01.2024 14:15
Hi.

1. Thank you for your interest, in this case the virtual server is no different from the physical one and the result will be the same both on us and on the physical one.
2. When we are talking about several, the question arises of how you specify them, because you need to register a specific IP address of a specific server. If we are talking about the same ports, but with different IPs, then in this case we will be talking about balancing the load, which someone must distribute based on the volume. The task itself is of a different type - load balancing, a different solution.