반응형

설명

리눅스의 파일 및 폴더의 기본 퍼미션이 다르므로 특정 폴더의 하위 폴더와 파일의 퍼미션을 일괄변경하는 방법에 대해서 알아 봅니다. (퍼미션 일괄 변경은 파일 및 폴더의 갯수에 따라서 컴퓨터 또는 스토리지의 퍼포먼스를 저하시킬수 있으므로 작업전에 충분한 검토가 필요합니다)

 

 

특정 폴더의 모든 파일 퍼미션 변경

/data/nfs 폴더에 포함된 모든 파일의 퍼미션을 644로 변경하는 명령어 구문입니다.

[root@localhost ~]# find /data/nfs -type f -exec chmod -v 644 {} \;

 

 

특정 폴더의 모든 하위폴더의 퍼미션 변경

/data/nfs 폴더에 포함된 모든 하위 폴더의 퍼미션을 755로 변경하는 명령어 구문입니다.

[root@localhost ~]# find /data/nfs -type d -exec chmod -v 755 {} \;

 

 

반응형
반응형

설명

생성된 파일이나 폴더의 퍼미션을 변경하는 경우에는 chmod 명령어를 사용하지만, 앞으로 생성될 파일이나 폴더의 퍼미션을  미리 설정하는 명령어는 umask입니다. 이와 같은 특성으로 파일이나 폴더를 업로드하는 프로토콜인 FTP와 같은 곳에서 많이 사용됩니다. 이페이지에서는 숫자조합 위주로 설명하겠습니다.

 

 

UMASK 형식

chmod 명령어는 숫자조합(421)으로 퍼미션을 설정할 수 있습니다. umask도 비슷하게 숫자조합으로 생성될 파일이나 폴더의 퍼미션을 설정할 수 있습니다. 다만 chmod 명령어와 다른 점이 있는데, 시스템이 제공하는 기본 퍼미션인 666(파일)과 777(폴더)에서 특정 숫자조합(기본값 022)을 빼주는 형식으로 파일 및 폴더의 퍼미션을 설정합니다. 아래에서 간단한 예를 들었는데요, umask 명령어로 생성될 파일 및 폴더의 퍼미션을 022로 지정한면, 그 영향으로 파일과 폴더의 기본 퍼미션은 644와 755로 바뀌게 됩니다. 이것이 우리가 리눅스를 처음 설치하고 파일이나 폴더를 생성하면 퍼미션이 644와 755로 보이는 이유입니다.

 

### 시스템이 제공하는 기본 퍼미션 ###
파일 : 666
폴더 : 777

### UMASK로 퍼미션 조절 ###
[root@localhost ~]# umask 022

### UMASK로 퍼미션 조절한 결과 ###
파일 : 666 - 022 = 644
폴더 : 777 - 022 = 755

 

umask 명령어에서 사용하는 숫자조합을 조금 더 자세히 들여다보면, 아래의 내용과 같이 각 숫자는 특성을 갖습니다. 이런 특성을 이용하여 FTP와 같이 신규 파일이 업로드되는 서비스에서 효과적으로 생성되는 파일 및 폴더의 퍼미션을 조절할수 있습니다.

 

### umask 숫자별 퍼미션 ###
0 : 읽기(r) / 쓰기(w) / 실행(e)
1 : 읽기(r) / 쓰기(w)
2 : 읽기(r) / 실행(e)
3 : 읽기(r)
4 : 쓰기(w) / 실행(e)
5 : 쓰기(w)
6 : 실행(e)
7 : 퍼미션 없음

 

 

UMASK 변경

umask를 변경하는 것은 "umask 022"와 같이 간단한 명령 구문으로 가능합니다. 아래와 같이 현재의 umask 설정값을 확인할수도, 새로운 값으로 설정할수도 있습니다. 다만, "umask 000"와 같은 설정은 모든 사용자에게 모든 퍼미션을 허용하는 것이므로 사용상에 주의가 필요합니다.

 

### umask 현재 설정 확인 ###
[root@localhost ~]# umask
0022

### umask 설정 변경 ###
[root@localhost ~]# umask 024
반응형
반응형

설명

