실습> UTM에서 LVS 설정하기
참고:
https://cafe.naver.com/linuxmasternet/546
!!! 중요 !!!
LSB를 설정하기 위해서는 NAT > DNAT [WEB#1 DNAT 설정] 룰을 중지해야 한다.
Sophos UTM LSB(Server Load Balancing)
대표 공인 IP주소 : 192.168.108.101
Real 서버#1 IP주소 : 192.168.101.100
Real 서버#2 IP주소 : 192.168.101.101
1. DNAT 설정 중지
UTM에서 LSB를 설정하면 자동으로 NAT 방식으로 설정된다.
그러므로 DNAT가 설정되어 있다면 중지해야 한다.
NAT : 사설 네트워크를 이용하는 방법
Real Server는 모두 사설 IP주소를 가지고 있다.
요청: Client -> LVS, 응답: Real -> LVS -> Client
[Network Protection] > [NAT] > [NAT] > DNAT 중지
2. LSB 설정
[Network Protection] > [Server Load Balancing] > [Balancing Rules] > [+ New Load Balancing Rule...]
Add Load Balancing Rule
Service: HTTP <-- 향후 HTTP/HTTPS로 그룹을 묶어서 사용하는 것을 테스트!
Virtual server: External [WEB#1] (Address)
Real Servers:
- WEB#1 <-- + 를 클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
Add Network Definition
Name: WEB#1
Type: Host
IPv4 address: 192.168.101.101
Comment: 내부망 웹서버#1
- WEB#2 <-- + 를 클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
Add Network Definition
Name: WEB#2
Type: Host
IPv4 address: 192.168.101.102
Comment: 내부망 웹서버#2
Check type: TCP
Interval: 15
Timeout: 5
Automatic firewall rules: 체크
Shutdown virtual server address: 체크 안함
Comment: UTM LSB Test
3. CentOS 웹서버
CentOS 7 iso 다운로드 : http://mirror.kakao.com/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso
CentOS 7을 최소 패키지로 설치한다.
WEB#1
- IP주소 : 192.168.101.101/24
- 게이트웨이 : 192.168.101.254
- DNS주소 : 192.168.101.254
WEB#2
- IP주소 : 192.168.101.100/24
- 게이트웨이 : 192.168.101.254
- DNS주소 : 192.168.101.254
4. SNAT 룰 설정
WEB#1, WEB#2 서버의 SNAT 설정을 한다.
[Network Protection] > [NAT] > [NAT] > [+ New NAT Rule...]
192.168.101.101 SNAT 설정
Group: :: No Group ::
Position: Bottom
Rule type: SNAT (source)
Matching condition
For traffic from: WEB#1 <-- + 를 클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
Add Network Definition
Name: WEB#1
Type: Host
IPv4 address: 192.168.101.101
Comment: 내부망 웹서버#1
Using service: Any
Going to: Any
Action
Change the source to: External [WEB#1] (Address) <-- 192.168.108.101
And the service to:
Automatic firewall rule: 체크 O
Comment: WEB#1 SNAT 설정
192.168.101.100 SNAT 설정
Group: :: No Group ::
Position: Bottom
Rule type: SNAT (source)
Matching condition
For traffic from: WEB#2 <-- + 를 클릭해서 아래처럼 생성한다. (이미 있다면 생략한다.)
Add Network Definition
Name: WEB#2
Type: Host
IPv4 address: 192.168.101.100
Comment: 내부망 웹서버#2
Using service: Any
Going to: Any
Action
Change the source to: External [WEB#1] (Address) <-- 192.168.108.101
And the service to:
Automatic firewall rule: 체크 O
Comment: WEB#2 SNAT 설정
5. DNS 설정
[Network Services] > [DNS] > [Global] > [Allowd Networks] 에 WEB#2를 추가한다.
- Internal (Networks)
- WEB#1
- WEB#2
6. 웹서버 설치 및 설정
UTM에서 방화벽 역할을 하므로 웹서버에서는 방화벽을 모두 내린다.
회사마다 정책이 다르므로 이 부분은 그 회사 정책을 따르지만 일반적으로 모두 내린다.
여기서는 APM중에서 아파치만 설정하는 것으로 한다.
WEB#1 설정
[root@web1 ~]# systemctl stop firewalld
[root@web1 ~]# systemctl disable firewalld
[root@web1 ~]# echo 192.168.101.101 web1.linuxmaster.net >> /etc/hosts
[root@web1 ~]# yum -y install httpd
[root@web1 ~]# systemctl enable httpd
[root@web1 ~]# systemctl start httpd
[root@web1 ~]# echo Welcome to 192.168.101.101. > /var/www/html/index.html
[root@web1 ~]# yum -y install lynx
WEB#2 설정
[root@web2 ~]# systemctl stop firewalld
[root@web2 ~]# systemctl disable firewalld
[root@web2 ~]# echo 192.168.101.100 web2.linuxmaster.net >> /etc/hosts
[root@web2 ~]# yum -y install httpd
[root@web2 ~]# systemctl enable httpd
[root@web2 ~]# systemctl start httpd
[root@web2 ~]# echo Welcome to 192.168.101.100. > /var/www/html/index.html
[root@web2 ~]# yum -y install lynx
7. 스크립트 생성
!!! 중요 !!!
LSB를 설정하기 위해서는 NAT > DNAT [WEB#1 DNAT 설정] 룰을 중지해야 한다.
WEB#1에서 아래 스크립트를 실행한다.
for i in $(seq 100)
do
lynx --dump 192.168.108.101
sleep 1
done
Welcome to 192.168.101.101.
Welcome to 192.168.101.101.
Welcome to 192.168.101.101.
:
:(생략)
WEB#1에서 아래 스크립트를 실행한다.
for i in $(seq 100)
do
lynx --dump 192.168.108.101
sleep 1
done
Welcome to 192.168.101.100.
Welcome to 192.168.101.100.
Welcome to 192.168.101.100.
:
:(생략)
'Linux > 보안장비 운용' 카테고리의 다른 글
| 백업 (1) | 2022.03.03 |
|---|---|
| pfsense 방화벽 설치하기 (1) | 2022.03.03 |
| NAT, DR, Tunneling (0) | 2022.03.03 |
| Anti port scan (0) | 2022.03.02 |
| slowhtptest DoS Attack (0) | 2022.03.02 |