Big data learning monk 2022-02-13 07:15:54 阅读数:661
stay Linux In most cases, the system chooses to use iptables To achieve port forwarding ,iptables Although powerful , But the configuration is inconvenient , And novices are prone to mistakes . Share another TCP/UDP Port forwarding tool rinetd,rinetd Small size , The configuration is also very simple .
This article uses CentOS 7 For example , Copy the following command input , A line of one :
install rinetd
1, Installation dependency
yum -y install gcc gcc-c++ make
2, download rinetd
wget https://github.com/samhocevar/rinetd/releases/download/v0.70/rinetd-0.70.tar.gz
3, decompression
tar xf rinetd-0.70.tar.gz
4, Entry directory
cd rinetd-0.70
5, Compilation and installation
./bootstrap
./configure
make && make install
6, After installation , You can enter rinetd -v Check out the current version .
[root@localhost rinetd-0.70]# rinetd -v
rinetd 0.70
Configure forwarding
1, edit rinetd The configuration file
vi /usr/local/etc/rinetd.conf
2, Fill in the following
0.0.0.0 8080 1.1.1.1 80
3, start-up rinetd
rinetd -c /usr/local/etc/rinetd.conf
4, Configuration parameter description
0.0.0.0: Source IP It's local monitoring IP
8080: Source port
1.1.1.1: The goal is IP, For the convenience of memory, you can use domain name instead of , But if the domain name is on this computer ping It will fail to start
80: Target port
1, establish rinetd service
vi /etc/systemd/system/rinetd.service
Copy the following content to save :
[Unit]
Description=rinetd
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/sbin/rinetd -c /usr/local/etc/rinetd.conf
ExecReload=/bin/kill -SIGHUP $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
2, Enter the command :systemctl daemon-reload heavy load daemon Make it effective , Then you can use the following command to manage rinetd 了 .
# start-up rinetd
systemctl start rinetd
# Set boot up
systemctl enable rinetd
# stop it rinetd
systemctl stop rinetd
# restart
systemctl restart rinetd
# close
killall rinetd
Check that the number of connections to the machine is not high
ss -s
Check port usage
netstat -antup
copyright:author[Big data learning monk],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130715526176.html