#!/bin/bash

# Определяем правила iptables
add_rules() {
    iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 9922 -j DNAT --to-destination 10.25.10.105:22

}

remove_rules() {
    iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 9922 -j DNAT --to-destination 10.25.10.105:22
	
}

# Проверяем количество аргументов
if [ "$#" -ne 2 ]; then
    echo "Usage: $0 {start|stop}"
    exit 1
fi

# Обработка аргументов
case "$2" in
    pre-start)
        add_rules
        ;;
    post-stop)
        remove_rules
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
        ;;
esac
