This example is based on two boxe’s debian, Client and Server

 

explain

 

Note: box1 has ip address 1.2.3.5 and box2 has ip address 1.2.3.4

  1. Install the package stunnel on both servers
    $ apt-get install -y stunnel
  2. configure the stunnel config on client box
    $ vim /etc/stunnel/stunnel.conf
    cert = /etc/ssl/certs/stunnel.pem
    chroot = /var/lib/stunnel4/
    setuid = stunnel4
    setgid = stunnel4
    pid = /stunnel4.pid
    ;socket = l:TCP_NODELAY=1
    ;socket = r:TCP_NODELAY=1
    debug = 7
    output = /var/log/stunnel4/stunnel.log
    client = yes[boxserver]
    accept = 127.0.0.1:1234
    connect = 1.2.3.4:1234
  3. configure the stunnel config on server box
    vim /etc/stunnel/stunnel.conf
    cert = /etc/ssl/certs/stunnel.pem
    chroot = /var/lib/stunnel4/
    setuid = stunnel4
    setgid = stunnel4
    pid = /stunnel4.pid
    ;socket = l:TCP_NODELAY=1
    ;socket = r:TCP_NODELAY=1
    debug = 7
    output = /var/log/stunnel4/stunnel.log
    client = yes[boxserver]
    accept = 1234 
    connect = 127.0.0.1:4321
  4. start the service on both servers
    $ service syslog-ng start
  5. check connection
    $ netstat -antp | grep 1234
  6. to test with one simple message
    – On the server box (to listen)
    $ nc -p 1234 -l
    – On the client box
    $ ( echo “Test msg”;  echo “Test the second message”; ) | nc 127.0.0.1 1234
  7. check on the server box, and you will see the messages
  8. And now, you are ready to setup por exeample syslog between box’s linux