레이블이 리눅스인 게시물을 표시합니다. 모든 게시물 표시
레이블이 리눅스인 게시물을 표시합니다. 모든 게시물 표시

linux - If server has multiple interface that specify default gateway device. (Red Hat Enterprise Linux 5, 6)

레드햇 리눅스 에서 서버 이더넷 포트에 다수의 게이트웨이가 있어 route시 default gateway가 재대로 잡히지 않는 현상이 있습니다.

위와 같은 현상이 있다면 아래와 같이 설정 할 수 있습니다.

- Resolution


 # vi /etc/sysconfig/network

위 명령어를 실행 한 뒤 아래 내용을 추가해줍니다.

 GATEWAYDEV=ethX

ethX = 디폴트 게이트웨이로 설정할 이더넷 포트

linux - Dell서버 Ethernet device name em -> eth 변경

dell서버에서 centos나 redhat linux설치 시 ethernet 디바이스 이름이 아래와 같이 em으로 등록 되어 있는것을 볼 수 있습니다.

$ ifconfig

em1      Link encap:Ethernet  HWaddr 20:47:47:8B:72:2C  
            UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
            RX packets:13287407 errors:0 dropped:0 overruns:0 frame:0
            TX packets:3518085 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:3979015280 (3.7 GiB)  TX bytes:1456833747 (1.3 GiB)
            Interrupt:41



$ cd /etc/sysconfig/network-scripts

위 경로로 이동해 보시면 디바이스 name이 em으로 되어있는 것을 보실 수 있습니다.

ifcfg-em1
ifcfg-em2
...


먼저 디바이스 name을 바꾸기 위해 패키지를 하나 삭제해야합니다.

rpm 명령어를 통해 패키지를 검색합니다.

$ rpm -qa | grep biosdevname
biosdevname-0.4.1-3.el6.x86_64

검색된 패키지를 rpm 명령어를 통해 삭제해 줍니다.

$ rpm -e biosdevname-0.4.1-3.el6.x86_64

위 명령어를 통해 패키지를 삭제 한 뒤 아래 파일을 수정해줍니다.

$ vi /etc/udev/rules.d/70-persistent-net.rules

위 파일이 존재하지 않는다면 추가 해 줘야 하는데, 첨부파일을 다운받아 수정하셔도 됩니다.

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="*", NAME="em1"

위 내용을 아래와 같이 수정합니다.

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

** xx:xx:xx:xx:xx:xx부분엔 포트의 mac-address를 넣어 주시면 됩니다. (ifcfg-emX 파일 참고)

em1 포트는 eth0 포트와 같습니다.

수정 하신 뒤 아래 폴더로 이동합니다.

$ cd /etc/sysconfig/network-scripts

그리고 ifcfg-em(숫자) 를 ifcfg-eth(숫자-1)로 수정 해 줍니다.
ex) ifcfg-em1 -> ifcfg-eth0

그리고 파일 내부를 수정해줍니다.
DEVICE=em1 -> DEVICE=eth0

$ init 6를 통해 시스템을 리부팅 시켜줍니다.


linux - ntpd client 간단 설정 및 트러블 슈팅

1. ntpd 설치

#yum -y install ntp
위 명령어를 통해 ntp를 설치해 줍니다.

2. ntpd clinet 서버 주소 입력

#vi /etc/ntp.conf
위 파일을 실행 시킨 후 아래의 빨간색 부분에

server (ntp server hostname) 을 입력해 줍니다.
(아래의 ntp.postech.ac.kr은 포항공대의 ntp서버입니다.)


     20 # Use public servers from the pool.ntp.org project.
     21 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
     22 server ntp.postech.ac.kr
     23 #server 0.rhel.pool.ntp.org
     24 #server 1.rhel.pool.ntp.org
     25 #server 2.rhel.pool.ntp.org
     26
     27 #broadcast 192.168.1.255 autokey        # broadcast server
     28 #broadcastclient                        # broadcast client
     29 #broadcast 224.0.1.1 autokey            # multicast server
     30 #multicastclient 224.0.1.1              # multicast client
     31 #manycastserver 239.255.254.254         # manycast server
     32 #manycastclient 239.255.254.254 autokey # manycast client

