Skip to content

Instantly share code, notes, and snippets.

@rolroralra
Last active January 27, 2022 02:27
Show Gist options
  • Save rolroralra/15bb59c9fc83eb196b1a8339a694d110 to your computer and use it in GitHub Desktop.
Save rolroralra/15bb59c9fc83eb196b1a8339a694d110 to your computer and use it in GitHub Desktop.
Network

RPC, REST, gRPC

https://livlikwav.github.io/study/grpc-and-its-history/


How to delete Network Interface

$ ip link delete vxlan.calico

How to install DNS Server in Ubuntu (bind9)

How To Configure BIND as a Private Network DNS Server on Ubuntu 18.04

Details

$ sudo su
$ apt update
$ apt install bind9 bind9utils bind9-doc

$ systemctl status bind9
● bind9.service - BIND Domain Name Server
   Loaded: loaded (/lib/systemd/system/bind9.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-06-27 02:24:44 KST; 58min ago
     Docs: man:named(8)
  Process: 8723 ExecStop=/usr/sbin/rndc stop (code=exited, status=0/SUCCESS)
 Main PID: 8726 (named)
    Tasks: 11 (limit: 4915)
   CGroup: /system.slice/bind9.service
           └─8726 /usr/sbin/named -f -u bind -4

$ vi /etc/default/bind9
...
OPTIONS="-u bind -4"

$ vi /etc/bind/named.conf.options
...
options {
 ...
listen-on port 53 {
    localhost; 70.50.183.0/24;
  };

  allow-query {
    any;
  };
...
}


$ vi /etc/bind/named.conf.local
...
// forward zone config
zone "nexledger.com" {
  type master;
  file "/etc/bind/zones/db.nexledger.com"; # zone file path
};

// backward zone config
zone "183.50.70.in-addr.arpa" {
  type master;
  file "/etc/bind/zones/db.nexledger.com.rev"; # zone file path
};


$ mkdir /etc/bind/zones

$ vi /etc/bind/zones/db.nexledger.com
$TTL    604800
@       IN      SOA     ns1.nexledger.com. root.nexledger.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

; name server - NS records
@  IN  NS  ns.nexledger.com.

; name servers - A records
ns IN  A 70.50.183.152

; 70.50.183.0/24 - A records
worker01 IN  A 70.50.183.49
worker02 IN  A 70.50.183.110
worker03 IN  A 70.50.183.111
worker04 IN  A 70.50.183.63



$ vi /etc/bind/zones/db.chat.nexledger.com.rev
$TTL    604800
@       IN      SOA     nexledger.com. root.nexledger.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

; name servers
@  IN  NS  ns.

; PTR Records
152 IN  PTR   ns1.nexledger.com.  ; 70.50.183.152
49  IN  PTR   worker01.nexledger.com. ; 70.50.183.49
110 IN  PTR   worker02.nexledger.com. ; 70.50.183.110
111 IN  PTR   worker03.nexledger.com. ; 70.50.183.111
63  IN  PTR   worker04.nexledger.com. ; 70.50.183.63



$ named-checkconf

$ named-checkzone nexledger.com db.nexledger.com

$ systemctl restart bind9

$ nslookup worker01.nexledger.com


How to set DNS server in client Ubuntu Server

Details

$ sudo su

$ vi /etc/resolv.conf
nameserver 70.50.183.87
nameserver 127.0.0.53

$ apt install resolvconf

# resolv.conf 재적용
$ resolvconf -u

$ vi /etc/environment
no_proxy="127.0.0.1,localhost,chat.nexledger.com"


/etc/resolv.conf

http://700billion.blogspot.com/2012/02/etcresolvconf.html

Details

  • domain

기본도메인을 설정한다.
만약 domain 지시자를 이용해서 기본 도메인을 설정하였다면 호스트네임을 보고 기본 도메인을 결정하는것이 아니라 resolv.conf 파일에있는 domain 지시자에 설정된도메인을 기본도메인으로 가지게된다.
즉 호스트네임보다는 resolv.conf 의 domain 지시자에게 정의된 기본 도메인이 우선한다는 의미이다.

  • search

이 역시 domain 지시자와 같이 기본 도메인을 설정하는 기능을가진다.
이 지시자는 한 라인에 여러게의 도메인을 지정할수있다.

  • nameserver

이 지시자는 질의할 네임서버의 주소를 Resolver에게 알려주어 해당 네임서버를 사용할수있게끔 한다.
이 지시자를 사용하여 최대 3 개의 네임서버를 설정할수있다.

  • sortlist

이 지시자는 질의에대한 응답으로 하나 이상의 IP 정보를 리턴할때 선호하는 네트워크와 서브넷을 지정하여
리졸버가 여러개의 주소중 원하는 네트워크 IP 주소를 우선적으로 가지도록 설정한다.

  • option
    • ndots

    search 리스트의 도메인들을 뒤에 덧붙이기 전에 리졸버가 입력받은 이름을 그래도 탐색할수 있도록 압력받은 도메인 네임이 반드시 가져야하는 . 의 최소갯수이다.


$ vi /etc/resolv.conf
# nameserver
nameserver 8.8.8.8

# search
search default.svc.cluster.local svc.cluster.local cluster.local asia-northeast1-a.c.beaming-talent-265001.internal c.beaming-talent-265001.internal google.internal

# domain
domain www.naver.com

# sortlist
sortlist 192.168.0.1/255.255.255.0

# options
options ndots:5


How to install NTP Server (Network Time Protocl)

How to install NTP Server in Window10

Details

$ sudo apt install ntp

$ sudo vi /etc/ntp.conf
server 127.127.1.0  # Local NTP Server
restrict 70.50.183.0 mask 255.255.255.0 nomodify notrap

# ntp restart
$ sudo systemctl restart ntp.service

# timedatectl 데몬의 시간 동기화 중지
$ timedatectl set-ntp no

# $ timedatectl
$ timedatectl status
                      Local time: 금 2020-10-16 12:41:45 KST
                  Universal time: 금 2020-10-16 03:41:45 UTC
                        RTC time: 금 2020-10-16 03:41:45
                       Time zone: Asia/Seoul (KST, +0900)
       System clock synchronized: yes
systemd-timesyncd.service active: no
                 RTC in local TZ: no


How to set NTP Client Server

Details

$ sudo vi /etc/ntp.conf
server 192.168.137.2 # NTP 서버 주소

$ sudo systemctl restart ntp.service

# timedatectl 데몬의 시간 동기화 중지
$ timedatectl set-ntp no

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*node1           LOCAL(0)         6 u  313 1024  377    0.308   -0.008   0.026


/etc/nsswitch.conf


Windows 10, host file

C:\Windows\System32\drivers\etc\hosts

Details

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1 rolroralra.com
127.0.0.1 cockpit.rolroralra.com
127.0.0.1 blog.rolroralra.com
127.0.0.1 transmission.rolroralra.com
127.0.0.1 plex.rolroralra.com
127.0.0.1 jenkins.rolroralra.com
127.0.0.1 gitlab.rolroralra.com
127.0.0.1 registry.rolroralra.com


Letsencrypt (certbot)

https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-dns-validation-with-acme-dns-certbot-on-ubuntu-18-04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment