IT/linux

centos7/redhat7 fresh install 후 기본 작업

울티마 2022. 6. 10. 14:42

1. hostname 변경
# hostnamectl set-hostname <호스트명>

2. Local YUM 구성 : 해당 버전 OS 이미지를 마운트하거나 iso 업로드해서 소프트마운트 (/mnt에 마운트한 경우 설명)
(1) createrepo 패키지 설치 (cdrom의 /Packages 디렉토리에 rpm 소스 있음)
# rpm -ivh deltarpm-3.6–3.el7.x86_64.rpm
# rpm -ivh python-deltarpm-3.6–3.el7.x86_64.rpm
# rpm -ivh libxml2-python-2.9.1–6.el7_2.3.x86_64.rpm
# rpm -ivh createrepo-0.9.9–28.el7.noarch.rpm

(2) repository 디렉토리 생성 후 Packages의 모든 파일 복사
# cd /mnt
# mkdir -p /redhat7media
# cp -R Packages/ /redhat7media/

(3) repository config 설정
# vi /etc/yum.repos.d/RedhatOS-Media.repo

[RedhatOS7Media]
name=RedhatOS-$releasever --Media
baseurl=file:///redhat7media/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

(4) repository db 생성
# createrepo /redhat7media/
# yum list
# yum list | wc -l

(5) package group 생성
# cd /mnt/repodata/
# ls
6d132b085489dcfe4a0ee2b4c38d9578c38ab83cebe4df87e3a409b48e8fee57-comps-Server.x86_64.xml
# createrepo -g /mnt/repodata/6d132b085489dcfe4a0ee2b4c38d9578c38ab83cebe4df87e3a409b48e8fee57-comps-Server.x86_64.xml /redhat7media/
# yum clean all
# yum makecache
# yum list | wc -l

3. 추가로 필요한 패키지 설치 (보안 및 편의 등)
(1) selinux 설정 툴 (semanage)
# yum install policycoreutils-python

(2) ifconfig 설치 (ip a 등의 사용이 불편할 경우)
# yum install net-tools

(3) X-Windows 환경 필요할 경우
# yum groupinstall “X Window System” 필수
# yum groupinstall “Fonts” 필수
# yum groupinstall “Korean Support” 한글 필요할 경우
# yum groupinstall “Desktop” 콘솔의 X-Windows 환경이 필요할 경우 -> 성능 영향, 서버 환경은 되도록 설치 지양

4. 방화벽 포트 개방
(1) 개방할 포트와 프로토콜 확인 후 변경
특정 포트 개방
# firewall-cmd --permanent --zone=public --add-port=8080/tcp
# firewall-cmd --reload

범위로 포트 개방
# firewall-cmd --permanent --zone=public --add-port=4000–4100/tcp
# firewall-cmd --reload

개방 포트 제거
# firewall-cmd --permanent --zone=public --remove-port=8080/tcp
# firewall-cmd --reload

(2) sshd 포트 변경
selinux 관리 툴인 semanage 툴 설치
# yum install policycoreutils-python

sshd 포트 변경
# vi /etc/ssh/sshd_config
Port 2022 <- 원하는 포트로 변경
# systemctl restart sshd.service <- 서비스 재가동

selinux 설정 변경
# semanage port -a -t ssh_port_t -p tcp 2022 <- SE Linux에 설정된 ssh 포트 변경
→ 이미 정의된 포트 및 프로토콜 전체는 # semanage port -l 명령으로 확인

방화벽 설정 및 리로드
# firewall-cmd --permanent --zone=public --add-port=20022/tcp
# firewall-cmd --reload

5. root login 금지
(1) 설정 파일 변경
설정 변경
# vi /etc/ssh/sshd_config
PermitRootLogin no <- no 로 설정

(2) 서비스 재가동
# systemctl restart sshd.service

6. NTP 구성
- ntp : 203.248.240.130 예
(1) 패키지 설치
# yum -y install ntp

(2) ntp server 설정
# vi /etc/ntp.conf
server 203.248.240.103

(3) firewall 설정
# firewall-cmd --add-service=ntp --permanent
# firewall-cmd --reload

- 방화벽 영구중지
# systemctl stop firewalld.service
# systemctl disable firewalld.service

(4) 서비스 가동
# systemctl start ntpd
# systemctl enable ntpd

(5) 확인
# ntpq -pn

7. 추가 패키지 설치
(1) telnet 클라이언트
# yum -y install /redhat7media/Packages/telnet-<버전>.x86_64.rpm
# systemctl start telnet.socket

(2) traceroute
# rpm -ivh /redhat7media/Packages/traceroute-<버전>.x86_64.rpm

(3) tcpdump
# yum -y install /redhat7media/Packages/tcpdump-<버전>.x86_64.rpm

'IT > linux' 카테고리의 다른 글

centos8/redhat8 install media > local yum repository  (0) 2022.06.10
centos7/redhat7 install media > local yum repository  (0) 2022.06.10
SELinux 설정 : semanage  (0) 2022.06.10
linux LVM  (0) 2022.06.10
creating over 2TB partition on linux  (0) 2022.06.10