20160429 리눅스 네트워크
=========================================메모=========================================
C언어, 어셈블리어, 파이썬
=========================================복습=========================================
=========================================강의=========================================
=========================================실습=========================================
서비스 방법의 종류
서버에서 서비스 하는 방법의 종류
■ standalone 방식 데몬이 떠 있으면서 서비스하는 방식
■ xinetd 방식 데몬이 떠 있지 않으면서, xinetd 데몬이 서비스 요청이 있으면 띄워주는 방식
------------------------------------------------------
[EX] # chkconfig named on
# service named start
[EX] # cd /etc/xinetd.d
# vi krb5-telnet (# chkconfig krb5-telnet on)
/yes
yes -> no
# service xinetd restart
------------------------------------------------------
(standalone 방식) 서비스 요청이 많을때 좋다.(EX: WEB, MAIL)
----- Client ----- ----- Server -----
http://DAUM ---------------> httpd(80)
(현재) # service named restart (# /etc/init.d/named restart)
(부팅) # chkconfig named on (# ntsysv, /etc/rc#.d/S##named)
(xinetd 방식) 서비스 요청이 적을때 좋다.(EX: telnet, ftp)
# telnet Server ---------------> xinetd -------> telnetd(23)
/etc/xinetd.conf
/etc/xinetd.d/*
(현재) #
(부팅) # cd /etc/xinetd.d (# chkconfig krb5-telnet on)
# vi krb5-telnet
# service xinetd restart
xinetd 방식 서비스 실습
(전제조건) telnet 서비스 open 방법
■ telnet 서비스 open
# chkconfig krb5-telnet on (# vi /etc/xinetd.d/krb5-telnet)
# service xinetd restart
■ root 사용자로 접속 허용
# vi /etc/securetty
....
pts/1
pts/2
....
pts/11
# telnet localhost
root 사용자로 로그인
# exit
[EX1] xinetd 방식의 실습
# telnet Server ---------------> xinetd -------> telnetd(23)
/etc/xinetd.conf
/etc/xinetd.d/*
/etc/services
[TERM1] 첫번째 터미널
# pgrep -lf telnet (# ps -ef | grep telnet, # ps aux | grep telnet)
#
# telnet localhost
root 사용자로 로그인
[TERM2] 두번째 터미널
# pgrep –lf telnet
8421 telnet localhost
8422 telnetd
[TERM3] 세번째 터미널
# telnet localhost
root 사용자로 로그인
[TERM2] 두번째 터미널
# pgrep -lf telnet
8421 telnet localhost
8422 telnetd
8467 telnet localhost
8468 telnetd
[EX2] xinetd 데몬에 대해서
■ xinetd = inetd + Access Control(tcp_wrapper)
# telnet Server --------> xinetd --------> telnetd(23)
/etc/xinetd.conf
/etc/xinetd.d/*
[root@linux220 ~]# pgrep -lf xinetd
6134 xinetd -stayalive -pidfile /var/run/xinetd.pid
[root@linux220 ~]# cat /etc/xinetd.conf
#
# This is the master xinetd configuration file. Settings in the
# default section will be inherited by all service configurations
# unless explicitly overridden in the service configuration. See
# xinetd.conf in the man pages for a more detailed explanation of
# these attributes.
defaults
{
# The next two items are intended to be a quick access place to
# temporarily enable or disable services.
#
# enabled =
# disabled =
# Define general logging characteristics.
log_type = SYSLOG daemon info
log_on_failure = HOST
log_on_success = PID HOST DURATION EXIT
# Define access restriction defaults
#
# no_access =
# only_from =
# max_load = 0
cps = 50 10
instances = 50
per_source = 10
# Address and networking defaults
#
# bind =
# mdns = yes
v6only = no
# setup environmental attributes
#
# passenv =
groups = yes
umask = 002
# Generally, banners are not used. This sets up their global defaults
#
# banner =
# banner_fail =
# banner_success =
}
includedir /etc/xinetd.d
[root@linux220 ~]# cd /etc/xinetd.d
[root@linux220 /etc/xinetd.d]# ls
chargen-dgram discard-dgram eklogin krb5-telnet telnet
chargen-stream discard-stream ekrb5-telnet kshell telnet~
daytime-dgram echo-dgram gssftp rsync time-dgram
daytime-stream echo-stream klogin tcpmux-server time-stream
[root@linux220 /etc/xinetd.d]# cat krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
}
[root@linux220 /etc/xinetd.d]# vi krb5-telnet
[root@linux220 /etc/xinetd.d]# cat krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
}
[root@linux220 /etc/xinetd.d]# service xinetd restart
xinetd 를 정지 중: [ OK ]
xinetd (을)를 시작 중: [ OK ]
[root@linux220 /etc/xinetd.d]# telnet localhost
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection refused
[root@linux220 /etc/xinetd.d]# vi krb5-telnet
[root@linux220 /etc/xinetd.d]# cat krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
}
[root@linux220 /etc/xinetd.d]# telnet localhost
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection refused
[root@linux220 /etc/xinetd.d]# service xinetd restart
xinetd 를 정지 중: [ OK ]
xinetd (을)를 시작 중: [ OK ]
[root@linux220 /etc/xinetd.d]# telnet localhost
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
linux220.example.com (Linux release 2.6.18-409.el5 #1 SMP Tue Mar 15 18:22:22 EDT 2016) (2)
login: root
Password:
Login incorrect
login: root
Password:
Last login: Fri Apr 29 18:22:00 from localhost.localdomain
You have new mail.
[root@linux220 ~]# exit
logout
|---> ~/.bash_logout read
Connection closed by foreign host.
[EX3] xinetd/standalone 서비스 방식의 목록 확인
(부팅시에 서비스 ON/OFF 시키는 툴들)
(TUI) # ntsysv (# setup)
(GUI) # system-config-services (# serviceconf)
(TUI) # chkconfig --list (# chkconfig krb5-telnet on)
■ xinetd 방식 서비스
# chkconfig —list
[root@linux220 /etc/xinetd.d]# chkconfig --list
NetworkManager 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
acpid 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
anacron 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
apmd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
atd 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
auditd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
autofs 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
avahi-daemon 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
avahi-dnsconfd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
bluetooth 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
capi 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
conman 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
cpuspeed 0:해제 1:활성 2:활성 3:활성 4:활성 5:활성 6:해제
crond 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
cups 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
dc_client 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
dc_server 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
dnsmasq 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
dovecot 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
dund 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
firstboot 0:해제 1:해제 2:해제 3:활성 4:해제 5:활성 6:해제
gpm 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
haldaemon 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
hidd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
hplip 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
httpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
ibmasm 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
innd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
ip6tables 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
iptables 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
irda 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
irqbalance 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
iscsi 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
iscsid 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
isdn 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
kdump 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
kudzu 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
lvm2-monitor 0:해제 1:활성 2:활성 3:활성 4:활성 5:활성 6:해제
mcstrans 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
mdmonitor 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
mdmpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
messagebus 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
multipathd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
named 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
netconsole 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
netfs 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
netplugd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
network 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
new 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
nfs 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
nfslock 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
nscd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
ntpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
oddjobd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
pand 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
pcscd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
portmap 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
psacct 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
rawdevices 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
rdisc 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
readahead_early 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
readahead_later 0:해제 1:해제 2:해제 3:해제 4:해제 5:활성 6:해제
restorecond 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
rpcgssd 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
rpcidmapd 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
rpcsvcgssd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
rwhod 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
saslauthd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
sendmail 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
setroubleshoot 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
smartd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
smb 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
spamassassin 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
squid 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
sshd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
syslog 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
tcsd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
tomcat5 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
tux 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
vmware-tools 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
vmware-tools-thinprint 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
vncserver 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
vsftpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
wdaemon 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
winbind 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
wpa_supplicant 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
xfs 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
xinetd 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
ypbind 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
yum-updatesd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
xinetd 기반의 서비스:
chargen-dgram: 해제
chargen-stream: 해제
daytime-dgram: 해제
daytime-stream: 해제
discard-dgram: 해제
discard-stream: 해제
echo-dgram: 해제
echo-stream: 해제
eklogin: 해제
ekrb5-telnet: 해제
gssftp: 해제
klogin: 해제
krb5-telnet: 활성
kshell: 해제
rsync: 활성
tcpmux-server: 해제
telnet: 해제
time-dgram: 해제
time-stream: 해제
[root@linux220 /etc/xinetd.d]# chkconfig krb5-telnet off
[root@linux220 /etc/xinetd.d]# chkconfig --list krb5-telnet
krb5-telnet 해제
[root@linux220 /etc/xinetd.d]# cat krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
}
[root@linux220 /etc/xinetd.d]# chkconfig krb5-telnet on
[root@linux220 /etc/xinetd.d]# chkconfig --list krb5-telnet
krb5-telnet 활성
[root@linux220 /etc/xinetd.d]# cat krb5-telnet
# default: off
# description: The kerberized telnet server accepts normal telnet sessions, \
# but can also use Kerberos 5 authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/telnetd
log_on_failure += USERID
}
[root@linux220 /etc/xinetd.d]# service xinetd restart
xinetd 를 정지 중: [ OK ]
xinetd (을)를 시작 중: [ OK ]
■ standalone 방식 서비스
[root@linux220 /etc/xinetd.d]# cd /etc/rc5.d
[root@linux220 /etc/rc5.d]# ls *sshd*
S55sshd
[root@linux220 /etc/rc5.d]# chkconfig sshd off
[root@linux220 /etc/rc5.d]# chkconfig --list sshd
sshd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
[root@linux220 /etc/rc5.d]# ls *sshd*
K25sshd
[root@linux220 /etc/rc5.d]# service sshd stop
sshd 를 정지 중: [ OK ]
[root@linux220 /etc/rc5.d]# chkconfig sshd on
[root@linux220 /etc/rc5.d]# chkconfig --list sshd
sshd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
[root@linux220 /etc/rc5.d]# ls *sshd*
S55sshd
[root@linux220 /etc/rc5.d]# service sshd start
sshd (을)를 시작 중: [ OK ]
[root@linux220 /etc/rc5.d]#
(정리) xinetd/standalone 서비스 제어
■ xinetd 서비스
# chkconfig krb5-telnet on ----> # vi /etc/xinetd.d/krb5-telnet(disable=no)
# service xinetd restart
■ standalone 서비스
# chkconfig sshd on ----> # mv /etc/rc5.d/K25sshd /etc/rc5.d/S55sshd
# service sshd restart
참조 http://blog.naver.com/gmasisy1/220644311274
참조 http://blog.naver.com/popqser2/220158960956
standalone 방식 서비스 실습
[EX1] WEB 서비스 실습
[root@linux220 /etc/rc5.d]# pgrep -lf httpd
[root@linux220 /etc/rc5.d]# service httpd restart
httpd 를 정지 중: [실패]
httpd (을)를 시작 중: [ OK ]
[root@linux220 /etc/rc5.d]# pgrep -lf httpd
6668 /usr/sbin/httpd
6670 /usr/sbin/httpd
6671 /usr/sbin/httpd
6672 /usr/sbin/httpd
6673 /usr/sbin/httpd
6674 /usr/sbin/httpd
6675 /usr/sbin/httpd
6676 /usr/sbin/httpd
6677 /usr/sbin/httpd
[root@linux220 /etc/rc5.d]# firefox &
[1] 6679
[root@linux220 /etc/rc5.d]#
(Gecko:6679): GLib-GObject-WARNING **: IA__g_object_notify: object class `MozContainer' has no property named `window'
(Gecko:6679): GLib-GObject-WARNING **: IA__g_object_notify: object class `MozContainer' has no property named `window'
console.error:
[CustomizableUI]
Custom widget with id loop-button does not return a valid node
console.error:
[CustomizableUI]
Custom widget with id loop-button does not return a valid node
(Gecko:6679): GLib-GObject-WARNING **: IA__g_object_notify: object class `MozContainer' has no property named `window'
(Gecko:6679): GLib-GObject-WARNING **: IA__g_object_notify: object class `MozContainer' has no property named `window'
(Gecko:6679): GLib-GObject-WARNING **: IA__g_object_notify: object class `MozContainer' has no property named `window'
[root@linux220 /etc/rc5.d]# service httpd stop
httpd 를 정지 중: [ OK ]
[root@linux220 /etc/rc5.d]# pgrep -lf httpd
[root@linux220 /etc/rc5.d]#
그림1
네트워크 설정 파일
■ 네트워크 설정 파일 종류
Ÿ /etc/hosts 파일
Ÿ /etc/host.conf 파일(/etc/nsswitch.conf)
Ÿ /etc/resolv.conf 파일
Ÿ /etc/sysconfig/network 파일
Ÿ /etc/sysconfig/network-scripts/ifcfg-eth0 파일
■ 네트워크 설정 확인 명령어
Ÿ ethtool 명령어
Ÿ ifconfig 명령어
Ÿ netstat -nr 명령어
Ÿ /etc/resolv.conf 파일
(1) /etc/hosts 파일
Ÿ /etc/hosts 파일은 아이피(IP)와 호스트 이름(hostname) 또는 도메인 이름(Domain Name)을 맵핑 (Mapping)하는 역할을 가진다. 작은 네트워크에서는 DNS을 대신하도록 설정할 수도 있다.
Ÿ 자세한 내용은 "# man hosts" 매뉴얼을 확인한다.
(2) /etc/host.conf 파일
Ÿ /etc/host.conf 파일은 이름 요청(도메인 요청, Naming Service Request)시 도메인/이름 검색 순 서를 나타낸다.
Ÿ 자세한 내용은 "# man host.conf" 매뉴얼을 확인한다.
# cat /etc/host.conf (# cat /etc/nsswitch.conf)
order hosts,bind
-> (ㄱ) hosts : /etc/hosts 파일을 검색
-> (ㄴ) bind : DNS 서버에서 검색
(예) http://www.daum.net -> (ㄱ) /etc/hosts -> (ㄴ) DNS(/etc/resolv.conf)
(3) /etc/resolv.conf 파일
Ÿ 이름 요청을 할 DNS 서버를 지정할 때 사용하는 파일이다.
-> 대표적인 ISP DNS 주소 확인
( 코넷 ) C:\> nslookup –q=NS kornet.net (IP: 211.216.50.150, 211.216.50.160)
(보라넷) C:\> nslookup –q=NS bora.net (IP: 164.124.101.31, 203.248.240.31)
(파워콤) C:\> nslookup –q=NS powercom.com (IP: 216.69.185.26, 208.109.255.26)
(하나로) C:\> nslookup -q=NS hanaro.net (IP: 210.180.98.85, 221.139.108.194)
[root@linux220 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
172.16.6.220 linux220.example.com linux220
[root@linux220 ~]# cat /etc/host.conf
[root@linux220 ~]# man host.conf
[root@linux220 ~]# cat /etc/resolv.conf
search example.com
nameserver 168.126.63.1
(4) /etc/sysconfig/network 파일
Ÿ 시스템의 호스트이름/기본라우터 정보를 지정할 때 사용하는 파일이다.
[root@linux220 ~]# cd /etc/sysconfig
[root@linux220 /etc/sysconfig]# ls
apm-scripts ip6tables pm-action
apmd ip6tables-config prelink
atd iptables raid-check
auditd iptables-config rawdevices
authconfig iptables-config.rpmnew readonly-root
autofs irda rhn
bluetooth irqbalance run-parts
cbq kdump samba
clock kernel saslauthd
conman keyboard selinux
console krb524 sendmail
cpuspeed kudzu smartmontools
crond mkinitrd spamassassin
desktop modules squid
dovecot named syslog
dund named.rpmnew system-config-securitylevel
firstboot netconsole system-config-users
grub network tomcat5
hidd network-scripts tux
hsqldb networking udev-stw
httpd nfs vncservers
hwconf nspluginwrapper wpa_supplicant
i18n ntpd xinetd
init pand
[root@linux220 /etc/sysconfig]# cat network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=linux220.example.com
GATEWAY=172.16.0.1
(5) /etc/sysconfig/network-scripts/ifcfg-eth0 파일
Ÿ NIC(EX: eth0)의 IP 설정을 할 때 사용하는 파일이다.
[root@linux220 /etc/sysconfig]# cd /etc/sysconfig/network-scripts/
[root@linux220 /etc/sysconfig/network-scripts]# ls
ifcfg-eth0 ifdown-isdn ifup-aliases ifup-plip ifup-wireless
ifcfg-lo ifdown-post ifup-bnep ifup-plusb init.ipv6-global
ifdown ifdown-ppp ifup-eth ifup-post net.hotplug
ifdown-bnep ifdown-routes ifup-ippp ifup-ppp network-functions
ifdown-eth ifdown-sit ifup-ipsec ifup-routes network-functions-ipv6
ifdown-ippp ifdown-sl ifup-ipv6 ifup-sit
ifdown-ipsec ifdown-tunnel ifup-ipx ifup-sl
ifdown-ipv6 ifup ifup-isdn ifup-tunnel
[root@linux220 /etc/sysconfig/network-scripts]# cat ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=172.16.255.255
HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.220
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
[root@linux220 /etc/sysconfig/network-scripts]# vi ifcfg-eth0
[root@linux220 /etc/sysconfig/network-scripts]# cat ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=172.16.255.255
#HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.220
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
[참고] /etc/sysconfig/networking 디렉토리
[root@linux220 /etc/sysconfig/network-scripts]# cd /etc/sysconfig/networking
[root@linux220 /etc/sysconfig/networking]# ls
devices profiles
[root@linux220 /etc/sysconfig/networking]# cd devices/
[root@linux220 /etc/sysconfig/networking/devices]# ls
[root@linux220 /etc/sysconfig/networking/devices]# cd ../profiles/
[root@linux220 /etc/sysconfig/networking/profiles]# ls
default
[root@linux220 /etc/sysconfig/networking/profiles]# cd default/
[root@linux220 /etc/sysconfig/networking/profiles/default]# ls
[root@linux220 /etc/sysconfig/networking/profiles/default]#
[참고] /etc/sysconfig/network-scripts/ifcfg-eth<N> 파일 예제
■ 고정 IP 설정 예(Static IP 설정) /* IP를 고정을 할당 */
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
-----------------------------------------------
DEVICE=eth0
BOOTPROTO=none or BOOTPROTO=static
ONBOOT=yes
NETWORK=172.16.0.0
NETMASK=255.255.0.0
IPADDR=172.16.9.249
USERCTL=no
-----------------------------------------------
■ 동적 IP 설정 예(Dynamic IP 설정) /* DHCP 서버로 부터 IP 할당 */
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
-----------------------------------------------
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
-----------------------------------------------
(6) 현재 설정 확인
(현재 IP 설정 확인)
# ifconfig /* 활성화(Activate) 된 인터페이스에 대한서만 정보 확인 */
# ifconfig -a /* 활성화(Activate) + 비활성화(Deactivate) 된 인터페이스 정보 확인 */
[root@linux220 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:185017 errors:0 dropped:0 overruns:0 frame:0
TX packets:1614 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19347129 (18.4 MiB) TX bytes:179846 (175.6 KiB)
Interrupt:67 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:11303 errors:0 dropped:0 overruns:0 frame:0
TX packets:11303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:48556835 (46.3 MiB) TX bytes:48556835 (46.3 MiB)
[root@linux220 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186397 errors:0 dropped:0 overruns:0 frame:0
TX packets:1614 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19468382 (18.5 MiB) TX bytes:179846 (175.6 KiB)
Interrupt:67 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:11303 errors:0 dropped:0 overruns:0 frame:0
TX packets:11303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:48556835 (46.3 MiB) TX bytes:48556835 (46.3 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@linux220 ~]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 172.16.0.1 0.0.0.0 UG 0 0 0 eth0
[root@linux220 ~]# cat /etc/resolv.conf
search example.com
nameserver 168.126.63.1
[참고] NIC카드 설정값 확인하는 명령어(ethtool)
■ ethtool
Display or change ethernet card settings
-> 전송속도 선택(10M/100M/1000M)
-> 전이중/반이중 방식 선택(Full Duplex, Half Duplex)
-> (사용방법 확인)
# ethtool
# man ethtool
[root@linux220 ~]# ethtool eth0
Settings for eth0:
Current message level: 0x00000007 (7)
Link detected: yes
[root@linux220 ~]# ethtool eth0 | grep Link
Link detected: yes
주로 링크디텍티드를 확인, 케이블 뽑히면 no 라고 나옴
(정리) 네트워크 설정 확인
(ㄱ) 물리적인 연결 확인
# ethtool eth0
(ㄴ) IP 확인
# ifconfig
(ㄷ) defaultrouter 확인
# netstat –nr
(ㄹ) DNS 클라이언트 설정 확인
# cat /etc/resolv.conf (# cat /etc/host.conf, /etc/nsswitch.conf)
어? 내가 인터넷이 안된다
1. 랜선연결 확인 # ethtool eth0
2. 같은 네트워크에 있는 PC에 핑테스트 # ping IP -> # ethtool eth0, # ifconfig
3. 외부 IP로 핑테스트 # ping IP(DNS 서버) -> # netstat -nr
4. # ping www.google.com -> # cat /etc/resolv.conf
2 네트워크 설정 툴 종류
■ 네트워크 설정 툴
# export LANG=en_US.UTF-8 (# export LANG=C)
(TUI) # system-config-network-tui (# setup)
(GUI) # system-config-network-gui (# neat)
# service network restart
[EX] 네트워크 설정 툴에 대한 실습
[root@linux220 ~]# yum list | grep system-config
system-config-date.noarch 1.8.12-5.el5.centos installed
system-config-display.noarch 1.0.48-4.el5 installed
system-config-httpd.noarch 5:1.3.3.3-1.el5 installed
system-config-kdump.noarch 1.0.14-5.el5_9 installed
system-config-keyboard.noarch 1.2.11-1.el5 installed
system-config-language.noarch 1.1.18-3.el5 installed
system-config-lvm.noarch 1.1.5-14.el5 installed
system-config-network.noarch 1.3.99.23-1.el5 installed
system-config-network-tui.noarch 1.3.99.23-1.el5 installed
system-config-nfs.noarch 1.3.23-2.el5 installed
system-config-printer.i386 0.7.32.10-3.el5 installed
system-config-printer-libs.i386 0.7.32.10-3.el5 installed
system-config-rootpassword.noarch 1.1.9.1-1 installed
system-config-samba.noarch 1.2.41-5.el5 installed
system-config-securitylevel.i386 1.6.29.1-6.el5 installed
system-config-securitylevel-tui.i386 1.6.29.1-6.el5 installed
system-config-services.noarch 0.9.4-5.el5 installed
system-config-soundcard.noarch 2.0.6-1.el5 installed
system-config-users.noarch 1.2.51-7.el5 installed
system-config-audit.i386 0.4.10-7.el5 base
system-config-bind.noarch 4.0.3-6.el5.centos base
system-config-boot.i386 0.2.13-1.el5 base
system-config-cluster.noarch 1.0.57-17 base
system-config-kickstart.noarch 2.6.19.9-2.el5 base
system-config-netboot.noarch 0.1.45.1-5.el5 base
system-config-netboot-cmd.noarch 0.1.45.1-5.el5 base
[root@linux220 ~]#
[참고] redhat-config-* && system-config-*
RHEL 3.X : redhat-config-* (CentOS 3.X)
RHEL 4.X : system-config-* (CentOS 4.X) 오해가 있을까봐 변경
[root@linux220 ~]# system-config-
system-config-authentication system-config-nfs
system-config-date system-config-packages
system-config-display system-config-printer
system-config-httpd system-config-rootpassword
system-config-kdump system-config-samba
system-config-keyboard system-config-securitylevel
system-config-language system-config-securitylevel-tui
system-config-lvm system-config-services
system-config-network system-config-soundcard
system-config-network-cmd system-config-time
system-config-network-gui system-config-users
system-config-network-tui
[root@linux220 ~]# system-config-
■ IP 변경 (172.16.9.2XX -> 172.16.9.1XX)
# system-config-network-tui
-> "Edit Devices"
-> "eth0 (eth0) - Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]"
-------------------------------------------
Name eth0
Device eth0
Use DHCP [ ]
Static IP 172.16.9.1XX /* (EX) 172.16.9.202 -> 172.16.9.102 */
Netmask 255.255.0.0
Default gateway IP 172.16.0.1
-------------------------------------------
[root@linux220 ~]# system-config-network-tui
[root@linux220 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=172.16.255.255
#HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.120
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:bf
GATEWAY=172.16.0.1
TYPE=Ethernet
[root@linux220 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:247501 errors:0 dropped:0 overruns:0 frame:0
TX packets:1956 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25691137 (24.5 MiB) TX bytes:205254 (200.4 KiB)
Interrupt:67 Base address:0x2000
[root@linux220 ~]# cd /etc/sysconfig/network-scripts/
[root@linux220 /etc/sysconfig/network-scripts]# ls
ifcfg-eth0 ifdown-isdn ifup-aliases ifup-plip ifup-wireless
ifcfg-lo ifdown-post ifup-bnep ifup-plusb init.ipv6-global
ifdown ifdown-ppp ifup-eth ifup-post net.hotplug
ifdown-bnep ifdown-routes ifup-ippp ifup-ppp network-functions
ifdown-eth ifdown-sit ifup-ipsec ifup-routes network-functions-ipv6
ifdown-ippp ifdown-sl ifup-ipv6 ifup-sit
ifdown-ipsec ifdown-tunnel ifup-ipx ifup-sl
ifdown-ipv6 ifup ifup-isdn ifup-tunnel
[root@linux220 /etc/sysconfig/network-scripts]# cat ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=172.16.255.255
#HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.120
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:bf
GATEWAY=172.16.0.1
TYPE=Ethernet
[root@linux220 /etc/sysconfig/network-scripts]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:250552 errors:0 dropped:0 overruns:0 frame:0
TX packets:1956 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25970819 (24.7 MiB) TX bytes:205254 (200.4 KiB)
Interrupt:67 Base address:0x2000
[root@linux220 /etc/sysconfig/network-scripts]# service network restart
인터페이스 eth0 (을)를 종료 중: [ OK ]
loopback 인터페이스를 종료 중: [ OK ]
loopback 인터페이스를 활성화 중: [ OK ]
eth0 인터페이스 활성화 중: [ OK ]
[root@linux220 /etc/sysconfig/network-scripts]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.120 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:251902 errors:0 dropped:0 overruns:0 frame:0
TX packets:1988 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26159522 (24.9 MiB) TX bytes:211106 (206.1 KiB)
Interrupt:67 Base address:0x2000
[root@linux220 /etc/sysconfig/network-scripts]#
■ IP 변경 (172.16.9.1XX -> 172.16.9.2XX)
# system-config-network-gui &
-------------------------------------------
Address 172.16.9.2XX /* 172.16.9.102 -> 172.16.9.202 */
Subnet Mast 255.255.0.0
Default gateway Address 172.16.0.1
-------------------------------------------
[root@linux220 /etc/sysconfig/network-scripts]# cd
[root@linux220 ~]# system-config-network-gui &
[1] 7587
[root@linux220 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.120 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:255548 errors:0 dropped:0 overruns:0 frame:0
TX packets:1988 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26520826 (25.2 MiB) TX bytes:211106 (206.1 KiB)
Interrupt:67 Base address:0x2000
[1]+ Done system-config-network-gui
[root@linux220 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=172.16.255.255
#HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.220
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:bf
GATEWAY=172.16.0.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[root@linux220 ~]# service network restart
인터페이스 eth0 (을)를 종료 중: [ OK ]
loopback 인터페이스를 종료 중: [ OK ]
loopback 인터페이스를 활성화 중: [ OK ]
eth0 인터페이스 활성화 중: [ OK ]
[root@linux220 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=172.16.255.255
#HWADDR=00:0C:29:1F:D6:BF
IPADDR=172.16.6.220
NETMASK=255.255.0.0
NETWORK=172.16.0.0
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:bf
GATEWAY=172.16.0.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
[root@linux220 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:256951 errors:0 dropped:0 overruns:0 frame:0
TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26704218 (25.4 MiB) TX bytes:217293 (212.2 KiB)
Interrupt:67 Base address:0x2000
[root@linux220 ~]#
3 네트워크 시나리오 작업
■NIC 카드 추가 작업
[참고] NIC(Network Interface Card) - Network Adapter, Network Card
(1) NIC 추가 작업
(1-1) NIC 이름 체계
NIC1 ---- alias ----> eth0 (ethernet card 0 번째)
NIC2 ---- alias ----> eth1 (ethernet card 1 번째)
NIC3 ---- alias ----> eth2 (ethernet card 2 번째)
......
[참고] NIC 커널 모듈
■ 이더넷 모듈 디렉토리 (/lib/modules/<커널버전>/kernel/drivers/net
많이 사용되는 이더넷 카드의 커널 모듈명
----------------------------------------------------------
Intel Express Pro100 e100
Intel 3945ABG Wireless PCI ipw3945
Intel 2200BG Wireless PCI ipw2200
Intel 2100NC Wireless ipw2100
Marvell Yukon 88E8055 forcedeth
Realtek 8139 8139too
Realtek 8169 r8169
----------------------------------------------------------
(1-2) NIC 추가 작업 순서
(a) NIC 장치 추가
(b) NIC 장치 인식
(c) NIC 네트워크 설정
① kudzu 서비스 ON
# chkconfig —list kudzu
# chkconfig kudzu on (# chkconfig --level 345 on)
#
② 서버 전원 OFF && NIC 장착 && 재부팅
# poweroff
새로운 NIC 장착 과정
■ VMWare > VM > Setting > Add > "Network Adapter" > NAT 방식
■ Power ON
■ root 사용자로 로그인
VMware DHCP 서버를 on
■ VMWare > Edit > Virtual Network Editor > VMnet8(NAT)
"[ V ] Use local DHCP service to distribute IP address to VMs"
[root@linux220 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2839 errors:0 dropped:0 overruns:0 frame:0
TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:269726 (263.4 KiB) TX bytes:6410 (6.2 KiB)
Interrupt:67 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:C9
inet6 addr: fe80::20c:29ff:fe1f:d6c9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:243 (243.0 b) TX bytes:6095 (5.9 KiB)
Interrupt:67 Base address:0x2080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3806 errors:0 dropped:0 overruns:0 frame:0
TX packets:3806 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4845328 (4.6 MiB) TX bytes:4845328 (4.6 MiB)
[root@linux220 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4590 errors:0 dropped:0 overruns:0 frame:0
TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:435520 (425.3 KiB) TX bytes:6410 (6.2 KiB)
Interrupt:67 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:C9
inet6 addr: fe80::20c:29ff:fe1f:d6c9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:243 (243.0 b) TX bytes:6095 (5.9 KiB)
Interrupt:67 Base address:0x2080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3806 errors:0 dropped:0 overruns:0 frame:0
TX packets:3806 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4845328 (4.6 MiB) TX bytes:4845328 (4.6 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@linux220 ~]# cd /etc/sysconfig/network-scripts/
[root@linux220 /etc/sysconfig/network-scripts]# ls
ifcfg-eth0 ifdown-ipv6 ifup ifup-isdn ifup-tunnel
ifcfg-eth1 ifdown-isdn ifup-aliases ifup-plip ifup-wireless
ifcfg-lo ifdown-post ifup-bnep ifup-plusb init.ipv6-global
ifdown ifdown-ppp ifup-eth ifup-post net.hotplug
ifdown-bnep ifdown-routes ifup-ippp ifup-ppp network-functions
ifdown-eth ifdown-sit ifup-ipsec ifup-routes network-functions-ipv6
ifdown-ippp ifdown-sl ifup-ipv6 ifup-sit
ifdown-ipsec ifdown-tunnel ifup-ipx ifup-sl
[root@linux220 /etc/sysconfig/network-scripts]# cat ifcfg-eth1
# Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:c9
[root@linux220 /etc/sysconfig/network-scripts]#
③ NIC 네트워크 설정
# system-config-network-tui
-> "Edit Devices"
-> "eth1 (eth1) - Intel Corporation 82545EM Gigabit Ethernet Controller"
----------------------------------------
Name eth1
Device eth1
Use DHCP [ ]
Static IP 192.168.10.2XX /* (EX) 192.168.10.202 */
Netmask 255.255.255.0
Default gateway IP
----------------------------------------
[root@linux220 /etc/sysconfig/network-scripts]# export LANG=en_US.UTF-8
[root@linux220 /etc/sysconfig/network-scripts]# echo $LANG
en_US.UTF-8
[root@linux220 /etc/sysconfig/network-scripts]# system-config-network-tui
[root@linux220 /etc/sysconfig/network-scripts]# cat ifcfg-eth1
# Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:1f:d6:c9
NETMASK=255.255.255.0
IPADDR=192.168.10.220
TYPE=Ethernet
[root@linux220 /etc/sysconfig/network-scripts]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
[root@linux220 /etc/sysconfig/network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:BF
inet addr:172.16.6.220 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fe1f:d6bf/64 Scope:Site
inet6 addr: fe80::20c:29ff:fe1f:d6bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11839 errors:0 dropped:0 overruns:0 frame:0
TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1170751 (1.1 MiB) TX bytes:13280 (12.9 KiB)
Interrupt:67 Base address:0x2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:1F:D6:C9
inet addr:192.168.10.220 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1f:d6c9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2556 (2.4 KiB) TX bytes:12097 (11.8 KiB)
Interrupt:67 Base address:0x2080
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3806 errors:0 dropped:0 overruns:0 frame:0
TX packets:3806 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4845328 (4.6 MiB) TX bytes:4845328 (4.6 MiB)
[root@linux220 /etc/sysconfig/network-scripts]#
4 이더채널 본딩(Ether Channel Bonding)
다음 문서는 이대섭님의 "RHEL 5 Bonding" 문서를 참고하여 만들어졌습니다.
이대섭님의 문서는 http://cafe.daum.net/bscsolaris 사이트에서 찾아 보실수 있습니다.
-----------------+-------+----------------
| |
+-------+-------+- ------+
| NIC1 NIC2 |
| |
| |
| |
| |
+------------------------+
■ RedHat 이더채널 본딩(EtherChannel Bonding)
■ Windows 티밍(Teaming) 팀-잉
■ Oracle Solaris IPMP(Internet Protocol Multi-Pathing), Trunking
■ IBM AIX EtherChannel
■ HP HP-UX APA
(필요성) 정보 제공 하는 서버, 자원 제공하는 서버
정보 제공하는 서버 : DB 서버(EX: Oracle, DB2), 인증서버(LDAP, NIS+)
자원 제공하는 서버 : NFS 서버(EX: NAS)
(1) 이더채널 본딩(Ether Channel Bonding)이란?
하나의 노드(Node)에 여러개의 NIC(Network Interface Card)를 하나의 IP로 묶어서 사용하는 것을 말 한다.
시스템에서 네트워크를 통해 서비스되고 있는 프로그램을 중단 없이 서비스 하기 위해 사용한 다.
즉, 여러장의 NIC(EX: eth#)를 하나의 논리적 인터페이스(EX: bond#)으로 묶어서 사용하는 방식 이다.
하나의 NIC가 물리적으로 이상(EX: FAIL)이 발생해도 서비스의 중지가 발생하지 않는다.
이더채널 본딩을 사용하면
(ㄱ) 장애 극복(Failover) 기능과
(ㄴ) 부하 분산 기능(Load Balancing)을
제공한다.
(2) 이더채널 본딩 모드 종류
이더채널 본딩 모드 종류는 7가지가 존재한다.
0 -> balance-rr (Round-robin)
2개의 포트를 사용하여 부하분산과 장애극복을 제공, 기본모드이다 (default)
*Active-Active
1 -> active-backup
하나의 포트만 활성화하고 장애 발생시 대기중인 포트가 장애를 대처한다
*Active-Standby
2 -> balance-xor (XOR)
출발 MAC 주소와 도착 MAC 주소를 통해서만 전송하며, 부하분산과 장애감시를 제공한다
3 -> broadcast
서버의 모든 포트에 전송을 시도하는 방식이다
4 -> 802.3ad
Link Aggregation 방식으로 사용하기 위해선 스위치에 그룹 생성이 필요하다
5 -> balance-tlb (Adaptive transmit load balancing)
로드밸런싱의 방법으로 보내는 패킷만 로드밸런스한다
6 -> balance-alb (Adaptive load balancing)
패킷을 로드밸런싱하며, 하나의 스위치에 있을때만 가능하다
(3) 관련 용어
■ miimon
Specifies (in milliseconds) how often MII link monitoring occurs. This is useful if high
availability is required because MII is used to verify that the NIC is active. To verify that
the driver for a particular NIC supports the MII tool, type the following command as root:
# ethtool <interface_name> | grep "Link detected:"
Link detected: yes
In this command, replace <interface_name> with the name of the device interface, such as eth0,
not the bond interface.
If using a bonded interface for high availability, the module for each NIC must support MII.
Setting the value to 0 (the default), turns this feature off. When configuring this setting, a
good starting point for this parameter is 100.
링크 감시(mii)가 발생할 때 밀리 초 단위로 감시한다. 사용하지 않으려면 값을 '0'으로 설정하면
된다. 사용시 '100'(100 milliseconds = 0.1 초)으로 설정하는 것을 권장한다. 기본값은 '0'이다.
1/1000초. 설정값이 100이면 100/1000초 = 0.1초
■ primary
Specifies the interface name, such as eth0, of the primary device. The primary device is the
first of the bonding interfaces to be used and is not abandoned unless it fails. This setting
is particularly useful when one NIC in the bonding interface is faster and, therefore, able to
handle a bigger load.
This setting is only valid when the bonding interface is in active-backup mode. Refer to
/usr/share/doc/kernel-doc-<kernel-version>/Documentation/networking/
bonding.txt for more information.
주 포트를 정해줄때 사용한다. 2개의 포트를 사용중에 1번 포트가 장애가 발생하여 2번 포트가 대신 통신을 유지하고 있을 때,
1번 포트가 다시 정상 작동하면 1번 포트를 전송이 넘어가며 2번 포 트는 다시 Standby 상태로 변하는 것을 지정할 때 사용된다.
(4) 이더채널 본딩 설정
실무에서 많이 사용되고 있는 이더채널 본딩 모드는
(ㄱ) Mode '0'(Active-Active) - balance-rr
(ㄴ) Mode '1'(Active-Standby) - Active-Backup
이다.
Mode 0 (Active + Active)
l 2개의 포트를 하나의 IP로 묶어 사용하므로
전송 데이터를 로드벨런싱하며, 1개의 포트
에 장애 발생시 다른 포트에서 지속적으로
통신을 유지해 준다.
Mode 1 (Active + Standby)
l 2개의 포트를 하나의 IP로 묶어서 사용하며
하나의 포트는 전송을 전담하고 다른 포트는
사용 대기(Standby) 상태를 유지하다가 만약
사용중인 포트에 장애가 발생하면 다른 포트 에서 연결을 이어받아 서비스를 지속적으로
사용 가능하게 해 준다.
이더채널 본딩 설정시 Mode 0/Mode 1 설정에 대해서만 다룬다.
(4-1) 이더채널 본딩 Mode 0(Active-Active, Balance-rr) 설정
(전제조건)
◾ Bonding을 설정하기 위한 서버에 NIC 2장 존재해야 한다.
◾ NIC는 같은 네트워크 대역에 존재해야 한다.
---------------- VMWare 환경 ---------------
서버1(172.16.9.2XX): 원본 서버
NIC1(eth0) 사용 0 (Bridge -> NAT)
NIC2(eth1) 사용 0 (NAT)
서버2 : 서버1 clone
NIC1(eth0) 사용 0(테스트 용도로만 사용) (Bridge -> NAT)
NIC2(eth1) 사용 X (NAT)
(ㄱ) (서버1) eth0 : Bridge -> NAT
(ㄴ) (서버1)
# vi /etc/sysconfig/network-scripts/ifcfg-(eth0|eth1)
-> MAC 주소 지우는 작업 필요(HWADDR)
# poweroff
VMWare > VM > Clone > Current Virtual Machine > Link Clone
(서버2)
Power ON
root 사용자로 로그인 # system-config-network-tui
# export LANG=en_US.UTF-8 (# export LANG=C)
호스트 이름: linux2XX.example.com -> linux1XX.example.com
(eth0) IP/Netmask : 192.168.10.150/255.255.255.0 (Static IP)
(eth1) 설정을 건드리지 않는다.
# vi /etc/hosts
재부팅(# reboot)
(서버1)
Power ON
root 사용자로 로그인
Bonding 설정(본딩 설정은 아래 문서 참고)
---------------- VMWare 환경 ---------------
----- bond0(192.168.10.100) -------+----- eth0(Active) -----
|
+------ eth1(Active) -----
[참고] bond0(Active-Active) 설정 예
(작업순서) 이더채널 본딩(EtherChannel Bonding)
◾ /etc/modprobe.conf 파일 설정
◾ /etc/sysconfig/network-scripts/ifcfg-bond0 파일 설정
◾ /etc/sysconfig/network-scripts/ifcfg-eth0 파일 설정
◾ /etc/sysconfig/network-scripts/ifcfg-eth1 파일 설정
gold-image = shared VM
■ 서버1(원본 서버) linux2XX
① /etc/modprobe.conf 파일 설정 # vi /etc/modprobe.conf
alias bond0 bonding <----- 새로운 라인 추가
② /etc/sysconfig/network-scripts/ifcfg-bond0 파일 설정
# cd /etc/sysconfig/network-scripts
# cp ifcfg-eth0 ifcfg-bond0
# vi ifcfg-bond0
[수정전]
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=
BROADCAST=
IPADDR=
NETMASK=
NETWORK=
ONBOOT=yes
[수정후]
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.10.255
IPADDR=192.168.10.100
NETMASK=255.255.255.0
NETWORK=192.168.10.0
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=0 miimon=100"
③ /etc/sysconfig/network-scripts/ifcfg-eth0 파일 설정 # vi ifcfg-eth0
미완
클론이랑 충돌이 일어나지 않고 기동시킨 상태를 만들었음
eth0.bak 이 생성이 되었는데 그 이유가 아까 맥어드레스(HWADDR) 지울때 지우지않고 추석처리했기 때문임
'모의해킹 침해대응 전문가 과정' 카테고리의 다른 글
20160503 리눅스 네트워크 (0) | 2016.05.04 |
---|---|
20160502 리눅스 네트워크 (0) | 2016.05.03 |
20160429 리눅스 관리자 (0) | 2016.05.01 |
20160428 리눅스 관리자 (0) | 2016.05.01 |
20160427 리눅스 관리자 (0) | 2016.04.28 |