brunch

매거진 TIP

You can make anything
by writing

C.S.Lewis

by sokoban Dec 17. 2018

네트워크 자산 정보의 수집

네트워크를 통한 자산 현황 수집 자동화

  소규모 혹은 대규모 네트워크상의 서버들을 운영하다 보면 자산 정보를 어떻게 구축하고 관리하는지가 가장 중요한 이슈일 것이다. 자산이 제대로 식별되지 않는다면 서비스에 문제가 발생했을때 또는 보안적 문제가 발생했을때에 어떻게 어디를 보아야 할지 전혀 알수 없을수도 있다. 특히 자산이 몇백대 수준을 넘어가기 시작하고 한두명이서 이를 관리하다 보면 역시 한계에 부딫힐수 밖엔 없을 것이다.

  서버는 MRTG를 통해서 당연히 적은수의 서버라도 관리를 하고 있을것이나 네트워크 장비들은 어떠한가 ? 네트워크 토폴로지를 명확하게 구분하고 어떤 포트가 사용중인지를 정확하게 파악하고 있어야지만 네트워크의 관리가 될수 있을 것이다.


  이를 자동화 해주기 위해 다양한 정보를 이용하여 자산을 자동으로 식별하고 정리해주는 툴을 소개하고자 한다. 


1. NetDisco


  Netdisco는 SNMP를 이용하여 정보를 폴링하여 자산 정보를 구축해 주는 툴이다. 

  서버에 대한 정보뿐 아니라 네트워크 장비에 대해서 세세한 그림을 그려주는것이 장점으로 현재 어떤 포트에 연결이 되어 있는장비에 대한 정보를 자세히 보여 준다...


Docker 이미지를 통한 설치

Netdisco의 설치는 docker의 compose를 이용하여 간단하게 설치하여 구성해 볼수도 있다. docker 설치는 아래 링크에 적혀 있는 메뉴얼대로 따라가면 된다. 혹시 docker와 compose가 설치되지 않았다면 배포본에 따라서 설치가 가능하니 별도로 검색을 통해서 설치 하기 바란다.

https://hub.docker.com/r/netdisco/netdisco


docker 설치 명령어


sudo groupadd netdisco -g 901 

sudo useradd -u 901 -p x -g netdisco netdisco 

mkdir -p netdisco/{logs,config,nd-site-local} 

sudo chown -R netdisco:netdisco netdisco 


curl -Ls -o docker-compose.yml https://tinyurl.com/nd2-dockercompose   

docker-compose up


실제 환경에서 사용하기를 원하시는 분들은 아래의 링크를 통해서 설치를 해서 사용하시기 바란다.

https://metacpan.org/pod/App::Netdisco


설치가 완료 되고 나면 http://localhost:5000 으로 접속하면 아래와 같은 화면을 볼수 있고 별도의 설정 없이도 SNMP Public으로 설정된 노드가 있을경우에는 Discover에 IP를 넣고 간단하게 해당 장비에 대한 정보를 폴링 할수 있다.

Netdisco의 최초 접속 화면



장비의 상세 설명 화면



스위치 장비의 포트 사용 현황 조회


연결된 장비들의 대역폭과 구성도


장비의 구성 목록


  간단하게 살펴 보았지만 응용할 경우 다양한 정보의 수집이 가능하고 간단(?)하게 구성이 가능한 장점이 있다. 한번은 실제 사용환경에서 사용중인 네트워크 장비의 여유포트 정보나 전체 트래픽 정보를 수집하여 관리하기 위해서 구성해 보고는 싶은 마음이 들게 하는 툴이다. 다만 전체 자산에 대해서 구축 되지 않는다면 힘든 부분이 있을것이고 SNMP를 꼭 써야하는 부분은 아무래도 걸리는 부분이긴 하다. 하지만 스위치가 1,000대 이상 있는 환경에 여유 포트가 어디인지도 모르고 수동으로 일일이 관리한다면 한번 써보기를 권하고 싶고 나역시도 기회가 된다면 제대로 설치해서 사용해 보고 싶다.


  혹시라도 구성을 해보고 싶은 분들은 Public 이 아닌 Private으로 SNMP를 설정해서 해보시길 바란다. 그리고 공인망에서는 Private도 신중히 고민해 보고 사용하기 바란다. 


  추가적으로 자세한 설정은 아래의 링크에서 찾아볼수 있으므로 이를 활용하여 셋팅하면 된다.

https://github.com/netdisco/netdisco/wiki/Configuration




참고 사이트


http://netdisco.org/


https://github.com/netdisco/netdisco


https://store.docker.com/r/netdisco/netdisco





Docker 실행 로깅

 Docker를 기본적으로 실행하게 되었을때 나타나는 로그 화면이다. 모든 솔루션이 다 그렇듯 로그상에서 다양한 정보가 노출되므로 이를 한번 읽어 보는것도 구조를 파악하는데 도움이 된다.


Creating sokoban_netdisco-postgresql_1_69cc969b7aa0 ... done

Creating sokoban_netdisco-web_1_781134b1dfd5        ... done

Creating sokoban_netdisco-backend_1_9d1cb310bc6f    ... done

Attaching to sokoban_netdisco-postgresql_1_f38f5382e1e9, sokoban_netdisco-backend_1_5eb62388469d, sokoban_netdisco-web_1_17e1975c08d4

netdisco-postgresql_1_f38f5382e1e9 | The files belonging to this database system will be owned by user "postgres".

netdisco-postgresql_1_f38f5382e1e9 | This user must also own the server process.

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-backend_1_5eb62388469d | Attempting to create directory /home/netdisco/perl5

netdisco-postgresql_1_f38f5382e1e9 | The database cluster will be initialized with locale "en_US.utf8".

