Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

* SELinux and Iptables will be disabled

General questions about VestaCP
Post Reply
  • Print view
Advanced search
12 posts
  • 1
  • 2
  • Next
activation
Posts: 28
Joined: Sat Aug 03, 2013 8:49 am

* SELinux and Iptables will be disabled
  • Quote

Post by activation » Mon Aug 05, 2013 10:00 am

Iptables отключается во время установки и потом не включается, верно?
Устанавливается какой-то другой файервол или нужно снова вручную включать Iptables после установки?
спасибо.
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: * SELinux and Iptables will be disabled
  • Quote

Post by skid » Mon Aug 05, 2013 10:49 am

Фаервол необходимо включить вручную. В будущем мы хотим сделать интегракию с фаерволом csf
Top

activation
Posts: 28
Joined: Sat Aug 03, 2013 8:49 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by activation » Mon Aug 05, 2013 11:08 am

ок, ясно.

добавил:
iptables -A INPUT -p tcp --dport 8083 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT


но доступа нет (
что еще забыл разрешить для работы панели?
Top

activation
Posts: 28
Joined: Sat Aug 03, 2013 8:49 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by activation » Mon Aug 05, 2013 11:11 am

какие порты необходимы для работы панели?
Top

activation
Posts: 28
Joined: Sat Aug 03, 2013 8:49 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by activation » Mon Aug 05, 2013 11:26 am

вот так у меня включается фаервол:

Code: Select all

#!/bin/bash
### Скрипт конфигурации IPTables ###

# Очищаем предыдущие записи
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X 

# Установка политик по умолчанию
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Разрешаем локальный интерфейс
iptables -A INPUT -i lo -j ACCEPT

# Простая защита от DoS-атаки
iptables -A INPUT -p tcp -m tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT

# Защита от спуфинга
iptables -I INPUT -m conntrack --ctstate NEW,INVALID -p tcp --tcp-flags SYN,ACK SYN,ACK -j REJECT --reject-with tcp-reset
# Защита от попытки открыть входящее соединение TCP не через SYN
iptables -I INPUT -m conntrack --ctstate NEW -p tcp ! --syn -j DROP

# Закрываемся от кривого icmp
iptables -I INPUT -p icmp -f -j DROP
# REL, ESTB allow
iptables -A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -m state --state RELATED,ESTABLISHED -j ACCEPT

# Начнем с базовых вещей. Разрешим передачу трафика уже открытым соединениям:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Разрешение главных типов протокола ICMP
iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 12 -j ACCEPT

# Защита сервера SSH от брутфорса
iptables -A INPUT -p tcp --syn --dport 22 -m recent --name dmitro --set
iptables -A INPUT -p tcp --syn --dport 22 -m recent --name dmitro --update --seconds 30 --hitcount 3 -j DROP
iptables -A INPUT -p tcp --dport 22 -j ACCEPT


# Для работы OpenVPN #
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
sysctl -p
iptables -I FORWARD 1 -i tap0 -p udp -j ACCEPT
iptables -I FORWARD 1 -i tap0 -p tcp -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.231.0/24 -o eth0 -j SNAT --to-source 111.111.231.242
iptables -A INPUT -p udp --dport 1194 -j ACCEPT
#
iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited


# Просмотр
iptables -L --line-number
echo
echo "Adding DONE, maybe OK"
echo "Saving to rc, PSE wait!"
service iptables save
echo
service iptables restart
echo "Done"

service iptables restart
service network restart
service openvpn restart

iptables -A INPUT -p tcp --dport 8083 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
Top

nabbe
Posts: 114
Joined: Mon Aug 26, 2013 7:22 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by nabbe » Thu Aug 29, 2013 12:28 pm

Скажите пожалуйста, этот вариант сейчас рабочий? Его можно использовать?
Last edited by nabbe on Fri Aug 30, 2013 2:37 pm, edited 1 time in total.
Top

nabbe
Posts: 114
Joined: Mon Aug 26, 2013 7:22 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by nabbe » Fri Aug 30, 2013 12:34 pm

Оставлю для потомков, ну и для себя =)

1. идем в настройки iptables и включаем запуск и сохрание настроек после ребута, иначе все что мы сделаем будет слетать.

Code: Select all

sudo nano /etc/sysconfig/iptables-config
Там меняем no на yes следующее:

Code: Select all

IPTABLES_MODULES_UNLOAD="yes"
IPTABLES_SAVE_ON_STOP="yes"
IPTABLES_SAVE_ON_RESTART="yes"
IPTABLES_SAVE_COUNTER="yes"
Сохраняем и закрываем.

2. Создаем новый баш скрипт

Code: Select all

sudo nano iptables.sh
3. В него копируем следующее

Code: Select all

#!/bin/bash
### Скрипт конфигурации IPTables ###

# Очищаем предыдущие записи
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X 

# Установка политик по умолчанию
iptables -P INPUT DROP
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Разрешаем локальный интерфейс
iptables -A INPUT -i lo -j ACCEPT

# Простая защита от DoS-атаки
iptables -A INPUT -p tcp -m tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT

# Защита от спуфинга
iptables -I INPUT -m conntrack --ctstate NEW,INVALID -p tcp --tcp-flags SYN,ACK SYN,ACK -j REJECT --reject-with tcp-reset
# Защита от попытки открыть входящее соединение TCP не через SYN
iptables -I INPUT -m conntrack --ctstate NEW -p tcp ! --syn -j DROP

