使用rinetd访问内网的mongodb
1、下载renetd
[root@iZuf669jf17u94zldbcxulZ cj]# wget http://www.rinetd.com/download/rinetd.tar.gz
--2021-12-14 12:44:07-- http://www.rinetd.com/download/rinetd.tar.gz
Resolving www.rinetd.com (www.rinetd.com)... 35.189.164.113
Connecting to www.rinetd.com (www.rinetd.com)|35.189.164.113|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37076 (36K) [application/octet-stream]
Saving to: ‘rinetd.tar.gz’
rinetd.tar.gz 100%[================>] 36.21K --.-KB/s in 0.09s
2021-12-14 12:44:08 (391 KB/s) - ‘rinetd.tar.gz’ saved [37076/37076]
2、解压
[root@iZuf669jf17u94zldbcxulZ cj]# tar zxvf rinetd.tar.gz
rinetd/
rinetd/CHANGES
rinetd/getopt.c
rinetd/getopt.h
rinetd/index.html
rinetd/Makefile
rinetd/match.c
rinetd/match.h
rinetd/README.md
rinetd/rinetd.8
rinetd/rinetd.c
rinetd/rinetd.dsp
rinetd/rinetd.dsw
rinetd/rinetd.html
rinetd/rinetd.ncb
rinetd/rinetd.opt
rinetd/rinetd.plg
[root@iZuf669jf17u94zldbcxulZ cj]# ls
ml mtest rinetd rinetd.tar.gz
3、编译安装
[root@iZuf669jf17u94zldbcxulZ cj]# cd rinetd/
[root@iZuf669jf17u94zldbcxulZ rinetd]# ls
CHANGES index.html match.h rinetd.c rinetd.html rinetd.plg
getopt.c Makefile README.md rinetd.dsp rinetd.ncb
getopt.h match.c rinetd.8 rinetd.dsw rinetd.opt
[root@iZuf669jf17u94zldbcxulZ rinetd]# make
cc -DLINUX -g -c -o rinetd.o rinetd.c
rinetd.c: In function ‘closesocket’:
rinetd.c:35:9: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
return close(s);
^~~~~
pclose
rinetd.c: At top level:
rinetd.c:177:6: warning: conflicting types for built-in function ‘log’ [-Wbuiltin-declaration-mismatch]
void log(int i, int coSe, int result);
^~~
rinetd.c: In function ‘sampleOsRelease’:
rinetd.c:235:6: warning: implicit declaration of function ‘read’; did you mean ‘fread’? [-Wimplicit-function-declaration]
read(f, (void *)buffer, 80);
^~~~
fread
rinetd.c: In function ‘main’:
rinetd.c:305:7: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
if (!fork()) {
^~~~
rinetd.c: In function ‘getAddress’:
rinetd.c:1391:19: warning: implicit declaration of function ‘inet_addr’; did you mean ‘h_addr’? [-Wimplicit-function-declaration]
iaddr->s_addr = inet_addr(host);
^~~~~~~~~
h_addr
rinetd.c: In function ‘RegisterPID’:
rinetd.c:1443:29: warning: implicit declaration of function ‘getpid’; did you mean ‘getenv’? [-Wimplicit-function-declaration]
fprintf(pid_file, "%d\n", getpid());
^~~~~~
getenv
cc -DLINUX -g -c -o match.o match.c
gcc rinetd.o match.o -o rinetd -lpthread
[root@iZuf669jf17u94zldbcxulZ rinetd]# make install
install -m 700 rinetd /usr/sbin
echo > /etc/rinetd.conf
[root@iZuf669jf17u94zldbcxulZ rinetd]# rinetd -v
rinetd 0.62
4、配置文件并启动测试
[root@iZuf669jf17u94zldbcxulZ rinetd]# cat /etc/rinetd.conf
0.0.0.0 27018 172.21.111.122 27018
[root@iZuf669jf17u94zldbcxulZ rinetd]# /usr/sbin/rinetd