псих?

Sep 19, 2010 21:02



#!/bin/sh
template=intsrv-
allowed_access="333.222.111.99,222.333.444.555"
hosts_list=`grep $template /etc/hosts|cut -f 1 -s`
for host in $hosts_list
do
last_part=`echo $host|cut -d . -f 4`
echo iptables -t nat -A PREROUTING -p tcp -i eth1 -d 333.333.333.333 --dport 22$last -j DNAT --to 10.1.3.$last:22
done

Автоматически формирует DNAT исходя из серверов, перечисленных в /etc/hosts (для доступа к серверам снаружи). Порт доступа 22xx для серверов с номерами 0-99 и 22xxx для серверов с номерами 100-254. Доступ открывается только избранным.

администрирование, iptables, linux

Previous post Next post
Up