Linux-Windows 端口转发

  • 2019 年 10 月 3 日
  • 筆記

???????????????????????????(?????)??????????????????????????????????????????????????????????????????????????????????

  • Windows ????
  • Linux ????

??Windows ????

windows ????? netsh ???????

listenaddress  # ?????ip  listenport # ???????    connectaddress # ?????????ip  connectport # ????????????  # ????  netsh  interface  portproxy    add  v4tov4  listenaddress=localip  listenport=localport connectaddress=remoteip  connectport=remoteport  # ???????  netsh  interface  portproxy show all  # ?????????   netsh  interface  portproxy    delete   v4tov4  listenaddress=localip listenport=localport

??

?????? ?? IP 192.168.15.89 ????? 2222 ??? 192.168.15.35 ?? 22?

??? ??????????????

netsh  interface  portproxy    add  v4tov4  listenaddress=192.168.15.89  listenport=2222  connectaddress=192.168.15.35  connectport=22
PS C:WINDOWSsystem32> netsh  interface  portproxy show all    ?? ipv4:                 ??? ipv4:    ??            ??        ??            ??  --------------- ----------  --------------- ----------  192.168.15.89   2222        192.168.15.35   22

??Linux ????

1?rinetd

??

???? ?https://boutell.com/rinetd/

?? https://boutell.com/rinetd/http/rinetd.tar.gz

rinetd ??? TCP ????? IP ????????????? IP ??????rinetd ????????(???IO??)??????????/etc/rinetd.conf??????????????????rinetd ????? FTP??? FTP ???? socket? rinetd ??? Linux ?????????? Windows 95/98/NT ??????

???

wget https://boutell.com/rinetd/http/rinetd.tar.gz  tar -xzf  rinetd.tar.gz  yum  install gcc -y  cd  rinetd  # (??????)  sed -i 's/65536/65535/g' rinetd.c  # ????  mkdir /usr/man  # ????  make && make install

????

????

?????????????????????

bindaddress bindport connectaddress connectport

???

0.0.0.0 2222  192.168.15.89 22  0.0.0.0 3333  192.168.15.89 80

??????

rinetd ????????????????????(????ip????????)

??? ???????????????

allow  #?????????  deny   #?????????

????? 192.168.15 ????????

deny 192.168.15.*

??????

?????? rinetd ???????????????????????????????

logfile log-file-location

????? logfile ?????????????

logfile /var/log/rinetd.log

???????

deny 192.168.15.*  0.0.0.0 2222  192.168.15.89 22  0.0.0.0 3333  192.168.15.89 80  logfile /var/log/rinetd.log

??????

echo  <<EOF  >/etc/rinetd.conf  deny 192.168.15.*  0.0.0.0 2222  192.168.15.89 22  0.0.0.0 3333  192.168.15.89 80  logfile /var/log/rinetd.log  EOF  

?????

# ?? rinetd  rinetd    # ??????  echo rinetd >>/etc/rc.local    # ?? ???kill pid  kill `cat   /var/run/rinetd.pid`    # ????????  rinetd -c  /opt/rinetd.conf

????????????????????????

iptables ? Firewalld ?????????????????