리눅스 환경에서 wget 명령어로 https 접속 또는 파일을 다운로드할 때 인증서 에러가 발생하는 경우가 있습니다. 이런 경우의 대처법을 알아봅니다.

 

 

에러 메세지

DEBUG output created by Wget 1.19.5 on linux-gnu.

Reading HSTS entries from /root/.wget-hsts
URI encoding = ‘UTF-8’
Converted file name 'index.html' (UTF-8) -> 'index.html' (UTF-8)
--2021-11-09 11:29:43-- https://DOMAIN/
Certificates loaded: 143
Resolving DOMAIN (DOMAIN)... xxx.xxx.xxx.xxx
Caching DOMAIN => xxx.xxx.xxx.xxx
Connecting to DOMAIN (DOMAIN)|xxx.xxx.xxx.xxx|:443... connected.
Created socket 3.
Releasing 0x000055e370123100 (new refcount 1).

ERROR: The certificate of ‘DOMAIN’ is not trusted.
ERROR: The certificate of ‘DOMAIN’ hasn't got a known issuer.

 

 

대응방법 (루트 인증서 설치)

루트 인증서가 설치되어 있지 않거나, 갱신되지 않아서 인증서 문제가 발생할수 있으므로, 아래와 같이 루트 인증서를 설치하거나 업데이트합니다.

### CentOS 7/8 ###

[root@localhost ~]# dnf -y install ca-certificates
or
[root@localhost ~]# dnf -y update ca-certificates

 

### Ubuntu 20.04 ###

root@localhost:~# apt -y install ca-certificates
or
root@localhost:~# apt -y upgrade ca-certificates

 

 

대응방법 (--no-check-certificate 옵션)

https 프로토콜을 사용할 때 굳이 인증서 확인이 필요 없다면 아래와 같이 인증서 확인을 무시하는 옵션을 포함하여 wget을 실행합니다.

[root@localhost ~]# wget --no-check-certificate https://DOMAIN/

 

 

대응방법 (인증서 재발급)

흔치 않는 경우지만, 가끔 인증서 갱신에서 중간 인증서와 루트 인증서 정보가 누락된채 발급되는 경우가 있습니다. 이렇게 생성된 인증서는 브라우저에서는 문제없이 동작할수도 있지만, wget과 같은 명령어에서는 인증서 에러가 발생합니다. 이런 경우 openssl 명령어로 간단히 확인할수 있습니다. 아래는 정상적인 depht와 chain 정보를 보여주는 예입니다.

[root@localhost ~]# openssl s_client -connect www.daum.net:443
CONNECTED(00000003)

depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
verify return:1
depth=0 C = KR, ST = Jeju-do, L = Jeju-si, O = Kakao Corp., CN = *.daum.net
verify return:1

---
Certificate chain
0 s:C = KR, ST = Jeju-do, L = Jeju-si, O = Kakao Corp., CN = *.daum.net
   i:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
1 s:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
   i:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
2 s:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
   i:C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
---

 

반대로 아래는 서버 인증서 만 존재할뿐, 중간(체인) 인증서 및 루트 인증서 정보가 없는 경우입니다. 이런 경우 wget과 같은 명령어로 https 프로토콜에 접속할 경우 인증서 에러가 발생하게 됩니다. 이와 같은 경우는, 신속하게 인증서를 재발급하는 것이 좋습니다.

[root@localhost ~]# openssl s_client -connect DOMAIN:443
CONNECTED(00000003)

depth=0 C = US, ST = California, L = Campbell, O = xxx CN = DOMAIN
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = US, ST = California, L = Campbell, O = xxx CN = DOMAIN
verify error:num=21:unable to verify the first certificate
verify return:1

---
Certificate chain
0 s:C = US, ST = California, L = Campbell, O = xxx CN = DOMAIN
   i:C = US, O = DigiCert Inc, CN = DigiCert TLS RSA SHA256 2020 CA1
---

 

반응형
반응형

CentOS에 기본 방화벽으로 올라가는 firewalld의 개인적으로 자주 사용하는 명령어들을 소개합니다. 설명에 사용되는 환경은 CentOS 8 최소설치입니다. (별도 안내 없이 필요한 경우 내용이 수정될 수 있습니다)




