Linux端口转发-rinted工具部署、配置、使用

1、源码安装rinted:

    下载和解压源码包:

1

cd /usr/local/src && wget https://boutell.com/rinetd/http/rinetd.tar.gz && tar xf rinetd.tar.gz && cd rinetd

 

    修改编译配置:

1

sed -i 's/65536/65535/g' rinetd.c# 修改端口范围,否则会报错

 

    编译安装:

1

mkdir -p /usr/man/man8 && make && make install

 

    编辑配置文件:/etc/rinetd.conf

1

2

3

4

5

6

7

8

9

10

#自定义mysql端口:3001/3100

#自定义ssh端口:2001/2500

#自定义web端口:801/899

#端口转发:[Source Address] [Source Port] [Destination Address] [Destination Port]

0.0.0.0 8080 10.124.162.114 8080

0.0.0.0 443 10.124.162.114 8080

0.0.0.0 3001 10.124.162.114 33080

#端口映射: bindaddress bindport connectaddress connectport

 

logfile /var/log/rinetd.log

 

    启动与关闭:

1

2

3

4

#启动

/usr/sbin/rinetd -c /etc/rinetd.conf

#关闭

pkill rinetd

 

   启动脚本:/home/shell/rinetd  使用方法:sh /home/shell/rinetd start|stop|restart|reload

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

#!/bin/bash

#

# Startup script for Rinetd - this script starts and stops the rinetd daemon

#

# chkconfig: - 85 15

# description: Rinetd is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server

# processname: rinetd

# config: /etc/rinetd.conf

# pidfile: /var/lock/subsys/rinetd

# Source function library.

. /etc/rc.d/init.d/functions

  

# Source networking configuration.

. /etc/sysconfig/network

  

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

  

rinetd="/usr/sbin/rinetd"

prog=$(basename $rinetd)

  

RINETD_CONF_FILE="/etc/rinetd.conf"

  

#[ -f /etc/sysconfig/rinetd ] && . /etc/sysconfig/rinetd

  

lockfile=/var/lock/subsys/rinetd

  

start() {

    [ -x $rinetd ] || exit 5

    [ -f $RINETD_CONF_FILE ] || exit 6

    echo -n $"Starting $prog: "

    daemon $rinetd -c $RINETD_CONF_FILE

    retval=$?

    echo

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}

  

stop() {

    echo -n $"Stopping $prog: "

    #killproc $rinetd -HUP

    daemon pkill $prog

    retval=$?

    echo

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}

  

restart() {

    stop

    sleep 1

    start

}

  

reload() {

    echo -n $"Reloading $prog: "

    killproc $rinetd -HUP

    RETVAL=$?

    echo

}

  

rh_status() {

    status $prog

}

rh_status_q() {

    rh_status >/dev/null 2>&1

}

  

case "$1" in

    start)

        rh_status_q && exit 0

        $1

        ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        rh_status_q || exit 7

        $1

        ;;

    status)

        rh_status

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|reload}"

        exit 2

esac

你可能感兴趣的:(linux)