Jump to content

Recommended Posts

Posted

Стоит впн сервер, биллинг UTM5.

Пользователь уходит в минус добавляется правило /sbin/iptables -D FORWARD -s UIP -j ACCEPT, интернет отключается. Но если в данный момент у пользователя была закачка файла или установлено соединение ICQ, то файл продолжает закачиваться, аська продолжает работать, пока пользователь её неотключит, ну и денежные средства уходят в минус. Что не так почему не разрываются соединения сразу непойму.... где копать?

Posted

Где, где, в iptables.

Отключайте вручную, проверяйте цепочки, проверьте политику FORWARD, уж не стоит ли там ACCEPT. :)

Posted

Я же написал интернет отключаетсЯ!!! Тоесть Пока идет закачка файла или работа в аське, новые TCP соединения не устанавливаются!!! А закачка файла идет! Я уже там все и по времени и по логам отслеживал.

Posted
Я же написал интернет отключаетсЯ!!! Тоесть Пока идет закачка файла или работа в аське, новые TCP соединения не устанавливаются!!! А закачка файла идет! Я уже там все и по времени и по логам отслеживал.
Посмотри нетли в FORWARD'e каких либо правил разрешающих НАТ,

обычно так себя ведет блокировка в цепочке NAT, т.к. она фильтрует

только первый пакет в проначеном потоке...

Posted
Пользователь уходит в минус добавляется правило /sbin/iptables -D FORWARD -s UIP -j ACCEPT, интернет отключается.
блин, думаю, как это - добавляется разрешаюшее правило, а интернет - отключается?

только потом заметил -D.. :)

читайте iptables tutorial, уважаемый

 

Но если в данный момент у пользователя была закачка файла или установлено соединение ICQ, то файл продолжает закачиваться, аська продолжает работать, пока пользователь её неотключит, ну и денежные средства уходят в минус. Что не так почему не разрываются соединения сразу непойму.... где копать?

ключевое слово - ESTABLISHED

Posted

У вас наверное man старый

 

recent

Allows you to dynamically create a list of IP addresses

and then match against that list in a few different ways.

 

For example, you can create a `badguy' list out of people

attempting to connect to port 139 on your firewall and

then DROP all future packets from them without considering

them.

 

--name name

Specify the list to use for the commands. If no

name is given then 'DEFAULT' will be used.

 

[!] --set

This will add the source address of the packet to

the list. If the source address is already in the

list, this will update the existing entry. This

will always return success (or failure if `!' is

passed in).

 

[!] --rcheck

Check if the source address of the packet is cur-

rently in the list.

 

[!] --update

Like --rcheck, except it will update the "last

seen" timestamp if it matches.

 

[!] --remove

Check if the source address of the packet is cur-

rently in the list and if so that address will be

removed from the list and the rule will return

true. If the address is not found, false is

returned.

 

[!] --seconds seconds

This option must be used in conjunction with one of

--rcheck or --update. When used, this will narrow

the match to only happen when the address is in the

list and was seen within the last given number of

seconds.

 

[!] --hitcount hits

This option must be used in conjunction with one of

--rcheck or --update. When used, this will narrow

the match to only happen when the address is in the

list and packets had been received greater than or

equal to the given value. This option may be used

along with --seconds to create an even narrower

match requiring a certain number of hits within a

specific time frame.

 

--rttl This option must be used in conjunction with one of

--rcheck or --update. When used, this will narrow

the match to only happen when the address is in the

list and the TTL of the current packet matches that

of the packet which hit the --set rule. This may be

useful if you have problems with people faking

their source address in order to DoS you via this

module by disallowing others access to your site by

sending bogus packets to you.

 

Examples:

 

# iptables -A FORWARD -m recent --name badguy

--rcheck --seconds 60 -j DROP

 

# iptables -A FORWARD -p tcp -i eth0 --dport 139 -m

recent --name badguy --set -j DROP

 