Built in service 리스트에 있는 서비스를 방화벽에 추가하기


「--get-services」 옵션을 사용하면, 내장형 서비스들을 볼 수 있습니다. 「--info-service=」 옵션에 서비스명을 더하여 실행하면 해당 서비스의 프로토콜 및 포트와 같은 정보를 볼 수 있습니다. 필요하다면, 이런 서비스를 활성화되어 있는 존에 추가하여 방화벽을 설정할 수 있습니다.


[root@localhost ~]# firewall-cmd --get-services

RH-Satellite-6 amanda-client amanda-k5-client ...



[root@localhost ~]# firewall-cmd --info-service=dns

dns

  ports: 53/tcp 53/udp

  protocols:

  source-ports:

  modules:

  destination:

  includes:

  helpers:



[root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=dns

success



[root@localhost ~]# firewall-cmd --reload

success



[root@localhost ~]# firewall-cmd --list-services

cockpit dhcpv6-client dns ssh



[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens32

  sources:

  services: cockpit dhcpv6-client dns ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:




Built in service 리스트에 없는 서비스를 방화벽에 추가하기


firewalld를 사용하다보면, 방화벽에 추가하고 싶은 서비스가 「Built in service」 리스트에 없는 경우가 있습니다. 방화벽에 해당 서비스 포트를 지정해서 추가할수도 있습니다만, 임의로 서비스를 등록해서 방화벽에 추가할수도 있습니다.


그럼, 방화벽의 서비스 리스트에서 임의로 서비스를 추가하는 방법에 대해서 알아 보겠습니다. 추가할 대상 서비스는 「rabbitmq」로 합니다. 임의로 생성하는 서비스는 사용되는 포트만 추가한 후, 마지막으로 방화벽에 임의 생성한 서비스를 등록해 보겠습니다.


[root@localhost ~]# firewall-cmd --get-services | grep rabbitmq

Nothing...



[root@localhost ~]# firewall-cmd --permanent --new-service=rabbitmq

success



[root@localhost ~]# firewall-cmd --permanent --service=rabbitmq --add-port=5671/tcp

success



[root@localhost ~]# firewall-cmd --permanent --add-service=rabbitmq

success



[root@localhost ~]# firewall-cmd --reload

success



[root@localhost ~]# firewall-cmd --get-services | grep rabbitmq

... rabbitmq ...



[root@localhost ~]# firewall-cmd --info-service=rabbitmq

rabbitmq

  ports: 5671/tcp

  protocols:

  source-ports:

  modules:

  destination:

  includes:

  helpers:



[root@localhost ~]# firewall-cmd --list-all

public (active)

  target: default

  icmp-block-inversion: no

  interfaces: ens32

  sources:

  services: cockpit dhcpv6-client dns rabbitmq ssh

  ports:

  protocols:

  masquerade: no

  forward-ports:

  source-ports:

  icmp-blocks:

  rich rules:




읽어 주셔서 감사합니다.

반응형

'Server > Linux' 카테고리의 다른 글

[리눅스] UMASK 명령어  (0) 2021.11.18
wget에서 인증서 에러  (0) 2021.11.09
[BIND] CentOS 7에서 DNS 설치  (0) 2020.07.17
CURL 또는 LYNX로 웹 사이트의 헤더 정보 확인하기  (0) 2019.07.02
Linux tar  (0) 2019.06.26
반응형

설명

CentOS 7에서 DNS 서비스를 설치하고 간단한 환경설정을 해봅니다.

 

 

서버 정보

버전 정보: bind-9.11.26-6

마스터 서버: 192.168.80.171

 

 

SELinux 비활성화

DNS 서버에서 SELinux를 사용하지 않으므로 비활성화 합니다.

### Inactive the SELinux ###
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@localhost ~]# reboot

 

 

Firewall에 DNS 서비스 추가

외부에서 DNS 서버로 접속할수 있도록, 파이어월에 dns 서비스를 추가합니다.

### Register dns service in the firewall ###
[root@localhost ~]# firewall-cmd --permanent --add-service=dns
[root@localhost ~]# firewall-cmd --reload

 

추가한 dns 서비스가 파이어월 서비스 리스트에 등록되었는지 확인합니다.

### Check the service list registered in the firewall ###
[root@localhost ~]# firewall-cmd --list-services
cockpit dhcpv6-client dns nfs proftpd ssh

 

dns 서비스의 포트 구성을 확인합니다.

### Check the dns service information in the firewall ###
[root@localhost ~]# firewall-cmd --info-service=dns
dns
  ports: 53/tcp 53/udp
  protocols:
  source-ports:
  modules:
  destination:
  includes:
  helpers:

 

 

패키지 설치

DNS 서비스에 필요한 패키지를 설치합니다.

### Install the BIND package ###
[root@localhost ~]# yum -y install bind bind-chroot bind-utils

 

 

DNS 서비스 활성화

bind와 bind-chroot 패키지를 설치하면, 각각 named와 named-chroot 데몬이 생성됩니다. chroot 기능이 포함된 DNS 서비스를 구성하므로 named-chroot 데몬을 활성화시킵니다. (named와 named-chroot 데몬은 동시에 실행시킬수 없습니다)

 

### Enable and Start the BIND Service ###
[root@localhost ~]# systemctl enable named-chroot
[root@localhost ~]# systemctl start named-chroot

 

named-chroot 데몬을 실행한후 "/var/named/chroot/etc" 폴더를 검색해보면, 아래와 같이 환경파일이 생성됩니다.

[root@localhost ~]# ls -al /var/named/chroot/etc
total 708
drwxr-x---  5 root named    186 Dec  6 12:52 .
drwxr-x---  7 root named     61 Dec  6 11:05 ..
drwxr-x---  3 root named     23 Dec  6 11:05 crypto-policies
-rw-r--r--. 2 root root     318 Oct 26 22:09 localtime
drwxr-x---  2 root named      6 Aug 25 08:20 named
-rw-r-----  1 root named   1705 Aug 25 08:20 named.conf
-rw-r-----  1 root named   1029 Aug 25 08:20 named.rfc1912.zones
-rw-r--r--  1 root named   1070 Aug 25 08:20 named.root.key
drwxr-x---  3 root named     25 Dec  6 11:05 pki
-rw-r--r--. 1 root root    6568 Sep 10  2018 protocols
-rw-r-----  1 root named    100 Dec  6 12:51 rndc.key
-rw-r--r--. 1 root root  692252 May 15  2020 services

 

 

DNS 초기화 (참고)

named-chroot 데몬에 대해서 구글링을 하다보면, named-chroot 데몬을 시작하기 전에 "/usr/libexec/setup-named-chroot.sh"을 실행하는 모습이 심심치않게 보여서 찾아봤습니다. 결론부터 말하면 현재 설치하는 버전에서는 별도로 "/usr/libexec/setup-named-chroot.sh"를 실행해서 초기화할 필요는 없어 보입니다. 그 이유에 대해서는 아래 내용에서 확인할수 있습니다.

 

■서비스 연관성

①"systemctl start named-chroot"를 실행하면, "named-chroot.service" 파일의 내용이 실행됩니다.

②"named-chroot.service" 파일에서 "named-chroot-setup" 서비스가 호출되며, "named-chroot-setup.service" 파일의 내용이 실행됩니다.

③"named-chroot-setup.service" 파일에서 다시 "setup-named-chroot.sh"이 실행되면서 초기화 작업이 진행됩니다.

 

자세한 흐름은 아래 파일의 내용을 참고해 주세요.

### named-chroot.service ###
[root@localhost ~]# cat /usr/lib/systemd/system/named-chroot.service

# Don't forget to add "$AddUnixListenSocket /var/named/chroot/dev/log"
# line to your /etc/rsyslog.conf file. Otherwise your logging becomes
# broken when rsyslogd daemon is restarted (due update, for example).

[Unit]
Description=Berkeley Internet Name Domain (DNS)
Wants=nss-lookup.target
Requires=named-chroot-setup.service
Before=nss-lookup.target
After=named-chroot-setup.service
After=network.target

[Service]
Type=forking
Environment=NAMEDCONF=/etc/named.conf
EnvironmentFile=-/etc/sysconfig/named
Environment=KRB5_KTNAME=/etc/named.keytab
PIDFile=/var/named/chroot/run/named/named.pid

ExecStartPre=/bin/bash -c 'if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -t \
/var/named/chroot -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi'
ExecStart=/usr/sbin/named -u named -c ${NAMEDCONF} -t /var/named/chroot $OPTIONS
ExecReload=/bin/sh -c 'if /usr/sbin/rndc null > /dev/null 2>&1; then /usr/sbin/rndc reload; else /bin/kill \
-HUP $MAINPID; fi'
ExecStop=/bin/sh -c '/usr/sbin/rndc stop > /dev/null 2>&1 || /bin/kill -TERM $MAINPID'
PrivateTmp=false

[Install]
WantedBy=multi-user.target

 

### named-chroot-setup.service ###
[root@localhost ~]# cat /usr/lib/systemd/system/named-chroot-setup.service

[Unit]
Description=Set-up/destroy chroot environment for named (DNS)
BindsTo=named-chroot.service
Wants=named-setup-rndc.service
After=named-setup-rndc.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/setup-named-chroot.sh /var/named/chroot on /etc/named-chroot.files
ExecStop=/usr/libexec/setup-named-chroot.sh /var/named/chroot off /etc/named-chroot.files

 

[root@localhost ~]# cat /etc/named-chroot.files
# Configuration of files used in chroot
# Following files are made available after named-chroot.service start
# if they are missing or empty in target directory.
/etc/localtime
/etc/named.root.key
/etc/named.conf
/etc/named.rfc1912.zones
/etc/rndc.conf
/etc/rndc.key
/etc/named.iscdlv.key
/etc/crypto-policies/back-ends/bind.config
/etc/protocols
/etc/services
/etc/named.dnssec.keys
/etc/pki/dnssec-keys
/etc/named
/usr/lib64/bind
/usr/lib/bind
/usr/share/GeoIP
/run/named
# Warning: the order is important
# If a directory containing $ROOTDIR is listed here,
# it MUST be listed last. (/var/named contains /var/named/chroot)
/var/named

 

 

DNS 환경파일 설정하기

아래는 bind 패키지를 설치하면 기본적으로 제공되는 named.conf 파일의 내용입니다. 내용을 살펴보면 IPv4와 IPv6 환경은 "127.0.0.1"과 "::1"로 제한되어 있으며, DNS 서버에 질의를 허용하는 옵션인 "allow-query"는 localhost로 제안되어 있기 때문에 외부에서 이 DNS 서버로 도메인 해석을 질의해도 응답하지 않도록 설정되어 있습니다.

 

### /etc/named.conf ###
options {
        listen-on port 53      { 127.0.0.1; };
        listen-on-v6 port 53   { ::1; };
        directory              "/var/named";
        dump-file              "/var/named/data/cache_dump.db";
        statistics-file        "/var/named/data/named_stats.txt";
        memstatistics-file     "/var/named/data/named_mem_stats.txt";
        secroots-file          "/var/named/data/named.secroots";
        recursing-file         "/var/named/data/named.recursing";
        allow-query            { localhost; };

        recursion              yes;

        dnssec-enable          yes;
        dnssec-validation      yes;

        managed-keys-directory "/var/named/dynamic";

        pid-file               "/run/named/named.pid";
        session-keyfile        "/run/named/session.key";

        include                "/etc/crypto-policies/back-ends/bind.config";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
        type hint;
        file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

 

이제 몇 가지 조건을 붙여서 named.conf의 설정을 조금 변경해 보겠습니다.

 

내부 도메인 해석에 대한 질의/응답을 내부 네트워크로 제한하는 경우 (폐쇄형 DNS에 적용)

우선 DNS 서버 외의 IP 주소에서도 네트워크 통신이 가능하도록 "listen-on port 53"와 "listen-on-v6 port 53"를 "자신의 DNS 서버 IP"로 변경합니다. 내부 네트워크(office-nets)에서 도메인 해석 질의가 가능하도록 "allow-query"를 "office-nets"로 제한하도록 설정합니다. 마지막으로 recursion 옵션을 no로 설정하므로서 DNS 서버에서 설정된 Zone 외에는 도메인 해석 질의가 불가능하도록 제한합니다. 

### /etc/named.conf ###
acl office-nets {
        192.168.80.0/24;
};

options {
        listen-on port 53     { 192.168.80.171; };
        listen-on-v6 port 53  { fe80::20c:29ff:fe24:2e78; };
        ...
        allow-query           { office-nets; };

        recursion             no;
        ...
};

 

 

내부 도메인 해석에 대한 질의/응답을 모든 네트워크에 허용하는 경우 (자사 서비스 DNS에 적용)

모든 네트워크에서 도메인 해석 질의에 대해 응답이 가능하도록 "allow-query"를 any로 설정하며, "recursion"을 no로 설정하여 DNS 서버에서 설정한 Zone으로 질의/응답 범위를 내부 도메인으로 제한합니다. (실제 환경에서 "listen-on port 53"와 "listen-on-v6 port 53"에서 설정하는 IP는 반드시 Public IP여야만 합니다)

### /etc/named.conf ###
options {
        listen-on port 53     { 192.168.80.171; };
        listen-on-v6 port 53  { fe80::20c:29ff:fe24:2e78; };
        ...
        allow-query           { any; };

        recursion             no;
        ...
};

 

 

내/외부 도메인 해석에 대한 질의/응답을 내부 네트워크로 제한하는 경우 (사내 DNS에 적용)

도메인 해석 질의를 내부 네트워크인 "office-nets"로 제한하며, 내/외부 모든 도메인 해석이 가능하도록 recursion 옵션을 yes로 변경합니다.

### /etc/named.conf ###
acl office-nets {
        192.168.80.0/24;
};

options {
        listen-on port 53     { 192.168.80.171; };
        listen-on-v6 port 53  { fe80::20c:29ff:fe24:2e78; };
        ...
        allow-query           { office-nets; };

        recursion             yes;
        ...
};

 

 

내/외부 도메인 해석에 대한 질의/응답을 모든 네트워크에 허용하는 경우 (포탈 사이트의 DNS 또는 Public DNS)

모든 네트워크에서 질의가 가능하도록 "allow-query"를 any로 설정하며, 내/외부 모든 도메인 해석이 가능하도록 recursion 옵션을 yes로 변경합니다. (실제 환경에서 "listen-on port 53"와 "listen-on-v6 port 53"에서 설정하는 IP는 반드시 Public IP여야만 합니다)

### /etc/named.conf ###
options {
        listen-on port 53     { 192.168.80.171; };
        listen-on-v6 port 53  { fe80::20c:29ff:fe24:2e78; };
        ...
        allow-query           { any; };

        recursion             yes;
        ...
};

 

 

몇 가지 설정할수 있는 유형에 대해서 알아 보았는데요, 일견 모든 네트워크에서 모든 도메인에 대해 질의와 해석이 가능하도록 설정하는 것이 이상적으로 보일수 있지만, DNS 공격에 악용될수 있으므로 반드시 목적에 맞게 서비스 범위를 제한하도록 설정합시다.

반응형

'Server > Linux' 카테고리의 다른 글

wget에서 인증서 에러  (0) 2021.11.09
firewall-cmd --new-service  (0) 2020.10.08
CURL 또는 LYNX로 웹 사이트의 헤더 정보 확인하기  (0) 2019.07.02
Linux tar  (0) 2019.06.26
Ubuntu 고정 IP 설정  (0) 2019.02.07
반응형

CURL 명령어와 LYNX 명령어로 대상 웹 사이트의 헤더 정보를 살펴볼 수 있습니다.

[root@localhost ~]# yum -y -q install curl

[root@localhost ~]# curl -I http://localhost
HTTP/1.1 302 Found
Date: Tue, 02 Jul 2019 01:08:05 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.3.6
Location: https://www.xxx.xxx
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# yum -y -q install lynx

[root@localhost ~]# lynx -head -mime_header http://localhost
HTTP/1.1 302 Found
Date: Tue, 02 Jul 2019 01:08:19 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.3.6
Location: https://www.xxx.xxx
Connection: close
Content-Type: text/html; charset=iso-8859-1

 

다만, HTTPS 프로토콜에 대해서는 정상적으로 SSL 인증서가 설치되어 있지 않을 경우, 아래와 같은 에러가 발생할 수 있습니다.

[root@localhost ~]# curl -I https://localhost

curl: (60) Issuer certificate is invalid.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
[root@localhost ~]# lynx -head -mime_header https://localhost

Looking up localhost
Making HTTPS connection to localhost
SSL callback:unable to get local issuer certificate, preverify_ok=0, ssl_okay=0
Retrying connection without TLS.
Looking up localhost
Making HTTPS connection to localhost
Alert!: Unable to make secure connection to remote host.

lynx: Can't access startfile https://localhost/
반응형

'Server > Linux' 카테고리의 다른 글

firewall-cmd --new-service  (0) 2020.10.08
[BIND] CentOS 7에서 DNS 설치  (0) 2020.07.17
Linux tar  (0) 2019.06.26
Ubuntu 고정 IP 설정  (0) 2019.02.07
Change the time zone on Linux  (0) 2018.11.07
반응형

tar 명령어로 절대경로를 지정하여 파일을 압축 또는 해제할 때, "tar: Removing leading `/' from member names"와 같은 출력문을 접하게 됩니다. 아래의 내용은 절대경로를 지정하여 파일을 압축하였을 때, 절대경로에서 선행문자인 "/"을 삭제한다는 메세지를 보여줍니다. 이런 메세지가 표시되더라도 CLI 환경에서 직접 압축 및 해동에서는 거의 문제가 발생하지 않습니다만, 스크립트로 tar 명령어가 실행될 때에는 정상적으로 압축 및 해제가 되지 않을 수도 있습니다.

[root@localhost ~]# tar cfz /root/test.tar /root/test.txt
tar: Removing leading `/' from member names

[root@localhost ~]# tar xfz /root/test.tar
tar: Removing leading `/' from member names

이런 경우에는 tar 명령어에 P 옵션을 붙여서 실행하면, 지정된 절대경로에서 선행문자인 "/"가 삭제되지 않고 그대로 붙어서 압축 및 해제가 진행됩니다.

[root@localhost ~]# tar cfzP /root/test.tar /root/test.txt

[root@localhost ~]# tar xfzP /root/test.tar
반응형

'Server > Linux' 카테고리의 다른 글

firewall-cmd --new-service  (0) 2020.10.08
[BIND] CentOS 7에서 DNS 설치  (0) 2020.07.17
CURL 또는 LYNX로 웹 사이트의 헤더 정보 확인하기  (0) 2019.07.02
Ubuntu 고정 IP 설정  (0) 2019.02.07
Change the time zone on Linux  (0) 2018.11.07
반응형

Ubuntu 16


설정파일 : /etc/network/interfaces


고정 IP로 설정할 인터페이스를 확인후, 아래 내용과 같이 관련 네트워크 정보를 추가해 줍니다.


# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface lo inet loopback


auto enp0s31f6

iface enp0s31f6 inet static

    address 192.168.0.100

    netmask 255.255.255.0

    network 192.168.0.0

    broadcast 192.168.0.255

    gateway 192.168.0.1

    dns-nameservers 8.8.8.8 192.168.0.1

    dns-domain domain.com

    dns-search domain.com


root@localhost:~$ sudo systemctl restart networking





Ubuntu 18


설정파일 : /etc/netplan/.yaml


초기 설치 후 해당 폴터에서 확장자가 "yaml"인 파일을 열어서 설정합니다.


# This file is generated from information provided by

# the datasource.  Changes to it will not persist across an instance.

# To disable cloud-init's network configuration capabilities, write a file

# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:

# network: {config: disabled}

network:

    ethernets:

        enp0s31f6:

            addresses: [192.168.0.100/24]

            gateway4: 192.168.0.1

            nameservers:

                addresses: [8.8.8.8,192.168.0.1]

            dhcp4: no

    version: 2


root@localhost:~$ sudo netplan apply


반응형

'Server > Linux' 카테고리의 다른 글

firewall-cmd --new-service  (0) 2020.10.08
[BIND] CentOS 7에서 DNS 설치  (0) 2020.07.17
CURL 또는 LYNX로 웹 사이트의 헤더 정보 확인하기  (0) 2019.07.02
Linux tar  (0) 2019.06.26
Change the time zone on Linux  (0) 2018.11.07

+ Recent posts