리눅스

/etc/sysctl.conf , /etc/sysctl.d , sysctl -a와 -p ,

정지홍 2024. 8. 7. 16:10

다음 파일은 리눅스의 커널 파라미터를 설정하는데 사용한다.

이 파일로 시스템 부팅 시 커널의 동작을 변경할 수 있는 설정을 하는 것이 가능

주로 시스템 성능,보안,네트워크 설정을 조정할 때 사용

  • 이 파일은 key-value로 이루어지며, 각각의 라인은 하나의 설정을 의미함
  •  
[root@localhost etc]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
systemControl의 설정은 /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.에...
#
# Vendors settings live in /usr/lib/sysctl.d/.
제조사 설정은 /usr/lib/sysctl.d/.에.....
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. 
전체 덮어쓰기
# To override, only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
특정 부분만 하려면 나중에 나오는 파일의 이름을 추가고 새로운 설정을 넣으세요.
# For more information, see sysctl.conf(5) and sysctl.d(5).

/etc/sysctl.d

이 디렉토리는 커널 파라미터 설정 파일을 저장하는 데 사용

/etc/sysctl.conf와 같이 커널 파리미터 관리함

jihong@DESKTOP-4J10SP6:/etc/sysctl.d$ ll
total 24
drwxr-xr-x 1 root root  512 Jan  4  2023 ./
drwxr-xr-x 1 root root  512 Jul  7 11:18 ../
-rw-r--r-- 1 root root   77 Feb 25  2022 10-console-messages.conf
-rw-r--r-- 1 root root  490 Feb 25  2022 10-ipv6-privacy.conf
-rw-r--r-- 1 root root 1229 Feb 25  2022 10-kernel-hardening.conf
-rw-r--r-- 1 root root 1184 Feb 25  2022 10-magic-sysrq.conf
-rw-r--r-- 1 root root  158 Feb 25  2022 10-network-security.conf
-rw-r--r-- 1 root root 1292 Feb 25  2022 10-ptrace.conf
-rw-r--r-- 1 root root  506 Feb 25  2022 10-zeropage.conf
lrwxrwxrwx 1 root root   14 Sep 10  2022 99-sysctl.conf -> ../sysctl.conf
-rw-r--r-- 1 root root  798 Feb 25  2022 README.sysctl

10-console-messages.conf는 콘솔 메시지와 관련된 설정
10-ipv6-privacy.conf는 ipv6관련 설정
10-kernel-hardening.conf는 커널 관련 보안 설정
10-network-security.conf는 네트워크 보안
10-ptrace.conf는 ptrace시스템 호출과 관련된 보안
10-zeropage.conf는 제로페이지 관련 보안
99-sysctl.conf는 ../sysctl.conf의 심볼릭 링크

sysctl -a (현재 적용된 모든 커널 파라미터를 확인)

jihong@DESKTOP-4J10SP6:/etc/sysctl.d$ sysctl -a
fs.binfmt_misc.status = enabled
fs.binfmt_misc.WSLInterop = enabled
fs.binfmt_misc.WSLInterop = interpreter /init
fs.binfmt_misc.WSLInterop = flags:
fs.binfmt_misc.WSLInterop = offset 0
fs.binfmt_misc.WSLInterop = magic 4d5a
fs.inotify.max_queued_events = 16384
fs.inotify.max_user_instances = 128
fs.inotify.max_user_watches = 8192
fs.file-max = 1048576
kernel.cap_last_cap = 36
kernel.domainname = localdomain
kernel.hostname = DESKTOP-4J10SP6
kernel.keys.root_maxkeys = 1000000
kernel.osrelease = 4.4.0-19041-Microsoft
kernel.ostype = Linux
kernel.overflowgid = 65534
kernel.overflowuid = 65534
kernel.ngroups_max = 65536
kernel.pid_max = 32768
kernel.random.boot_id = 0fb6b789-d10e-406a-b7db-5b472f5a868f
kernel.random.entropy_avail = 4096
kernel.random.poolsize = 4096
kernel.random.uuid = 109b1b29-358d-47c5-85b3-8ef7517cc105
kernel.randomize_va_space = 2
kernel.sem = 32000      1024000000      500     32000
kernel.threads-max = 32768
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.yama.ptrace_scope = 1
net.bridge.bridge-nf-call-arptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-filter-pppoe-tagged = 0
net.bridge.bridge-nf-filter-vlan-tagged = 0
net.bridge.bridge-nf-filter-nf-pass-vlan-input-dev = 0
net.core.somaxconn = 128
net.ipv4.ip_forward = 1
vm.min_free_kbytes = 45056
vm.overcommit_memory = 0
vm.swappiness = 60

sysctl -p

/etc/sysctl.conf 및 /etc/sysctl.d/ 디렉토리에 있는 설정 파일들을 읽고 커널 파라미터를 적용하는 명령어

 


Kernel parameter apply

net.ipv4.tcp_tw_recyle ⇒ /proc/sys/net/ipv4/tcp_tw_recyle

echo 1 > /proc/sys/net/ipv4/tcp_tw_recyle

sysctl -a | grep tcp_tw

echo 0 > /proc/sys/net/ipv4/tcp_tw_recyle

sysctl -a | grep tcp_tw

vim /etc/sysctl.conf

net.ipv4.tcp_tw_recyle = 1

sysctl -p

sysctl -a | grep tcp_tw

echo 0 > /proc/sys/net/ipv4/tcp_tw_recyle

sysctl -a | grep tcp_tw

'리눅스' 카테고리의 다른 글

ip변경하는 쉘 스크립트  (0) 2024.08.08
shell script  (0) 2024.08.07
yum repository 설정  (0) 2024.08.05
hostnamectl set-hostname <HOSTNAME>  (0) 2024.08.03
/etc/security/limits.conf , /etc/security/limits.d/*  (0) 2024.08.03