3. ntpd를 재시작 해줍니다.

#service ntpd restart

4. ntpd 상태 확인

#ntpq -pn을 통해 아래와같이 ntp의 상태를 확인 할 수 있습니다.
poll이 갱신 타임으로 ntp.conf에서 설정 가능 합니다.
     remote           refid          st t when  poll  reach  delay    offset   jitter
==========================================================
*141.223.182.106    .GPS.         1 u   58    64    377   8.643  -63.180  92.177





5. ntp 서버 통신 오류

#ntpd -pn

 remote        refid           st t when poll reach   delay   offset  jitter
=====================================================
 1.1.1.1         .INIT.          16 u    -   64    0    0.000    0.000   0.000

 no server suitable for synchronization found

위와 같이 통신이 안될 때 확실히 통신이 안되는지 아래 명령어를 통해 확인합니다.

#ntpd -d 1.1.1.1
아래와 같이

transmit(1.1.1.1)
transmit(1.1.1.1)
transmit(1.1.1.1)
transmit(1.1.1.1)
transmit(1.1.1.1)

전송만 하고 리시브 받지 못하면 ntp서버가 열려있지 않은 겁니다.

transmit(141.223.182.106)
receive(141.223.182.106)
transmit(141.223.182.106)
receive(141.223.182.106)
transmit(141.223.182.106)
receive(141.223.182.106)
transmit(141.223.182.106)
receive(141.223.182.106)
transmit(141.223.182.106)
server 141.223.182.106, port 123

정상적인 서버는 위와같이 receive 받습니다.

6. ntp time 강제로 맞추기

 ㄱ. ntpd 실행 상태에서 시간 맞추기
 
  # ntpdate -u 141.223.182.106
  13 Oct 14:59:06 ntpdate[51466]: adjust time server 141.223.182.106 offset 0.005536 sec

 위 명령어 -u는 ntpd 소켓인 123번 소켓이 아닌 다른 소켓을 사용하여 ntp서버 time을 받아옵니다.

 ㄴ. ntpd 서버 종료 후 시간 맞추기

  #service ntpd stop
  #ntpdate -b 141.223.182.106
  #service ntpd start

  위와 같은 방법을 사용하면 ntp서버를 멈춘 뒤 123번 포트를 이용해 date를 받아옵니다.

DHCP ServerSetting

Objectives
-ubuntuRed-Hat계열 Linux에서의 DHCP Server Setting
 
InstallSetting 전 확인 사항
1. Linux계열 확인
2. Root계정 권한 획득
 
 Install

























<Ubuntu>
# apt-get install isc-dhcp-server

<Red-Hat/CentOS>
# Yum install dhcp


위와 같은 방법으로 dhcp패키지를 설치 해 줍니다.

Configure

# vi /etc/dhcp/dhcp.conf
위 커맨드를 실행 한 뒤 dhcp serverconfigure해줍니다.





16/17line에서 domain-name을 설정 해 줄 수 있습니다.


























52 ~ 60line을 통해 dhcp serverconfigure합니다.
1.     53 – 사용하고 있는 ipsubnet정보를 입력 해 줍니다.
2.     54 – dhcp client가 받게 될 ip의 범위를 입력 해 줍니다.
3.     55,56 – 위에서 바꾼 domain name을 입력 해 줍니다.
4.     57 – gateway ip를 입력 해 줍니다.
5.     58 – broadcast-address ip를 입력 해 줍니다.
6.     59,60 – lease timeip의 대여 시간 이며 *lease timelinuxtime-zone의 영향을 받지 않습니다.


Service start
<Ubuntu>
# /etc/init.d/isc-dhcp-server start
* Stopping ISC DHCP server dhcpd    [ OK ]
* Starting ISC DHCP server dhcpd    [ OK ]

# unset UPSTART_SESSION
# service isc-dhcp-server restart
Isc-dhcp-server stop/waiting
Isc-dhcp-server start/running, process 8570

<Red-Hat/CentOS>
# service dhcpd restart
Isc-dhcp-server stop/waiting
Isc-dhcp-server start/running, process 8570



Maintenance

# cat /var/lib/dhcp/dhcp.leases

위 커맨드를 통해 clientserver에서 ip를 받아간 정보를 확인 할 수 있습니다.

























# tail f /var/lib/dhcp/dhcp.seases

위 커맨드를 통해 실시간으로 clinetip를 받아가는 정보를 확인 할 수 있습니다.





















<Ubuntu>
# vi /var/log/syslog

<Red-Hat/CentOS>
# vi /var/log/message


위 커맨드를 통해 시스템 로그에서 dhcp 서버가 client에게 ip를 할당하는 모습이나 error등을 체크 할 수 있습니다.

linux #3 basic commands #2 (리눅스 - 기본 명령어 #2)

8) head, tail(기본 10줄)

- 텍스트 파일의 앞 10줄, 뒤 10줄 기본 출력하는 명령입니다.
- 형식

#head -line text
#tail -line text

#tail -f log_file (-f: file open, 실시간으로 추가되는 내용을 확인 할 수 있습니다.)

9) more

- 장문의 텍스트 출력 시 사용합니다. 페이지 단위로 끊어 사용자에게 보여주고
 내부 명령을 이용하여 페이지 진행이 가능합니다.

#more text
-----------------------------------------------------
Enter    : 한줄씩 이동
space    : 한페이지씩 이동
b        : 1페이지 뒤로
q        : 끝내기
/keyword : 검색
n        : 키워드 검색 후 연속 검색 지원

10) less

- more에 head나 tail을 섞은 모습입니다. (라인 번호를 적고 시작 가능)
- vi 편집기로 자동변환합니다.
- 잘 쓰이진 않습니다.

#less +10 a.txt

10) file

- 파일의 속성 정보를 세부적으로 출력하는 명령입니다.
- 형식

#file /bin/ls
#file /etc/init.d/*

* = 메타캐릭터

11) 사용자 계정 추가 명령

1> useradd
                                                   
#useradd [-d /user_home -m -s /bin/tcsh -u 1000 -g 1000 -G 10000] user
        -d  = 디렉토리
        -m = mkdir
        -s  = 쉘
        -u  = user
        -g  = maingroup
        -G = secondary group                                
     

#passwd user (관리자만)

*shell - 명령줄

2> usermod  : /etc/passwd 사용자의 정보를 변경할 때 사용합니다.(useradd와 동일 옵션)
               (login name)          (directory)           (move)
#usermod -l new_account -d /new_account -m user
       
        usermod에서 -m은 mkdir이 아니라 move로 기존의 계정 디렉토리를 mv해줍니다.

3> userdel

#userdel account
#userdel -r account


*패스워드 관리

#passwd [-options] [user_name]
#passwd -l user_name (-l passwd locking)
#passwd -u user_name (-u unlocking password)

        *패스워드 변경 주기 관리

#chage [-option] user_name
#chage -m day user_name (-m min day setting)
#chage -M day user_name (-M Max day setting)
----> /etc/login.defs (여기서 설정해도 됩니다.)

12) 사용자 그룹 관리

1> groupadd : 사용자가 소속될 신규 그룹 생성합니다.

#groupadd -g GID new_group

2> groupmod : 존재하는 그룹의 이름 등의 정보 변경합니다.

#groupmod -n new_group group

3> groupdel : 그룹 삭제 시 사용합니다.

#groupdel group

*/etc/group

linux #2 basic commands #1 (리눅스 - 기본 명령어 #1)

1.시스템 레벨(Run level)

- 시스템 운영을 위해 시스템의 부팅 단계를 레벨로 표시합니다.
- 구분

0: poweroff
1: Single user mode
2: Multi user mode(CLI) commend line interface, 공유금지
3: Multi user mode(CLI) 공유가능
4: x
5: Xwindow multi user mode
6: Reboot


#init 0
#who -r  상태정보확인

2. man (On-line manual)

- 시스템에서 제공되는 명령, 파일 등에 관한 메뉴얼 정보를 보여줍니다.

# man [options] [sections] argument

