Blog

webvirtmgr搭建kvm管理平台之NAT小鸡设置

cat >/root/cat.sh <<EOF
#!/bin/sh
 socat TCP4-LISTEN:3022,reuseaddr,fork TCP4:192.168.122.243:22
 socat TCP4-LISTEN:1022,reuseaddr,fork TCP4:192.168.122.51:22
 socat TCP4-LISTEN:2022,reuseaddr,fork TCP4:192.168.122.201:22
 socat TCP4-LISTEN:8080,reuseaddr,fork TCP4:192.168.122.101:8080
 socat TCP4-LISTEN:1433,reuseaddr,fork TCP4:192.168.122.101:1433
EOF

cat >/root/socat.sh <<EOF
#!/bin/sh
pid=`ps aux| grep "socat" | grep -v grep | sed -n  '1P' | awk '{print $2}'`
if [ -z $pid ]; then
       cd /root/
       screen -dmS   sh cat.sh
        exit 1
else
        echo -e "exist ,don't need restart"
fi
EOF

echo "0 */2 * * * /bin/sh /root/socat.sh" >> /var/spool/cron/root

没有评论

Leave a Reply