netdisco-postgresql_1_f38f5382e1e9 | The default database encoding has accordingly been set to "UTF8".

netdisco-postgresql_1_f38f5382e1e9 | The default text search configuration will be set to "english".

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | Data page checksums are disabled.

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | fixing permissions on existing directory /var/lib/postgresql/data ... ok

netdisco-postgresql_1_f38f5382e1e9 | creating subdirectories ... ok

netdisco-postgresql_1_f38f5382e1e9 | selecting default max_connections ... 100

netdisco-postgresql_1_f38f5382e1e9 | selecting default shared_buffers ... 128MB

netdisco-postgresql_1_f38f5382e1e9 | selecting dynamic shared memory implementation ... posix

netdisco-postgresql_1_f38f5382e1e9 | creating configuration files ... ok

netdisco-web_1_17e1975c08d4 | Attempting to create directory /home/netdisco/perl5

netdisco-backend_1_5eb62388469d | config watcher: watching /home/netdisco/environments for updates.

netdisco-web_1_17e1975c08d4 | config watcher: watching /home/netdisco/environments for updates.

netdisco-postgresql_1_f38f5382e1e9 | running bootstrap script ... ok

netdisco-postgresql_1_f38f5382e1e9 | performing post-bootstrap initialization ... sh: locale: not found

netdisco-postgresql_1_f38f5382e1e9 | No usable system locales were found.

netdisco-postgresql_1_f38f5382e1e9 | Use the option "--debug" to see details.

netdisco-postgresql_1_f38f5382e1e9 | ok

netdisco-postgresql_1_f38f5382e1e9 | syncing data to disk ... ok

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | WARNING: enabling "trust" authentication for local connections

netdisco-postgresql_1_f38f5382e1e9 | You can change this by editing pg_hba.conf or using the option -A, or

netdisco-postgresql_1_f38f5382e1e9 | --auth-local and --auth-host, the next time you run initdb.

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | Success. You can now start the database server using:

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 |     pg_ctl -D /var/lib/postgresql/data -l logfile start

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | waiting for server to start....LOG:  could not bind IPv6 socket: Address not available

netdisco-postgresql_1_f38f5382e1e9 | HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system was shut down at 2018-12-11 15:44:30 UTC

netdisco-postgresql_1_f38f5382e1e9 | LOG:  MultiXact member wraparound protections are now enabled

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system is ready to accept connections

netdisco-postgresql_1_f38f5382e1e9 | LOG:  autovacuum launcher started

netdisco-postgresql_1_f38f5382e1e9 |  done

netdisco-postgresql_1_f38f5382e1e9 | server started

netdisco-postgresql_1_f38f5382e1e9 | ALTER ROLE

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/netdisco-initdb.sh

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: configuring Netdisco user and db

netdisco-postgresql_1_f38f5382e1e9 | CREATE ROLE

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: restarting pg privately to container

netdisco-postgresql_1_f38f5382e1e9 | waiting for server to shut down...LOG:  received fast shutdown request

netdisco-postgresql_1_f38f5382e1e9 | .LOG:  aborting any active transactions

netdisco-postgresql_1_f38f5382e1e9 | LOG:  autovacuum launcher shutting down

netdisco-postgresql_1_f38f5382e1e9 | LOG:  shutting down

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system is shut down

netdisco-postgresql_1_f38f5382e1e9 |  done

netdisco-postgresql_1_f38f5382e1e9 | server stopped

netdisco-postgresql_1_f38f5382e1e9 | waiting for server to start....LOG:  could not bind IPv6 socket: Address not available

netdisco-postgresql_1_f38f5382e1e9 | HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system was shut down at 2018-12-11 15:44:32 UTC

netdisco-postgresql_1_f38f5382e1e9 | LOG:  MultiXact member wraparound protections are now enabled

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system is ready to accept connections

netdisco-postgresql_1_f38f5382e1e9 | LOG:  autovacuum launcher started

netdisco-postgresql_1_f38f5382e1e9 |  done

netdisco-postgresql_1_f38f5382e1e9 | server started

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: bringing schema up-to-date

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: importing OUI

netdisco-postgresql_1_f38f5382e1e9 | COPY 23285

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: marking schema as up-to-date

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: adding admin user if none exists

netdisco-postgresql_1_f38f5382e1e9 | INSERT 0 1

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: adding session key if none exists

netdisco-postgresql_1_f38f5382e1e9 | INSERT 0 1

netdisco-postgresql_1_f38f5382e1e9 | netdisco-db-entrypoint: queueing stats job

netdisco-postgresql_1_f38f5382e1e9 | INSERT 0 1

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | waiting for server to shut down...LOG:  received fast shutdown request

netdisco-postgresql_1_f38f5382e1e9 | .LOG:  aborting any active transactions

netdisco-postgresql_1_f38f5382e1e9 | LOG:  autovacuum launcher shutting down

netdisco-postgresql_1_f38f5382e1e9 | LOG:  shutting down

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system is shut down

netdisco-postgresql_1_f38f5382e1e9 |  done

netdisco-postgresql_1_f38f5382e1e9 | server stopped

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | PostgreSQL init process complete; ready for start up.

netdisco-postgresql_1_f38f5382e1e9 |

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system was shut down at 2018-12-11 15:44:40 UTC

netdisco-postgresql_1_f38f5382e1e9 | LOG:  MultiXact member wraparound protections are now enabled

netdisco-postgresql_1_f38f5382e1e9 | LOG:  database system is ready to accept connections

netdisco-postgresql_1_f38f5382e1e9 | LOG:  autovacuum launcher started

매거진의 이전글 Free Threat Intelligence #3

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari