리눅스 네트워크 서비스
IT 위키
더 많은 작업
리눅스 서버에서 운영하는 웹, 인증, 파일 공유, 메일, DNS, 가상화 등 네트워크 서비스의 패키지·데몬·설정 파일을 한곳에 정리한 문서이다. 각 서비스의 자세한 설정은 링크된 문서를 본다.
Rocky Linux 8 기준이다.
| 서비스 | 패키지 | 데몬(systemd 유닛) | 주 설정 파일 | 기본 포트 |
|---|---|---|---|---|
| 웹 (Apache) | httpd | httpd | /etc/httpd/conf/httpd.conf | 80, 443 |
| FTP | vsftpd | vsftpd | /etc/vsftpd/vsftpd.conf | 20, 21 |
| Samba | samba | smb, nmb | /etc/samba/smb.conf | 139, 445 (TCP), 137, 138 (UDP) |
| NFS | nfs-utils | nfs-server | /etc/exports | 2049 |
| 메일 송신 (MTA) | sendmail 또는 postfix | sendmail / postfix | /etc/mail/sendmail.cf, /etc/postfix/main.cf | 25 |
| 메일 수신 (POP·IMAP) | dovecot | dovecot | /etc/dovecot/dovecot.conf | 110, 143, 993, 995 |
| DNS | bind | named | /etc/named.conf | 53 |
| DHCP | dhcp-server | dhcpd | /etc/dhcp/dhcpd.conf | 67, 68 (UDP) |
| 시간 동기화 | chrony | chronyd | /etc/chrony.conf | 123 (UDP) |
| NIS | ypserv, ypbind | ypserv, ypbind | /etc/yp.conf, /var/yp/Makefile | portmap(111) 사용 |
| 프록시 (Squid) | squid | squid | /etc/squid/squid.conf | 3128 |
| SSH | openssh-server | sshd | /etc/ssh/sshd_config | 22 |
| 가상화 (KVM) | qemu-kvm, libvirt | libvirtd | /etc/libvirt/ | - |
# 설치, 시작, 부팅 시 자동 시작, 방화벽 허용 (httpd 예) # dnf install httpd # systemctl enable --now httpd # firewall-cmd --permanent --add-service=http # firewall-cmd --reload
- 아파치 설정 파일 구조 : /etc/httpd/conf/httpd.conf, /etc/httpd/conf.d/*.conf, 모듈 설정 /etc/httpd/conf.modules.d/
- 문서 루트 : /var/www/html, 로그 : /var/log/httpd/access_log, error_log
| 지시자 | 의미 |
|---|---|
| ServerRoot | 설정 파일의 기준 디렉터리 (/etc/httpd) |
| Listen | 요청을 받을 포트 (Listen 80) |
| User, Group | 웹 서버 프로세스 소유자 (apache) |
| ServerAdmin | 관리자 메일 주소 |
| ServerName | 서버의 도메인 이름과 포트 |
| DocumentRoot | 웹 문서 루트 디렉터리 |
| DirectoryIndex | 디렉터리 요청 때 보여 줄 기본 파일 (index.html) |
| UserDir | 사용자 홈 디렉터리의 웹 문서 디렉터리 (public_html) |
| ErrorLog, CustomLog, LogLevel | 로그 파일과 수준 |
| AllowOverride | .htaccess로 덮어쓸 수 있는 설정 범위 (None, All, AuthConfig) |
| Require | 접근 허용 (Require all granted, Require ip 192.168.0.0/24) |
| Options | Indexes(목록 표시), FollowSymLinks, ExecCGI |
| Timeout, KeepAlive, MaxKeepAliveRequests | 연결 유지 설정 |
- 가상 호스트 : 한 서버에서 여러 도메인을 운영한다.
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/example
ErrorLog logs/example-error_log
</VirtualHost>
윈도 네트워크(SMB/CIFS)와 파일·프린터를 공유한다. 자세한 내용은 리눅스 samba 문서를 본다.
# /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
hosts allow = 192.168.0.
[share]
path = /data/share
comment = 공유 폴더
writable = yes
valid users = kaituser
browseable = yes
- Samba 사용자는 시스템 계정이 있어야 하고 smbpasswd -a로 따로 등록한다.
- 점검 : testparm, 접속 : smbclient //서버/share -U 사용자, 상태 : smbstatus
- 리눅스에서 윈도 공유 마운트 : mount -t cifs //서버/share /mnt -o username=사용자
유닉스·리눅스끼리 디렉터리를 네트워크로 공유한다. 자세한 내용은 리눅스 NFS 문서를 본다.
# /etc/exports /data/nfs 192.168.0.0/24(rw,sync,no_root_squash) *.example.com(ro)
- vsftpd 주요 설정 : anonymous_enable, local_enable, write_enable, local_umask, chroot_local_user, userlist_enable, listen, listen_ipv6
- 접근 제한 파일 : /etc/vsftpd/ftpusers(접속 금지), /etc/vsftpd/user_list
- 전송 기록 : /var/log/xferlog
- 액티브 모드는 서버가 20번 포트에서 클라이언트로 데이터 연결을 걸고, 패시브 모드는 클라이언트가 서버의 임의 포트로 연결한다.
- 자세한 내용은 리눅스 vsftpd.conf 문서를 본다.
- 구성 요소 : MUA(메일 클라이언트) → MTA(메일 전송, SMTP) → MDA(메일함 배달) → MUA가 POP·IMAP으로 가져감
- sendmail 주요 파일
- /etc/mail/sendmail.cf : 주 설정 파일. 보통 sendmail.mc를 고친 뒤 m4로 만든다.
- /etc/mail/local-host-names : 메일을 받을 도메인
- /etc/mail/access : 릴레이 허용·거부 (RELAY, OK, REJECT, DISCARD)
- /etc/mail/virtusertable : 가상 메일 주소를 실제 계정으로 연결
- /etc/aliases : 메일 별칭. 고친 뒤 newaliases를 실행한다.
- ~/.forward : 사용자별 메일 전달
- access, virtusertable은
makemap hash /etc/mail/access < /etc/mail/access로 DB를 만든다. - 메일 대기열 확인 : mailq (sendmail -bp)
- postfix : sendmail을 대신하는 MTA. /etc/postfix/main.cf의 myhostname, mydomain, inet_interfaces, mynetworks
- dovecot : POP3·IMAP 서버. protocols = imap pop3
BIND(named)로 운영한다. 자세한 내용은 리눅스 named.conf, 리눅스 zone 파일 문서를 본다.
- /etc/named.conf : options(listen-on, directory, allow-query, forwarders, recursion)와 zone 선언
- /etc/named.rfc1912.zones : 추가 zone 선언을 두는 파일
- /var/named/ : zone 파일 위치
zone "example.com" IN {
type master;
file "example.com.zone";
allow-update { none; };
};
- zone 파일 레코드 : SOA(권한 시작), NS(네임 서버), A(IPv4), AAAA(IPv6), CNAME(별칭), MX(메일 서버), PTR(역방향), TXT
- 점검 : named-checkconf, named-checkzone, 관리 : rndc reload
- 질의 : nslookup, dig, host
자세한 내용은 리눅스 가상화 문서를 본다.
- 전가상화(Full Virtualization)와 반가상화(Para Virtualization), 하드웨어 지원 가상화(Intel VT-x, AMD-V)
- KVM : 리눅스 커널에 들어 있는 하이퍼바이저 모듈. QEMU, libvirt와 함께 쓴다. 관리 도구 virsh, virt-install, virt-manager
- Xen : 반가상화에서 출발한 하이퍼바이저
- 컨테이너 : 도커(docker), Podman. RHEL 8은 기본 컨테이너 도구로 Podman을 제공한다.
- CPU 가상화 지원 확인 :
grep -E 'vmx|svm' /proc/cpuinfo
- DHCP : IP 주소 자동 할당. subnet, range, option routers, option domain-name-servers, default-lease-time, max-lease-time, 고정 할당은 host 블록에 hardware ethernet과 fixed-address
- 시간 동기화 : chrony가 ntpd를 대신한다. /etc/chrony.conf의 server·pool, 확인 chronyc sources. 리눅스 ntp 참조
- Squid : 캐시 프록시 서버. http_port, cache_dir, acl, http_access
- xinetd : 요청이 올 때만 서비스를 띄우는 슈퍼 데몬. /etc/xinetd.d/서비스 파일의 disable, socket_type, user, server, only_from
- systemd 소켓 활성화 : xinetd 대신 .socket 유닛으로 같은 기능을 한다.
- 서비스별 패키지·데몬·설정 파일·포트 대응
- httpd.conf 지시자 (DocumentRoot, DirectoryIndex, UserDir, Listen, AllowOverride, Require)
- /etc/exports 옵션과 exportfs -ra
- smb.conf 섹션 구조와 smbpasswd -a
- sendmail 파일 역할 (access, virtusertable, aliases, local-host-names)과 makemap, newaliases
- named.conf zone 선언과 zone 파일 레코드