# Закрываемся от кривого icmp
iptables -I INPUT -p icmp -f -j DROP
# REL, ESTB allow
iptables -A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -m state --state RELATED,ESTABLISHED -j ACCEPT

# Начнем с базовых вещей. Разрешим передачу трафика уже открытым соединениям:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Разрешение главных типов протокола ICMP
iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 12 -j ACCEPT

# Защита сервера SSH от брутфорса
iptables -A INPUT -p tcp --syn --dport 22 -m recent --name dmitro --set
iptables -A INPUT -p tcp --syn --dport 22 -m recent --name dmitro --update --seconds 30 --hitcount 3 -j DROP
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Просмотр
iptables -L --line-number
echo
echo "Adding DONE, maybe OK"
echo "Saving to rc, PSE wait!"
service iptables save
echo
service iptables restart
echo "Done"

service iptables restart
service network restart

iptables -A INPUT -p tcp --dport 8083 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 995 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
OpenVPN я убрал, и добавил несколько портов для почты, фтп, ssh и т.д.
Сохраняем и закрываем.

4. Запускаем скрипт на выполнение

Code: Select all

bash iptables.sh 
Скрипт выполнится и завершит работу.

5. Смотрим что получилось.

Code: Select all

 iptables -L -n
Top

margent
Posts: 49
Joined: Wed Aug 28, 2013 8:57 pm

Re: * SELinux and Iptables will be disabled
  • Quote

Post by margent » Sat Sep 07, 2013 11:10 am

Я немного не понял:
-------------------------------------------------------------------
[root@main ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@jetlive ~]# ^C

--------------------------------------------------------------------
Это корректный ответ?
Сайт и панель работает.

Запустил с баш скрипта, выдает вот такой ужастик:
-------------------------------------------------------------------

[root@main ~]# iptables --list
Chain INPUT (policy DROP)
target prot opt source destination
DROP icmp -f anywhere anywhere
DROP tcp -- anywhere anywhere ctstate NEW tcp fla gs:!FIN,SYN,RST,ACK/SYN
REJECT tcp -- anywhere anywhere ctstate INVALID,NEW tcp flags:SYN,ACK/SYN,ACK reject-with tcp-reset
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp flags:FIN,SYN,R ST,ACK/RST limit: avg 1/sec burst 5
ACCEPT tcp -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT udp -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT all -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT icmp -- anywhere anywhere icmp destination-un reachable
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-prob lem
tcp -- anywhere anywhere tcp dpt:ssh flags:F IN,SYN,RST,ACK/SYN recent: SET name: dmitro side: source
DROP tcp -- anywhere anywhere tcp dpt:ssh flags:F IN,SYN,RST,ACK/SYN recent: UPDATE seconds: 30 hit_count: 3 name: dmitro side: so urce
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:us-srv
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Top

nabbe
Posts: 114
Joined: Mon Aug 26, 2013 7:22 am

Re: * SELinux and Iptables will be disabled
  • Quote

Post by nabbe » Sat Sep 07, 2013 6:01 pm

margent wrote:Я немного не понял:
-------------------------------------------------------------------
[root@main ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@jetlive ~]# ^C

--------------------------------------------------------------------
Это корректный ответ?
Сайт и панель работает.

Запустил с баш скрипта, выдает вот такой ужастик:
-------------------------------------------------------------------

[root@main ~]# iptables --list
Chain INPUT (policy DROP)
target prot opt source destination
DROP icmp -f anywhere anywhere
DROP tcp -- anywhere anywhere ctstate NEW tcp fla gs:!FIN,SYN,RST,ACK/SYN
REJECT tcp -- anywhere anywhere ctstate INVALID,NEW tcp flags:SYN,ACK/SYN,ACK reject-with tcp-reset
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp flags:FIN,SYN,R ST,ACK/RST limit: avg 1/sec burst 5
ACCEPT tcp -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT udp -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT all -- anywhere anywhere state RELATED,ESTAB LISHED
ACCEPT icmp -- anywhere anywhere icmp destination-un reachable
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-prob lem
tcp -- anywhere anywhere tcp dpt:ssh flags:F IN,SYN,RST,ACK/SYN recent: SET name: dmitro side: source
DROP tcp -- anywhere anywhere tcp dpt:ssh flags:F IN,SYN,RST,ACK/SYN recent: UPDATE seconds: 30 hit_count: 3 name: dmitro side: so urce
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:us-srv
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:urd
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere anywhere tcp dpt:imap
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Всю русскую кириллицу попробуйте убрать из скрипта, вообще всю
Top

XakRu
Posts: 117
Joined: Wed Nov 28, 2012 10:26 pm

Re: * SELinux and Iptables will be disabled
  • Quote

Post by XakRu » Wed Sep 25, 2013 10:56 am

Зачем столько букв?

Code: Select all

nano /etc/sysconfig/iptables
и вставить

Code: Select all

# Generated by iptables-save v1.4.7 on Fri Jun  7 14:37:21 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8083 -j ACCEPT 
-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A FORWARD -j REJECT --reject-with icmp-host-prohibited 
COMMIT
# Completed on Fri Jun  7 14:37:21 2013

Code: Select all

service iptables restart
По вебсерверу произвел некоторые настройки, не касающиеся производительности. Выключен почтовый сервер. Что работает: веб, фтп и ssh, ssl

Да и fail2ban настроить тоже можно, если нужно могу привести настройки, будет время отправлю коммиты в репозиторий. У меня fail2ban настроен и работает корректно, результат: в блокировке постоянно китайские айпи.
Top


Post Reply
  • Print view

12 posts
  • 1
  • 2
  • Next

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password