*section
1 일반 명령
2 System Call
3 Library ~.so
4 특수 파일
5 구성정보 파일
6 게임 메뉴얼
7 환경 설정(환경변수) path
8 관리 명령
9 커널 관련

# man section_no argument

# man signal   == 2번 System Call에 대한 정보를 보여줍니다.
# man 7 signal == 7번 환경변수에 대한 정보를 보여줍니다.

# man passwd   == 1번 일반명령어 passwd에 대한 정보를 보여줍니다.
# man 5 passwd == 5번 특수파일 passwd에 대한 정보를 보여줍니다.

*최소 설치 시 또는 메뉴얼을 제공하지 않는 명령, 파일인경우 출력 없습니다.


3. 기본명령

1) ls(list)

- 작업 디렉터리, 대상 디렉터리 내의 파일 정보를 출력합니다.
- 명령 형식

#ls [-options] [file|dir]
#ls -l : -l long 파일이 가진 속성 정보 출력합니다. 
#ls -a : -a all 대상 디렉터리 내 숨김 속성을 갖는 파일도 출력합니다.
#ls -F : -F file type 파일의 타입 정보 4가지를 같이 출력합니다.
name/ - directory
name* - execute file
name@ - Symbolic Link
name  - file
#ls -i : -i index node 파일이 위치하고 있는 inode 정보를 포함하여 출력합니다.
#ls -lu: -u user(Access) time 파일에 접근한 시간 정보를 표시합니다.
#ls -lc: -c change time 파일의 속성 정보에 변경이 발생된 시간 정보를 표시합니다.
#ls -n : -n ID number 사용자의 ID를 표시 합니다.(ls -l에선 아이디와 그룹이 영어로 표시)

2) cd (change directory)

- 명령 형식

#cd directory

#cd       : home디렉토리로 이동합니다.
#cd ..    : 상위 디렉토리 이동합니다.
#cd -     : 이전 작업 디렉토리로 이동합니다.
#cd ~     : home디렉토리로 이동합니다.

pwd(print working drectory): 현재디렉토리

3) touch

- 파일이 없을 경우 0kb파일 생성합니다. (체크포인트 파일 일부 백업할 때 씀)
- 존재하는 파일 및 디렉토리에 적용 시간 정보 변경합니다.
- log파일을 만들 때에도 사용합니다.
- 명령 형식

#touch [-options] file/dir

#touch newfile (0kb 파일 생성)
#touch exist_file (시간 정보 변경)
#touch -t [년도]월일시분.초 file    (원하는 시간으로 변경)

4) mkdir

- 명령 형식

#mkdir [-option] new_dir
#mkdir dir1 dir2 
#mkdir dir3/dir4 - 오류
#mkdir -p dir3/dir4 - 됨 : -p path 생성도리 디렉터리의 중간 경로가 없을 때 같이 생성합니다.

5) rm

- 파일 대상 명령으로 디렉토리는 삭제 불가능합니다.
- 명령 형식

#rm [-options] file|dir

#rm file1 file2
#rm -r dir3     (-r recursive : 디렉토리 내 파일에 rm 적용 후 최종 디렉토리까지 삭제)
#rm -i file3    (-i interactive : 지우기 전 사용자에게 질의) 
           --> 해당 기능의 강제적 사용을 위한 alias 설정을 해둡니다.

*alias 기능 (alias 별명='명령 -옵션')
*alias 별명 - 현재 설정 사항 확인 가능
*unalias 별명 - 해제

6) mv (move)

- 파일을 이동할 때 사용되는 명령입니다.
- 파일의 이름을 변경할 때 사용합니다.
- 명령 형식

#mv file|dir dir            (이동)
#mv file|dir new_name (이름변경)
#mv -i file dir              (이동 할 디렉토리 내 같은 이름이 존재 할 경우에만 사용자에게 질의)

7) cat

- 짧은 텍스트 파일을 볼 때 사용합니다.(view 명령)
- 명령 형식

#cat [-option] text

#cat -n text  (-n : line Number 출력 텍스트에 라인번호 삽입)
#nl text (text 출력 시 라인번호를 포함하여 출력합니다.) (cat -n text와 동일)