※ 요약
필자는 간간이 ssh를 이용하고 있고, 가끔 접속 장애가 일어난다. 접속 장애가 일어났을때 매번 찾지 않기 위해 블로그에 정리해둔다. 출처는 땡깡님의 블로그이다.
 
※ 정리
1. 접속 대상이 없을 경우
ssh: connect to host 192.168.0.10 port 22: No route to host
서버가 down 상태이거나 ip 정보가 틀린 경우
 
2. netfilter(iptables)로 막아 놓았을 경우
ssh: connect to host 192.168.0.200 port 22: No route to host
웹서비스는 정상 접속되는 상태에서 ssh 접속이 안되는 경우
 
3. ssh 서비스가 구동중이지 않은 경우
ssh: connect to host 192.168.0.200 port 22: Connection refused
 
4. tcp_wrapper(/etc/hosts.deny)로 막아 놓은 경우
ssh_exchange_identification: Connection closed by remote host
 
5. 서비스 포트가 틀린 경우
ssh: connect to host 192.168.0.200 port 22: Connection refused
 
1번, 2번의 경우 접속 에러 로그는 동일하나 ping test 또는 다른 서비스 접속을 통해 어느 원인인지 확인 가능
3번, 5번의 경우 에러로그 상으로는 파악 불가

출처 : https://shaeod.tistory.com/582

아래와 같은 시스템로그가 계속 발생하는 것은 문제 없는, Info성 메시지이다. 하지만 이 부분이 거슬릴 경우 해당 메시지가 쌓이지 않도록 설정할 수 있다.

 

1. 아래 커맨드 입력을 통해 해당 로그가 쌓이지 않도록 설정해주자.

echo 'if $programname == "systemd" and ($msg contains "Starting Session" or $msg contains "Started Session" or $msg contains "Created slice" or $msg contains "Starting user-" or $msg contains "Starting User Slice of" or $msg contains "Removed session" or $msg contains "Removed slice User Slice of" or $msg contains "Stopping User Slice of") then stop' >> /etc/rsyslog.d/ignore-systemd-session-slice.conf

 ( 한줄이다. )

 

2. 설정파일 적용을 위해 rsyslog 재시작을 해주자.

systemctl restart rsyslog

 

출처 : https://growingsaja.tistory.com/217

RockyLinux8 이상에서 부팅시 생성되는 /var/log/dmesg 파일이 존재하지 않는 현상이 있었다.
이를 해결하기 위해 아래 방법을 수행하면 된다.

1) vi /etc/systemd/system/dmesg.service 파일에 아래 내용 추가  (해당 파일은 없으니 만들어야 함)

 [Unit]
 Description=Create /var/log/dmesg on boot
 ConditionPathExists=/var/log/dmesg

 [Service]
 ExecStart=/usr/bin/dmesg
 StandardOutput=file:/var/log/dmesg

 [Install]
 WantedBy=multi-user.target

2) /var/log/dmesg 파일 생성 및 SeLinux 컨텍스트 확인 (Selinux가 비활성화 상태면 dmesg파일만 만들면 된다.)

 # touch /var/log/dmesg
 # restorecon -v /var/log/dmesg (selinux 비활성화면 이 라인은 스킵)

3) 부팅 시 서비스가 시작되도록 활성화

 # systemctl enable dmesg

4) 시스템 재시작 (재부팅 후 /var/log/dmesg 파일 생성 및 파일 내용 확인 할 것)

 #shutdown -r now


참조 : https://www.getpagespeed.com/solutions/the-var-log-dmesg-file-is-not-created-during-boot-for-rocky-linux-8

HTTP 응답 코드 종류

 응답 코드 설명 
100   Continue (클라이언트로 부터 일부 요청을 받았으며 나머지 정보를 계속 요청함)
 101  Switching protocols
 200  OK(요청이 성공적으로 수행되었음)
 201  Created (PUT 메소드에 의해 원격지 서버에 파일 생성됨)
 202  Accepted(웹 서버가 명령 수신함)
 203  Non-authoritative information (서버가 클라이언트 요구 중 일부만 전송)
 204  No content, (사용자 요구 처리하였으나 전송할 데이터가 없음)
 301  Moved permanently (요구한 데이터를 변경된 타 URL에 요청함)
 302  Not temporarily
 304  Not modified (컴퓨터 로컬의 캐시 정보를 이용함, 대개 gif 등은 웹 서버에 요청하지 않음)
 400  Bad request (사용자의 잘못된 요청을 처리할 수 없음)
 401  Unauthorized (인증이 필요한 페이지를 요청한 경우)
 402  Payment required(예약됨)
 403  Forbidden (접근 금지, 디렉터리 리스팅 요청 및 관리자 페이지 접근 등을 차단)
 404  Not found, (요청한 페이지 없음)
 405  Method not allowed (혀용되지 않는 http method 사용함)
 407  Proxy authentication required (프락시 인증 요구됨)
 408  Request timeout (요청 시간 초과)
 410  Gone (영구적으로 사용 금지)
 412  Precondition failed (전체 조건 실패)
 414  Request-URI too long (요청 URL 길이가 긴 경우임)
 500  Internal server error (내부 서버 오류)
 501  Not implemented (웹 서버가 처리할 수 없음)
 503  Service unnailable (서비스 제공 불가)
 504  Gateway timeout (게이트웨이 시간 초과)
 505  HTTP version not supported (해당 http 버전 지원되지 않음)

 

 

HTTP 메소드 종류

 HTTP Method 전송 형태  설명 
 GET GET [request-uri]?query_string
HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n 
 GET 요청 방식은 URI(URL)가 가진 정보를
 검색하기 위해 서버 측에 요청하는형태이다

 

 HTTP Method 전송 형태  설명 
 POST POST [request-uri]?query_string
HTTP/1.1\r\n
HOST:[Hostname] 혹은 [IP] \r\n
Content-Lenght:[Lenght in Bytes] \r\n 
\r\n
[query-string] 혹은 [데이터]
POST 요청 방식은 요청 URI(URL)에
폼 입력을 처리하기 위해 구성한 서버 측 스크립트
(ASP, PHP, JSP 등) 혹은 CGI 프로그램으로
구성되고 Form Action과 함께 전송되는데,
이때 헤더 정보에 포함되지 않고 데이터 부분에 요청 정보가 들어가게 된다.

 

 HTTP Method 전송 형태  설명 
 HEAD HEAD [request-uri] HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n 
HEAD 요청 방식은 GET과 유사한 방식이나 웹 서버에서 헤더 정보 이외에는 어떤 데이터도 보내지 않는다.
웹 서버의 다운 여부 점검(Health Check)이나 웹 서버 정보(버전 등)등을 얻기 위해 사용될 수 있다. 

 

 HTTP Method 전송 형태  설명 
 OPTIONS OPTIONS [request-ri]
HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n 
해당 메소드를 통해 시스템에서 지원되는 메소드 종류를 확인할 수 있다. 

 

 HTTP Method 전송 형태  설명 
 PUT PUT [request-uri] HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n
Content-Lenght:[Length in Bytes] \r\n
Content-Type:[Content Type] \r\n
\r\n
[데이터] 
 POST와 유사한 전송 구조를 가지기 때문에 헤더 이외에 메시지(데이터)가 함께 전송된다.
원격지 서버에 지정한 콘텐츠를 저장하기 위해 사용되며 홈페이지 변조에 많이 악용되고 있다.

 

 HTTP Method 전송 형태  설명 
 DELETE DELETE [request-uri] HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n
\r\n 
 원격지 웹 서버에 파일을 삭제하기 위해 사용되며 PUT과는 반대 개념의 메소드이다.

 

 HTTP Method 전송 형태  설명 
 TRACE TRACE [request-uri] HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n
\r\n 
원격지 서버에 Loopback(루프백) 메시지를 호출하기 위해 사용된다. 

 

 HTTP Method 전송 형태  설명 
 CONNECT CONNECT [request-uri] HTTP/1.1\r\n
Host:[Hostname] 혹은 [IP] \r\n
\r\n 
 웹 서버에 프락시 기능을 요청할 때 사용된다.


출처 : https://gyrfalcon.tistory.com/m/entry/HTTP-%EC%9D%91%EB%8B%B5-%EC%BD%94%EB%93%9C-%EC%A2%85%EB%A5%98-HTTP-%EB%A9%94%EC%86%8C%EB%93%9C-%EC%A2%85%EB%A5%98

Apache 2.4.x 서버에서 mod_cband  (트래픽 사용량 제어 모듈) 설치시 다음과 같은 오류 메세지가 출력됩니다.

[ SUN(11.123) , /usr/local/src/mod-cband-0.9.7.5 ] > make

/usr/local/apache/bin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -c src/mod_cband.c
/usr/local/apr/build-1/libtool –silent –mode=compile gcc -std=gnu99 -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache/include -I/usr/local/apr/include/apr-1 -I/usr/local/apr-util/include/apr-1 -Wall -DDST_CLASS=3 -c -o src/mod_cband.lo src/mod_cband.c && touch src/mod_cband.slo
src/mod_cband.c: In function ‘mod_cband_create_traffic_size’:
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c: In function ‘mod_cband_get_dst’:
src/mod_cband.c:1333: error: ‘conn_rec’ has no member named ‘remote_ip’
src/mod_cband.c: In function ‘mod_cband_get_remote_host’:
src/mod_cband.c:1362: error: ‘struct conn_rec’ has no member named ‘remote_ip’
src/mod_cband.c:1363: error: ‘struct conn_rec’ has no member named ‘remote_ip’
src/mod_cband.c:1365: error: ‘struct conn_rec’ has no member named ‘remote_addr’
apxs:Error: Command failed with rc=65536
.
make: *** [src/.libs/mod_cband.so] 오류 1

mod_cband.c 파일을 편집합니다.

vi /usr/local/src/mod-cband-0.9.7.5/src/mod_cband.c

이때, src/.libs/mod_cband.c 라는 파일이 존재 않은 상태에서 작업해야 합니다.

빨간색은 수정 이전 라인, 파란색은 수정 이후 라인입니다.

1333번 라인
p.add.sin.s_addr = inet_addr(r->connection->remote_ip);
p.add.sin.s_addr = inet_addr(r->connection->client_ip);

1342번 라인
   fprintf(stderr,”%s leaf %s\n”,r->connection->remote_ip,leaf);
   fprintf(stderr,”%s leaf %s\n”,r->connection->client_ip,leaf);

1362~1365번 라인
if (c->remote_ip != NULL)
addr = inet_addr(c->client_ip);
else
addr = c->remote_addr->sa.sin.sin_addr.s_addr;

if (c->client_ip != NULL)
addr = inet_addr(c->client_ip);
else
addr = c->client_addr->sa.sin.sin_addr.s_addr;

위와 같이 수정한 다음 make 명령을 내리면 정상적으로 컴파일이 진행됩니다.

/usr/local/apache/bin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -c src/mod_cband.c
/usr/local/apr/build-1/libtool –silent –mode=compile gcc -std=gnu99 -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache/include -I/usr/local/apr/include/apr-1 -I/usr/local/apr-util/include/apr-1 -Wall -DDST_CLASS=3 -c -o src/mod_cband.lo src/mod_cband.c && touch src/mod_cband.slo
src/mod_cband.c: In function ‘mod_cband_create_traffic_size’:
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
/usr/local/apr/build-1/libtool –silent –mode=link gcc -std=gnu99 -o src/mod_cband.la -rpath /usr/local/apache/modules -module -avoid-version src/mod_cband.lo

write “make install” to install module

 

make install

/usr/local/apache/bin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -i -a -n cband src/mod_cband.la
/usr/local/apache/build/instdso.sh SH_LIBTOOL=’/usr/local/apr/build-1/libtool’ src/mod_cband.la /usr/local/apache/modules
/usr/local/apr/build-1/libtool –mode=install install src/mod_cband.la /usr/local/apache/modules/
libtool: install: install src/.libs/mod_cband.so /usr/local/apache/modules/mod_cband.so
libtool: install: install src/.libs/mod_cband.lai /usr/local/apache/modules/mod_cband.la
libtool: install: install src/.libs/mod_cband.a /usr/local/apache/modules/mod_cband.a
libtool: install: chmod 644 /usr/local/apache/modules/mod_cband.a
libtool: install: ranlib /usr/local/apache/modules/mod_cband.a
libtool: finish: PATH=”/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/java/bin:/root/bin:/sbin” ldconfig -n /usr/local/apache/modules
———————————————————————-
Libraries have been installed in:
/usr/local/apache/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
chmod 755 /usr/local/apache/modules/mod_cband.so
[activating module `cband’ in /usr/local/apache/conf/httpd.conf]

출처 : http://idchowto.com/tip-apache-2-4-x-%EC%84%9C%EB%B2%84%EC%97%90%EC%84%9C-mod_cband-%EC%84%A4%EC%B9%98%EC%8B%9C-%EC%98%A4%EB%A5%98-%EB%A9%94%EC%84%B8%EC%A7%80-%EC%B2%98%EB%A6%AC%EB%B0%A9%EB%B2%95/