add 16
parent
541650d333
commit
b39fe7d7b5
|
@ -217,6 +217,15 @@ DNS | 192.168.10.9
|
|||
6. Добавьте порт 1001/TCP в постоянную конфигурацию зоны public.
|
||||
7. Проверьте доступ к серверу `http://server1` и виртуальному хосту `http://server1:1001`.
|
||||
|
||||
[вверх](#top)
|
||||
|
||||
***
|
||||
|
||||
###### Chapter16
|
||||
**Запуск контейнеров.**
|
||||
|
||||
|
||||
|
||||
[вверх](#top)
|
||||
|
||||
***
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
12. [Реализация расширенных функций хранилища.](#chapter12)
|
||||
13. [Планирование будущих задач. - Лабы нет.](#chapter13)
|
||||
14. [Доступ к NFS (Network-Attached Storage).](#chapter14)
|
||||
15. [](#chapter15)
|
||||
15. [Управление сетевой безопасностью.](#chapter15)
|
||||
16. [](#chapter16)
|
||||
17. [](#chapter17)
|
||||
|
||||
|
@ -59,9 +59,29 @@ root password: redhat
|
|||
```bash
|
||||
useradd student -G wheel
|
||||
echo student | passwd student --stdin
|
||||
|
||||
echo '192.168.10.11 server2' >> /etc/hosts
|
||||
|
||||
wget -P /home/student https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/h/htop-3.0.5-1.el8.x86_64.rpm
|
||||
|
||||
yum install -y httpd
|
||||
echo 'Welcome to WEB on SERVER1' > /var/www/html/index.html
|
||||
mkdir /var/www/html2
|
||||
echo 'Welcome to VHOST on SERVER1' > /var/www/html2/index.html
|
||||
cat <<EOT >> /etc/httpd/conf.d/vhost.conf
|
||||
Listen 1001
|
||||
NameVirtualHost *:1001
|
||||
<VirtualHost *:1001>
|
||||
DocumentRoot /var/www/html2
|
||||
</VirtualHost>
|
||||
EOT
|
||||
firewall-cmd --add-service=http
|
||||
firewall-cmd --add-service=http --permanent
|
||||
systemctl enable --now httpd
|
||||
|
||||
useradd poduser
|
||||
echo redhat | passwd poduser --stdin
|
||||
|
||||
```
|
||||
|
||||
*SERVER2*
|
||||
|
@ -997,3 +1017,148 @@ Welcome to Autofs share on server2!
|
|||
[вверх](#top)
|
||||
|
||||
***
|
||||
|
||||
###### Chapter15
|
||||
**Управление сетевой безопасностью.**
|
||||
|
||||
Ваша компания решила использовать новое web-приложение. Это приложение прослушивает порты 80/TCP и 1001/TCP. Порт 22/TCP для доступа по SSH также должен быть доступен. Все изменения, которые будут сделаны, должны быть доступны после перезагрузки.
|
||||
*Все настройки этой работы необходимо производить на server1, доступ проверять с server2.*
|
||||
|
||||
1. С server2 проверить доступ к серверу `http://server1` и виртуальному хосту `http://server1:1001`.
|
||||
```bash
|
||||
[student@server2 ~]$ curl http://server1/index.html
|
||||
curl: (7) Failed to connect to server1 port 80: В соединении отказано
|
||||
[student@server2 ~]$ curl http://server1:1001/index.html
|
||||
curl: (7) Failed to connect to server1 port 1001: Нет маршрута до узла
|
||||
```
|
||||
|
||||
2. Подключитесь к server1, чтобы разобраться в причинах ограничения доступа.
|
||||
*Проверим запущен ли Apache*
|
||||
```bash
|
||||
[root@server1 ~]# systemctl status httpd
|
||||
● httpd.service - The Apache HTTP Server
|
||||
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
|
||||
Active: failed (Result: exit-code) since Fri 2021-10-15 12:49:45 MSK; 7min ago
|
||||
Docs: man:httpd.service(8)
|
||||
Process: 10416 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
|
||||
Main PID: 10416 (code=exited, status=1/FAILURE)
|
||||
Status: "Reading configuration..."
|
||||
|
||||
окт 15 12:49:45 server1 systemd[1]: Starting The Apache HTTP Server...
|
||||
окт 15 12:49:45 server1 httpd[10416]: AH00548: NameVirtualHost has no effect and will be removed in the next release /e>
|
||||
окт 15 12:49:45 server1 httpd[10416]: AH00558: httpd: Could not reliably determine the server's fully qualified domain >
|
||||
окт 15 12:49:45 server1 httpd[10416]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:1001
|
||||
окт 15 12:49:45 server1 httpd[10416]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:1001
|
||||
окт 15 12:49:45 server1 httpd[10416]: no listening sockets available, shutting down
|
||||
окт 15 12:49:45 server1 httpd[10416]: AH00015: Unable to open logs
|
||||
окт 15 12:49:45 server1 systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
|
||||
окт 15 12:49:45 server1 systemd[1]: httpd.service: Failed with result 'exit-code'.
|
||||
окт 15 12:49:45 server1 systemd[1]: Failed to start The Apache HTTP Server.
|
||||
```
|
||||
*из вывода видно, что Apache не смог прослушать порт 1001*
|
||||
*проверим логи SELinux, возможно этот порт блокируется*
|
||||
```bash
|
||||
[root@server1 ~]# sealert -a /var/log/audit/audit.log
|
||||
100% done
|
||||
found 1 alerts in /var/log/audit/audit.log
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
SELinux запрещает /usr/sbin/httpd доступ name_bind к tcp_socket port 1001.
|
||||
|
||||
***** Модуль bind_ports предлагает (точность 99.5) *************************
|
||||
|
||||
Если вы хотите разрешить /usr/sbin/httpd для привязки к сетевому порту $PORT_ЧИСЛО
|
||||
То you need to modify the port type.
|
||||
Сделать
|
||||
# semanage port -a -t PORT_TYPE -p tcp 1001
|
||||
где PORT_TYPE может принимать значения: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t.
|
||||
|
||||
-- дальнейший вывод опущен --
|
||||
```
|
||||
*проверим разрешённые SELinux порты для WEB сервера*
|
||||
```bash
|
||||
[root@server1 ~]# semanage port -l | grep http
|
||||
http_cache_port_t tcp 8080, 8118, 8123, 10001-10010
|
||||
http_cache_port_t udp 3130
|
||||
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
|
||||
pegasus_http_port_t tcp 5988
|
||||
pegasus_https_port_t tcp 5989
|
||||
```
|
||||
|
||||
3. Настройте SELinux для доступа сервису httpd прослушивать порт 1001/TCP.
|
||||
*добавим порт 1001 в SELinux, как было предложено в выводе команды `sealert -a /var/log/audit/audit.log`*
|
||||
```bash
|
||||
[root@server1 ~]# semanage port -a -t http_port_t -p tcp 1001
|
||||
```
|
||||
*убедимся, что порт добавлен*
|
||||
```bash
|
||||
[root@server1 ~]# semanage port -l | grep http
|
||||
http_cache_port_t tcp 8080, 8118, 8123, 10001-10010
|
||||
http_cache_port_t udp 3130
|
||||
http_port_t tcp 1001, 80, 81, 443, 488, 8008, 8009, 8443, 9000
|
||||
pegasus_http_port_t tcp 5988
|
||||
pegasus_https_port_t tcp 5989
|
||||
```
|
||||
*перезапустим Apache*
|
||||
```bash
|
||||
[root@server1 ~]# systemctl start httpd
|
||||
[root@server1 ~]# systemctl status httpd
|
||||
● httpd.service - The Apache HTTP Server
|
||||
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
|
||||
Active: active (running) since Fri 2021-10-15 13:08:01 MSK; 8s ago
|
||||
Docs: man:httpd.service(8)
|
||||
Main PID: 39142 (httpd)
|
||||
Status: "Started, listening on: port 1001, port 80"
|
||||
Tasks: 213 (limit: 11252)
|
||||
Memory: 22.2M
|
||||
CGroup: /system.slice/httpd.service
|
||||
├─39142 /usr/sbin/httpd -DFOREGROUND
|
||||
├─39148 /usr/sbin/httpd -DFOREGROUND
|
||||
├─39149 /usr/sbin/httpd -DFOREGROUND
|
||||
├─39150 /usr/sbin/httpd -DFOREGROUND
|
||||
└─39151 /usr/sbin/httpd -DFOREGROUND
|
||||
|
||||
окт 15 13:08:01 server1 systemd[1]: Starting The Apache HTTP Server...
|
||||
окт 15 13:08:01 server1 httpd[39142]: AH00548: NameVirtualHost has no effect and will be removed in the next release /e>
|
||||
окт 15 13:08:01 server1 httpd[39142]: AH00558: httpd: Could not reliably determine the server's fully qualified domain >
|
||||
окт 15 13:08:01 server1 systemd[1]: Started The Apache HTTP Server.
|
||||
окт 15 13:08:06 server1 httpd[39142]: Server configured, listening on: port 1001, port 80
|
||||
```
|
||||
|
||||
4. С server2 проверить доступ к серверу `http://server1` и виртуальному хосту `http://server1:1001`.
|
||||
```bash
|
||||
[student@server2 ~]$ curl http://server1/index.html
|
||||
Welcome to WEB on SERVER1
|
||||
[student@server2 ~]$ curl http://server1:1001/index.html
|
||||
curl: (7) Failed to connect to server1 port 1001: Нет маршрута до узла
|
||||
```
|
||||
*сервер стал отвечать на стандартном порту (80), но порт 1001, по-прежнему недоступен*
|
||||
|
||||
5. Подключитесь к server1, чтобы определить верные ли порты указаны в межсетевом экране (firewall).
|
||||
```bash
|
||||
[root@server1 ~]# firewall-cmd --list-ports
|
||||
|
||||
[root@server1 ~]#
|
||||
```
|
||||
*из вывода понятно, что никакие порты не разрешены*
|
||||
|
||||
6. Добавьте порт 1001/TCP в постоянную конфигурацию зоны public.
|
||||
```bash
|
||||
[root@server1 ~]# firewall-cmd --zone=public --add-port=1001/tcp
|
||||
success
|
||||
[root@server1 ~]# firewall-cmd --list-ports
|
||||
1001/tcp
|
||||
[root@server1 ~]#
|
||||
```
|
||||
|
||||
7. Проверьте доступ к серверу `http://server1` и виртуальному хосту `http://server1:1001`.
|
||||
```bash
|
||||
[student@server2 ~]$ curl http://server1/index.html
|
||||
Welcome to WEB on SERVER1
|
||||
[student@server2 ~]$ curl http://server1:1001/index.html
|
||||
Welcome to VHOST on SERVER1
|
||||
```
|
||||
|
||||
[вверх](#top)
|
||||
|
||||
***
|
||||
|
|
Loading…
Reference in New Issue