서버/Linux III 2016. 3. 9. 16:25
Linux III - 02. 리눅스 네트워크 설정
login as: root
root@192.168.1.1's password:
Last login: Wed Mar 9 15:45:26 2016 from 192.168.1.10
[root@main /root]#
1. 네트워크 장치 확인
리눅스에서는 네트워크 장치는 '/etc/sysconfig/network-scripts' 디렉토리에서 'ifcfg-인터페이스 이름' 파일로 관리한다.
[root@main /root]# ls /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-lo
/etc/sysconfig/network-scripts/ifcfg-eth1
1) 네트워크 장치 정보 확인
- 리눅스에서는 네트워크 장치를 확인하려면, 'ifconfig' 명령어를 사용한다. 윈도우의 'ipconfig'와 동일하다.
[root@centosmain /root]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6491 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:583192 (569.5 KiB) TX bytes:769 (769.0 b)
eth1 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:4A
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee9:9c4a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:138 errors:0 dropped:0 overruns:0 frame:0
TX packets:143 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18996 (18.5 KiB) TX bytes:14181 (13.8 KiB)
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:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 b) TX bytes:240 (240.0 b)
2) Loopback 도메인 이름 확인
[root@main /root]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
3) 특정 이더넷 장치 정보 확인
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:64781 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5821896 (5.5 MiB) TX bytes:769 (769.0 b)
4) 특정 이더넷 장치 Down / UP 하는 방법
[root@main /root]# ifconfig eth0 down
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:95908 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8566211 (8.1 MiB) TX bytes:769 (769.0 b)
[root@main /root]# ifconfig eth0 up
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:95982 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8573112 (8.1 MiB) TX bytes:1047 (1.0 KiB)
2. IP 주소 설정 및 변경
Ex1) IP 주소 변경
[root@main /root]# ifconfig eth0 down
[root@main /root]# ifconfig eth0 172.20.10.1
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.10.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:106219 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:9490565 (9.0 MiB) TX bytes:2595 (2.5 KiB)
Ex2) IP 주소, 서브넷 마스크, 서브넷 브로드케스트 주소 변경
[root@main /root]# ifconfig eth0 down
[root@main /root]# ifconfig eth0 172.20.10.1 netmask 255.255.255.0 broadcast 172.20.10.255
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.10.1 Bcast:172.20.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:110157 errors:0 dropped:0 overruns:0 frame:0
TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9843160 (9.3 MiB) TX bytes:3053 (2.9 KiB)
Ex3) 원래 IP 주소로 변경
[root@main /root]# ifconfig eth0 down
[root@main /root]# ifconfig eth0 172.20.1.1
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:111011 errors:0 dropped:0 overruns:0 frame:0
TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9920874 (9.4 MiB) TX bytes:3331 (3.2 KiB)
- 위의 설정은 메모리에 올라가는 정보이기 때문에 재부팅되면 초기화된다.
- 그렇기 때문에 '/etc/sysconfig/network-scripts/ifcfg-eth0' 스크립트 파일을 vi 편집기를 이용하여 설정하여 저장해야 한다.
Ex4) 'ifcfg-eth0' 스크립트 파일을 이용한 IP 주소 설정
[root@main /root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=10a63f41-0a00-4e31-8112-ccb1d344bfc6
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
HWADDR=00:0C:29:E9:9C:40
IPADDR=172.20.1.1
PREFIX=16
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
[root@main /root]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
1 DEVICE=eth0 : wq! |
- IP 주소 정보가 확인되지 않거나, 변경되지 않는다.
[root@main /root]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe7e:8e97/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2038 errors:0 dropped:0 overruns:0 frame:0
TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:179855 (175.6 KiB) TX bytes:4525 (4.4 KiB)
- 재부팅하거나, 또는 다음과 같이 'network' 스크립트를 재시작한다.
[root@main /root]# cd /etc/init.d
[root@centosmain /etc/init.d]# ./network restart
인터페이스 eth1 (을)를 종료 중: 장치 상태: 3 (연결 끊겼음)
[ OK ]
loopback 인터페이스 종료 중: [ OK ]
loopback 인터페이스 활성화중 입니다: [ OK ]
eth0 인터페이스 활성화중 입니다: Determining if ip address 172.20.10.1 is already in use for device eth0...
[ OK ]
eth1 인터페이스 활성화중 입니다: 활성화된 연결 상태: 활성화됨
활성화된 연결 경로: /org/freedesktop/NetworkManager/ActiveConnection/5
[ OK ]
[root@main /etc/init.d]# ifconfig eth0
eth0 Link encap:Ethernet 00:0C:29:E9:9C:40
inet addr:172.20.10.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2420 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:212824 (207.8 KiB) TX bytes:6183 (6.0 KiB)
Ex5) 'setup' 모드를 이용한 IP 주소 설정
[root@main /etc/init.d]# setup
'네트워크 설정' 엔터
'장치 설정' 엔터
'eth0' 엔터
eth0 IP 주소 관련 설정 -> 'Ok' 엔터
'저장' 엔터
'저장&종료' 엔터
'종료' 엔터
- IP 주소가 변경되지 않은것을 확인할 수 있다.
[root@main /etc/init.d]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.10.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3539 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:310083 (302.8 KiB) TX bytes:6183 (6.0 KiB)
- 재부팅하거나, 또는 다음과 같이 'network' 스크립트를 재시작한다.
[root@main /etc/init.d]# ./network restart
인터페이스 eth0 (을)를 종료 중: [ OK ]
인터페이스 eth1 (을)를 종료 중: 장치 상태: 3 (연결 끊겼음)
[ OK ]
loopback 인터페이스 종료 중: [ OK ]
loopback 인터페이스 활성화중 입니다: [ OK ]
eth0 인터페이스 활성화중 입니다: Determining if ip address 172.20.1.1 is already in use for device eth0...
[ OK ]
eth1 인터페이스 활성화중 입니다: 활성화된 연결 상태: 활성화됨
활성화된 연결 경로: /org/freedesktop/NetworkManager/ActiveConnection/7
[ OK ]
[root@main /etc/init.d]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.20.1.1 Bcast:172.20.255.255 Mask:255.255.0.0
inet6 addr: fec0:1234::20c:29ff:fee9:9c40/64 Scope:Site
inet6 addr: fe80::20c:29ff:fee9:9c40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4744 errors:0 dropped:0 overruns:0 frame:0
TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:430216 (420.1 KiB) TX bytes:6867 (6.7 KiB)
[root@main /etc/init.d]# cd
[root@main /root]#
3. 서브-인터페이스
- 이더넷 인터페이스는 서브-인터페이스가 제공되기 때문에 복수개의 IP 주소를 설정할 수 있다.
- 이때, 서브-인터페이스는 주-인터페이스에서 제공하는 분리된 논리적인 인터페이스이다.
Ex1) 서브-인터페이스 정보 확인
[root@main /root]# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[root@main /root]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[root@main /root]# ifconfig eth0:2
eth0:2 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Ex2) 서브-인터페이스 IP 주소 설정 및 삭제
[root@main /root]# ifconfig eth0:1 172.16.4.100
[root@main /root]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
inet addr:172.16.4.100 Bcast:172.16.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[root@main /root]# ping -c 1 172.16.4.100
PING 172.16.4.100 (172.16.4.100) 56(84) bytes of data.
64 bytes from 172.16.4.100: icmp_seq=1 ttl=255 time=20.8 ms
--- 172.16.4.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 20ms
rtt min/avg/max/mdev = 20.819/20.819/20.819/0.000 ms
[root@main /root]# ifconfig eth0:1 down
[root@main /root]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:E9:9C:40
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
4. 네트워크 서비스 재시작
- 네트워크 서비스를 재시작하는 방법은 '/etc/init.d' 디렉토리에 있는 'network' 스크립트 파일을 재시작해야 한다.
- 또다른 방법으로는 다음과 같이 'service network start' 명령어를 사용하면 된다.
[root@main /root]# service network restart
인터페이스 eth0 (을)를 종료 중: [ OK ]
인터페이스 eth1 (을)를 종료 중: [ OK ]
loopback 인터페이스 종료 중: [ OK ]
loopback 인터페이스 활성화중 입니다: [ OK ]
eth0 인터페이스 활성화중 입니다: Determining if ip address 172.20.1.1 is already in use for device eth0...
[ OK ]
eth1 인터페이스 활성화중 입니다: Determining if ip address 192.168.1.100 is already in use for device eth1...
[ OK ]
[root@main /root]#
5. 라우팅 테이블 및 경로 설정
- 라우팅 테이블을 확인하려면, 'route' 명령어를 사용한다.
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
- 라우팅 테이블에 경로 등록은 다음과 같다. 단, 네트워크 서비스가 재시작되면 삭제된다.
[root@main /root]# route add -net 168.126.63.0 netmask 255.255.255.0 gw 192.168.1.254 dev eth1
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
168.126.63.0 192.168.1.254 255.255.255.0 UG 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
- 경로 삭제는 다음과 같다.
[root@main /root]# route del -net 168.126.63.0 netmask 255.255.255.0
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
- 기본 게이트웨이(기본 경로) 설정 및 삭제는 다음과 같다.
[root@main /root]# route add default gw 172.20.0.1
또는
[root@main /root]# route add -net 0.0.0.0 netmask 0.0.0.0 gw 172.20.0.1 dev eth0
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 172.20.0.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
[root@main /root]# route del default gw 172.20.0.1
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
- 다음과 같은 방법으로도 기본 게이트웨이(기본 경로)를 삭제할 수 있다.
[root@main /root]# route del default
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
- 기본 게이트웨이(기본 경로) 정보가 없기 때문에 인터넷으로 패켓을 전송할 수 없다.
[root@main /root]# ping -c 1 168.126.63.1
connect: 네트워크가 접근 불가능합니다
- 'network' 서비스를 재시작하면, 'network' 스크립트 파일에 설정된 내용으로 재시작한다.
[root@main /root]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=f0625107-190c-4dd7-8a2c-41b65a08749b
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
HWADDR=00:0C:29:E9:9C:4A
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.254
DNS1=168.126.63.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
HWADDR=00:50:56:21:CA:E5
USERCTL=no
[root@main /root]# service network restart
인터페이스 eth0 (을)를 종료 중: [ OK ]
인터페이스 eth1 (을)를 종료 중: [ OK ]
loopback 인터페이스 종료 중: [ OK ]
loopback 인터페이스 활성화중 입니다: [ OK ]
eth0 인터페이스 활성화중 입니다: Determining if ip address 172.20.1.1 is already in use for device eth0...
[ OK ]
eth1 인터페이스 활성화중 입니다: Determining if ip address 192.168.1.100 is already in use for device eth1...
[ OK ]
[root@main /root]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth1
[root@main /root]# ping -c 1 168.126.63.1
PING 168.126.63.1 (168.126.63.1) 56(84) bytes of data.
64 bytes from 168.126.63.1: icmp_seq=1 ttl=128 time=17.0 ms
--- 168.126.63.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 17ms
rtt min/avg/max/mdev = 17.003/17.003/17.003/0.000 ms
[참고] 정적 경로 파일 설정
- 'route add' 명령어로 설정한 정적 경로는 재시작되거나 재부팅되면 사라진다.
- 만약, 정적 경로를 계속 사용하려면 다음과 같이 설정하면 된다.
[root@main /root]# vi /etc/sysconfig/network-scripts/route-eth1
GATEWAY0=192.168.2.254
:wq! |
6. DNS 서버 지정
- DNS 서버 정보는 다음과 같이 '/etc/resolv.conf' 파일로 관리한다.
[root@main /root]# cat /etc/resolv.conf
# Generated by NetworkManager
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
nameserver 168.126.63.1
- 'main' 서버를 설치할때, eth1에 DNS 서버 주소를 수동으로 설정했기 때문에 'ifcfg-eth1' 파일에 저장되어 있다.
[root@main /root]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
UUID=f0625107-190c-4dd7-8a2c-41b65a08749b
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
HWADDR=00:0C:29:E9:9C:4A
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.254
DNS1=168.126.63.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth1"
HWADDR=00:50:56:21:CA:E5
USERCTL=no
- 다음과 같이 'nslookup' 명령어를 사용하여 DNS 요청/응답 테스트를 할 수 있다.
[root@main /root]# nslookup www.naver.com
Server: 168.126.63.1
Address: 168.126.63.1#53
Non-authoritative answer:
www.naver.com canonical name = www.naver.com.nheos.com.
Name: www.naver.com.nheos.com
Address: 125.209.222.141
Name: www.naver.com.nheos.com
Address: 202.179.177.22
7. Host 지정
- 특정 시스템 및 서버에 도메인이 없다면, 다음과 같이 '/etc/hosts' 파일에 수동으로 등록하면 된다.
[root@main /root]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@main /root]# vi /etc/hosts
1 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 : wq! |
[root@main /root]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.20.1.1 main main.com
[root@main /root]# ping -c 1 main
PING main (172.20.1.1) 56(84) bytes of data.
64 bytes from main (172.20.1.1): icmp_seq=1 ttl=64 time=0.017 ms
--- centosmain ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.017/0.017/0.017/0.000 ms
[root@main /root]# ping -c 1 main.com
PING main (172.20.1.1) 56(84) bytes of data.
64 bytes from main (172.20.1.1): icmp_seq=1 ttl=64 time=0.025 ms
--- centosmain ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.025/0.025/0.025/0.000 ms
8. Hostname 설정
- 호스트 이름은 다음과 같이 '/etc/sysconfig' 디렉토리에 'network' 파일로 관리한다.
- vi 편집기를 이용하여 변경할 수 있으며, 변경시 시스템을 재부팅해야 한다.
[root@main /root]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=main
GATEWAY=192.168.1.254
NTPSERVERARGS=iburst
9. SELinux 비활성화
- SELinux는 리눅스 서버에 대한 보안을 강화하기 위해서 제공하는 기능이다.
- 이 기능이 활성화되어있다면, 실습 진행시 불편한 점이 있기 때문에 비활성화 하도록 한다.
[root@main /root]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
[root@main /root]# vi /etc/selinux/config
1 # This file controls the state of SELinux on the system.
: wq! |
10. ARP 테이블 확인 및 삭제
[root@main /root]# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.254 ether 00:50:56:e7:32:90 C eth1
192.168.1.1 ether 00:50:56:c0:00:08 C eth1
[root@main /root]# arp -d 192.168.2.254
[root@main /root]# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.254 (incomplete) eth1
192.168.1.1 ether 00:50:56:c0:00:08 C eth1
[root@main /root]# ping -c 1 168.126.63.1
PING 168.126.63.1 (168.126.63.1) 56(84) bytes of data.
64 bytes from 168.126.63.1: icmp_seq=1 ttl=128 time=3.21 ms
--- 168.126.63.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 3.211/3.211/3.211/0.000 ms
[root@main /root]# arp -n
Address HWtype HWaddress Flags Mask Iface
192.168.1.254 ether 00:50:56:e7:32:90 C eth1
192.168.1.1 ether 00:50:56:c0:00:08 C eth1
- 클론 서버를 구성하기 위해서 'main' 서버는 종료하도록 한다.
[root@main /root]# init 0
'서버 > Linux III' 카테고리의 다른 글
Linux III - 06. FTP 클라이언트 (0) | 2016.03.15 |
---|---|
Linux III - 05. 리눅스 서비스 운영 방식(Standalone & xinetd) (0) | 2016.03.14 |
Linux III - 04. 방화벽 해지하는 방법 (0) | 2016.03.14 |
Linux III - 03. main 서버 클론 및 IP 주소 & Telnet 설정 (0) | 2016.03.10 |
Linux III - 01. 리눅스 메인 서버 설치 (0) | 2016.03.08 |