실습> 원격 로그 서버 구축하기
서버 A: 192.168.101.101 원격로그클라이언트 웹서버
서버 B: 192.168.101.254 원격 로그 서버
원격 로그서버: 서버 A의 로그 정보를 저장하는 서버
외부에서 서버A로 접속하면
자신(A)의 로그에도 기록되고 원격 로그서버(B)에도 기록되게 설정한다.
[Internet]---+------ [서버A 원격로그클라이언트 웹서버] 192.168.101.101
|
+------ [서버B 원격로그서버] 192.168.101.254
로그 포트 : syslog 514/TCP, 514/UDP
1. 원격 로그 서버 설정
원격 로그서버인 서버B에서 설정한다.
아래 TCP/UDP 514번의 4줄의 주석을 해제한다.
LogServer# vi /etc/rsyslog.conf
-- /etc/rsyslog.conf --
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
-- /etc/rsyslog.conf --
LogServer# systemctl restart rsyslog
LogServer# netstat -nltup|grep rsyslog
tcp 0 0 0.0.0.0:514 0.0.0.0:* LISTEN 2428/rsyslogd
tcp6 0 0 :::514 :::* LISTEN 2428/rsyslogd
udp 0 0 0.0.0.0:514 0.0.0.0:* 2428/rsyslogd
udp6 0 0 :::514 :::* 2428/rsyslogd
방화벽 firewalld 로 설정된 경우
firewall-cmd --add-port=514/tcp --permanent
firewall-cmd --add-port=514/udp --permanent
firewall-cmd --reload
방화벽 iptables 로 설정된 경우
iptables -I INPUT -p tcp --dport 514 -j ACCEPT # -s IP주소
iptables -I INPUT -p udp --dport 514 -j ACCEPT # -s IP주소
방화벽을 내리고 할 경우
LogServer# systemctl stop firewalld
LogServer# systemctl disable firewalld
LogServer# iptables -F
2. 원격 로그 클라이언트 설정
/etc/rsyslog.conf 설정파일에서 맨 아래 라인에 원격 로그서버로 보내는 설정이 있다.
그 라인을 주석처리한 후 로그서버의 IP주소 or 도메인을 설정한다.
LogClient# vi /etc/rsyslog.conf
*.* @@192.168.101.254:514
LogClient# systemctl restart rsyslog
3. 로그 모니터링
로그 서버쪽에 모니터링을 설정한다.
LogServer# tail -f /var/log/secure
로그 클라이언트쪽에 모니터링을 설정한다.
LogClient# tail -f /var/log/secure
4. 로그 클라이언트 접속
ssh 로 접속을 해서 로컬과 원격 로그서버로 전송 되는지 확인한다.
login as: root
root@192.168.101.101's password:
Last login: Fri Mar 4 20:48:05 2022 from 192.168.101.1
LogClient#
로그 클라이언트쪽에 아래처럼 로그가 기록된다.
LogClient# tail -f /var/log/secure
Mar 4 20:48:37 web1 sshd[9458]: Accepted password for root from 192.168.101.1 port 26111 ssh2
Mar 4 20:48:37 web1 sshd[9458]: pam_unix(sshd:session): session opened for user root by (uid=0)
로그 클라이언트가 로그 서버쪽으로 로그를 전송하므로 로그 서버쪽에 아래처럼 로그가 기록된다.
LogServer# tail -f /var/log/secure
Mar 4 20:48:37 web1 sshd[9458]: Accepted password for root from 192.168.101.1 port 26111 ssh2
Mar 4 20:48:37 web1 sshd[9458]: pam_unix(sshd:session): session opened for user root by (uid=0)
'Linux > 보안장비 운용' 카테고리의 다른 글
| logrotate 실행하기 (0) | 2022.03.04 |
|---|---|
| 로그 관리 프로그램 logrotate (0) | 2022.03.04 |
| 장치에 로그 출력하기 (0) | 2022.03.04 |
| /etc/rsyslog.conf (0) | 2022.03.04 |
| rsyslog 데몬 (0) | 2022.03.04 |