[CentOS] rinetd

2014. 10. 29. 15:55OS/CentOS

# yum -y install gcc

# wget http://www.boutell.com/rinetd/http/rinetd.tar.gz

# tar zxvf rinetd.tar.gz

# cd rinetd

# make

# mv rinetd /usr/sbin/

# chcon -u system_u -t bin_t /usr/sbin/rinetd

# vi /etc/rinetd.conf

>내용시작--------------------------------------<

logfile /var/log/rinetd/rinetd.log

logcommon


#src IP, Port, dest IP, Port

0.0.0.0 8080 192.168.0.10 80

>내용종료--------------------------------------<


# vi /etc/rc.d/init.d/rinetd

>내용시작---------------------------------------<

#!/bin/sh

#

# chkconfig: - 80 20

# description: rinetd is a TCP redirection server

# processname: rinetd

# pidfile: /var/run/rinetd.pid

# config: /etc/rinetd.conf


# Source function library.

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


# Source networking configuration.

. /etc/sysconfig/network


# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 1


exec="/usr/sbin/rinetd"

prog=$(basename $exec)


lockfile=/var/lock/subsys/$prog


start() {

    echo -n $"Starting $prog: "

daemon $exec

    retval=$?

    echo

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

    return $retval

}


stop() {

    echo -n $"Stopping $prog: "

    killproc $prog

    retval=$?

    echo

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

    return $retval

}


restart() {

    stop

    start

}


reload() {

if [ -f "$lockfile" ]; then

echo -n $"Reloading $prog: "

killproc $prog -HUP

retval=$?

echo

return $retval

else

restart

fi

}


force_reload() {

    restart

}


fdr_status() {

    status $prog

}


case "$1" in

    start|stop|restart|reload)

        $1

        ;;

    force-reload)

        force_reload

        ;;

    status)

        fdr_status

        ;;

    condrestart|try-restart)

  [ ! -f $lockfile ] || restart

;;

    *)

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

        exit 2

esac

>내용종료---------------------------------------<


# chcon -u system_u -t initrc_exec_t /etc/rc.d/init.d/rinetd

# chmod +x /etc/rc.d/init.d/rinetd

# chkconfig rinetd on

# vi /etc/logrotate.d/rinetd

>내용시작---------------------------------------<

/var/log/rinetd.log {

missingok

notifempty

delaycompress

postrotate

/sbin/service rinetd restart 2> /dev/null > /dev/null || true

endscript

}

>내용종료---------------------------------------<


# mkdir /var/log/rinetd

# chcon -u system_u /var/log/rinetd

# service rinetd start


서비스 확인

# ps -aux | grep `cat /var/run/rinetd.pid`

서비스 강제종료

# kill -9 `cat /var/run/rinetd.pid`

'OS > CentOS' 카테고리의 다른 글

[CentOS] Sendmail  (0) 2014.10.29
[CentOS] MySQL  (0) 2014.09.30
[CentOS] vsftpd  (0) 2014.09.24
[CentOS] Web  (0) 2014.09.05
[CentOS] Samba  (0) 2014.09.03