Official website (http://snowman.net/projects/ipt_recent/)

also has some examples of usage.

 

/proc/net/ipt_recent/* are the current lists of addresses

and information about each entry of each list.

 

Each file in /proc/net/ipt_recent/ can be read from to see

the current list or written two using the following com-

mands to modify the list:

 

echo xx.xx.xx.xx > /proc/net/ipt_recent/DEFAULT

to Add to the DEFAULT list

echo -xx.xx.xx.xx > /proc/net/ipt_recent/DEFAULT

to Remove from the DEFAULT list

 

echo clear > /proc/net/ipt_recent/DEFAULT

to empty the DEFAULT list.

 

The module itself accepts parameters, defaults shown:

 

ip_list_tot=100

Number of addresses remembered per table

 

ip_pkt_list_tot=20

Number of packets per address remembered

 

ip_list_hash_size=0

Hash table size. 0 means to calculate it based on

ip_list_tot, default: 512

 

ip_list_perms=0644

Permissions for /proc/net/ipt_recent/* files

 

debug=0

Set to 1 to get lots of debugging info

Я проверил в паре мест - модуль ipt_recent есть и в 2.4 и в 2.6 iptables версий 1.3.5 и 1.3.7

Posted

хм, действительно, в etch появилось.. в sarge и rhel4 такого нет (iptables 1.2.11)

насколько я понимаю, вся фишка в "echo xx.xx.xx.xx > /proc/net/ipt_recent/"?

 

но рекомендации автору копать на тему ESTABLISHED это не отменяет :)

Posted

4.1.3 Create content in userspecified chains

#

$IPTABLES -A bad_tcp_packets -p tcp --tcp-flags SYN,ACK SYN,ACK -m \

state --state NEW -j REJECT --reject-with tcp-reset

$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j \

LOG --log-prefix "New not syn:"

$IPTABLES -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP

#

# allowed chain

#

$IPTABLES -A allowed -p TCP --syn -j ACCEPT

$IPTABLES -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A allowed -p TCP -j DROP

 

Трансляция через маскарадинг.

Куда дальше копать?

Posted
Установлен RHEL 3 упоминания про recent нету(((
для решения проблемы это не нужно

возможно, будет полезно для оптимизации. потом.

если захотите обновлять iptables

Posted

[root@server root]# iptables -nL FORWARD

iptables -nL FORWARD

Chain FORWARD (policy DROP)

target prot opt source destination

bad_tcp_packets tcp -- 0.0.0.0/0 0.0.0.0/0

ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

LOG all -- 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 3 LOG flags 0 level 7 prefix `IPT FORWARD packet died: '

ACCEPT all -- 192.168.1.16 0.0.0.0/0

ACCEPT all -- 192.168.1.18 0.0.0.0/0

ACCEPT all -- 192.168.1.24 0.0.0.0/0

и так далее куча ацептов для клиентов...

Posted

мда....

вы-таки туториал почитайте, полезно будет

2 направления:

1. что есть RELATED,ESTABLISHED и зачем они нужны

2. что есть LOG и зачем оно нужно

 

судя по IPT FORWARD packet died: изначально правила были взяты из туториала, там даже каменты есть для этих строчек, насколько мне не изменяет память

 

так что читайте, понимание работы ESTABLISHED вам поможет

 

туториал даже на русский переведен

Posted
[root@server root]# iptables -nL FORWARD

iptables -nL FORWARD

Chain FORWARD (policy DROP)

target prot opt source destination

bad_tcp_packets tcp -- 0.0.0.0/0 0.0.0.0/0

ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

LOG all -- 0.0.0.0/0 0.0.0.0/0 limit: avg 3/min burst 3 LOG flags 0 level 7 prefix `IPT FORWARD packet died: '

ACCEPT all -- 192.168.1.16 0.0.0.0/0

ACCEPT all -- 192.168.1.18 0.0.0.0/0

ACCEPT all -- 192.168.1.24 0.0.0.0/0

и так далее куча ацептов для клиентов...

а фигли ты хотел если самое первое правило разрешает пропуск уже установленных соединений.
Posted

а фигли ты хотел если самое первое правило разрешает пропуск уже установленных соединений.

ну вот, пришел и всю малину распугал.. :)

Posted

тоесть я так понял первое правило убираем, и прописываем в билинге чтоб добавлялось два правила к примеру /sbin/iptables -A FORWARD -s UIP -m state --state ESTABLISHED,RELATED -j ACCEPT

/sbin/iptables -A FORWARD -s UIP -j ACCEPT, а при уходе в минус

/sbin/iptables -D FORWARD -s UIP -m state --state ESTABLISHED,RELATED -j ACCEPT

/sbin/iptables -D FORWARD -s UIP -j ACCEPT

я все правильно понял, гуру?

Posted

в этой схеме состояние соединения отслеживать не нужно, это лишнее

LOG тоже не нужен, он дает вызывающе неверную информацию :)

Posted

непонимаю если я убираю правило iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT тогда интернет вообще пропадает, значит всетаки состояние отслеживать нужно...

Posted

вах, чёрт возьми.

пакеты ходят как от юзера, так и к юзеру при его работе в инете.

вариантов два: либо разрешить исходящие от клиента и отслеживать статус соединения с помощью -m state , либо на каждого юзера генерировать по два правила: на выход и на вход, а модуль state не юзать.

у вас сейчас сделано по первой схеме.

hint: с модулем state работает несколько медленнее, только прочувствовать это можно только нагрузках, близких к максимуму.

Posted

если отслеживать состояние, то не получится рубить активные соединения (что и было описано в исходном посте)

 

если у вас не работает при удалении FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT, то тут что-то другое

 

показываете опять -nL FORWARD

правила, разрешающие трафик юзеру, есть?

Posted

т.е. чтобы у UIP был инет, нужно сделать

/sbin/iptables -A FORWARD -s UIP -j ACCEPT

 

чтобы отключить

/sbin/iptables -D FORWARD -s UIP -j ACCEPT

 

при этом состояние отслеживать не нужно

Posted

ок, а кто быдет пропускать входящий к юзеру трафик?

сейчас за это отвечает правило с -m state

еще раз: если не использовать state, на каждого юзера надо по два правила, одно на вход, одно на выход.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...
На сайте используются файлы cookie и сервисы аналитики для корректной работы форума и улучшения качества обслуживания. Продолжая использовать сайт, вы соглашаетесь с использованием файлов cookie и с Политикой конфиденциальности.