Rinetd is a utility tool for port forwarding, which can redirect traffic from one port to another specified port. The following is a concise introductory tutorial for Rinetd:
Install Rinetd: Open a terminal window and run the following command to install Rinetd:
sudo apt update sudo apt install -y rinetd
Configuring Rinetd: Rinetd’s configuration file is located at /etc/rinetd.conf
. Open the file using your favorite text editor:
sudo nano /etc/rinetd.conf
Add port forwarding rules in the configuration file: Each line represents a port forwarding rule, the format is source IP source port target IP target port
. For example, to forward the local port 80 to the remote server's port 8080, you can add the following line:
0.0.0.0 80 远程服务器IP 8080
You can add multiple forwarding rules as needed, each rule occupies one line.
Ctrl X
, then enter Y
Save changes and exit. Start the Rinetd service: Run the following command to start the Rinetd service:
sudo systemctl start rinetd
Verify port forwarding: After ensuring that the Rinetd service has been started, you can try to connect to the local source port, and then check whether the traffic is correctly forwarded to the destination port. You can use tools such as telnet or curl to test the connection.
For example, if you have a web server running on your local host and use Rinetd to forward port 80 to the remote server's port 8080, you can run the following command through the terminal:
curl localhost
If everything is set up correctly, you should be able to get a response on port 8080 on the remote server.
Configure auto-start at boot (optional): If you want Rinetd to start automatically when the system starts, you can run the following command to configure it to auto-start at boot:
sudo systemctl enable rinetd
In this way, Rinetd will start automatically every time the system starts.
Now you have completed the introductory tutorial of Rinetd. You can add more port forwarding rules in the configuration file as needed and enable or disable the Rinetd service as needed. Please note that the use of Rinetd involves network security considerations, please ensure that only necessary ports are opened and appropriate security measures are taken.
The above is the detailed content of Detailed introductory tutorial for port forwarding tool Rinetd. For more information, please follow other related articles on the PHP Chinese website!