공통설정
GNS설정
R1#confi ter
R1(config)#int f0/1
R1(config-if)#shut
R1(config-if)#mac-add 1234.1234.1212
R1(config-if)#no shut
R1(config-if)#ip add dhcp
R1(config-if)#int f0/0
R1(config-if)#ip add 192.168.10.254 255.255.255.0
R1(config-if)#no shut
R1(config-if)#ip nat inside
R1(config-if)#int f0/1
R1(config-if)#ip nat outside
R1(config-if)#exit
R1(config)#access-list 10 permit 192.168.10.0 0.0.0.255
R1(config-std-nacl)#exit
R1(config)#ip nat inside source list 10 interface f0/1 overload (이거 list10보다 더 먼저 쓰면 오류남..)
R1(config-if)#ip route 0.0.0.0 0.0.0.0 f0/1 10.0.0.1
리눅스에서도 네트워크 설정
VMnet2으로 바꿔주고
[root@centos7 pub]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 ==> 이거 위치 모르면 locate ifcfg-ens33으로 찾자.
ens33이라는 NIC(Network Interface Controller)정보를 저장하고 있는 설정 파일
interface configuration = 리눅스의 네트워크 관리를 위한 인터페이스 구성 유틸리티
ifcfg-ens33 ==> ens33이라는 NIC(Network Interface Controller)정보를 저장하고 있는 설정 파일
TYPE=Ethernet
BOOTPROTO=static ==>고정IP할당을 위해 DHCP→Static으로 변경
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.10.100
GATEWAY=192.168.10.254
NETMASK=255.255.255.0
NETWORK=192.168.10.0
BROADCAST=192.168.10.255
DNS1=168.126.63.1
DNS2=8.8.8.8
:wq
[root@centos7 pub]# systemctl restart network ==>systemctl은 service(데몬)들을 관리하는 명령어
[root@centos7 temp]# ifconfig ==>inet 192.168.10.100 설정된것 확인.
[root@centos7 temp]# ping 168.126.63.1
==>안되면 걍 bridge로 바꿔주기..(이럼 ifcfg-ens33에가서 DHCP로 바꿔주고 ip 주소들에 다 # 주석처리해야함)
FTP 구현
RPM 으로 vsftpd 설치 확인, yum으로 설치하기.
rpm 은 Redhat Package Manager 의 약자로 패키지의 설치, 확인, 제거등의 관리를 하는 패키지 관리자를 말합니다.
리눅스 vsftpd는 Very Secure File Transfer Protocol Daemon의 약자로 FTP의 보안을 강조한 파일 전송 프로토콜입니다
[root@centos7 temp]# rpm -qa | grep vsftpd ==>패키지 설치되었는지 확인
[root@centos7 temp]# yum -y install vsftpd ==> -y 는 yes.
yum : RPM 기반의 시스템을 위한 자동 업데이터 겸 패키지 설치/제거 도구 - rpm의 의존성문제 해결
[root@centos7 temp]# systemctl start vsftpd.service ==>서버를 실행하겠다.
[root@centos7 temp]# systemctl enable vsftpd.service ==> 리눅스 부팅시 서비스 재시작 / 이거 안되면 방화벽에 걸린것.
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@centos7 temp]# vi /etc/vsftpd/vsftpd.conf
:set nu 해주고 넘버링 붙인다.
12 anonymous_enable=YES
16 local_enable=YES
19 write_enable=YES
23 local_umask=022
29 anon_upload_enable=YES
33 anon_mkdir_write_enable=YES
87 ftpd_banner=Welcome to blah FTP service.
:wq
[root@centos7 temp]# systemctl restart vsftpd.service
[root@centos7 temp]# ifconfig ==>확인
리눅스의 보안정책을 셀 리눅스라고 한다.
프로그램설치하려면 selinux에 걸린다. 그래서 해제해야함.
selinux 해제
"SELinux 간략 정리"
enforce(1), permissive(0), disable 세 가지 모드가 있으며
RHEL/CentOS 를 설치하면 default 로 enforce mode 로 동작하며
SELinux 의 rule 에 어긋나는 operation 은 거부된다.
현재 SELinux 의 동작 모드는 "sestatus" 명령어로 확인할 수 있다.
방법1)
[root@centos7 pub]# setenforce 0 ==>셀리눅스(리눅스 보안과 관련된 기능)를 해제한다. Enforcing(적용. 1) 되면 설치가 안된다.
setenforce: SELinux is disabled
[root@centos7 pub]# getenforce ==>확인
방법2)
[root@centos7 temp]# vi /etc/sysconfig/selinux ==> SELINUX=disabled 로 바꿔준다.
그리고 재부팅.(init 6)
[root@centos7 pub]# getenforce ==>확인
방화벽 해제
[root@centos7 heejae]# firewall-config ==>밑에처럼 둘다 바꿔주기 // 포트넘버별 서비스별로 방화벽 정책이 적용된다. // 런타임은 현재상태, 영구적은 재부팅해도 안바뀌게.
권한설정
[root@centos7 temp]# cd /var/ftp/
[root@centos7 ftp]# ls -l
합계 0
drwxr-xr-x. 2 root root 6 6월 10 2021 pub ==> 외부에서 접속하면 이게 보인다. 소유권이 root니까 소유권 바꾸자
[root@centos7 ftp]# chown ftp:ftp pub
[root@centos7 ftp]# ls -l
합계 0
drwxr-xr-x. 2 ftp ftp 6 6월 10 2021 pub
[root@centos7 ftp]# chown ftp:ftp pub
[root@centos7 ftp]# chmod 777 pub ==>현업에선 777하면안됨. 연습이니까 모든권한 주는것.
[root@centos7 ftp]# ls -l
합계 0
drwxrwxrwx. 2 ftp ftp 6 6월 10 2021 pub ==>바뀐거 확인
[root@centos7 ftp]# cd pub
[root@centos7 pub]# cat > test_ftp
this is test..
[root@centos7 ftp]# ls -l
합계 4
drwxrwxrwx. 2 ftp ftp 6 6월 10 2021 pub
-rw-r--r--. 1 root heejae 28 3월 30 16:33 test_ftp
Win702가서 네트워크와 FTP설정
HTTP구현
[root@centos7 heejae]# rpm -qa | grep httpd ==>rpm이 설치된 httpd를 찾아줘(Query(문의) 및 All(전부)) ==>앗 설치가 안되어있다.
ifconfig
셀리눅스, 방화벽 해제
[root@centos7 heejae]# setenforce 0 //FTP 설정하면서 해줬으니까 passs
[root@centos7 heejae]# firewall-config //밑에 둘다 바꿔주기
권한설정-이미 ftp설정할때 해줌
[root@centos7 html]# cd /var/ftp/
[root@centos7 ftp]# chown ftp:ftp pub //권한 바꿔주기
[root@centos7 ftp]# chmod 777 pub
[root@centos7 ftp]# ls -l
합계 4
drwxrwxrwx. 2 ftp ftp 92 3월 30 17:19 pub
Win702에서 파일 넣어주기
boa_valenti.mp4 랑 boa.jpg를 넣자
//안된다면 ? 재부팅해라.
[root@centos7 html]# cd /var/ftp/
[root@centos7 ftp]# cd pub
[root@centos7 pub]# ls -l
합계 13576
-rw------- 1 ftp ftp 21662 3월 31 16:23 boa.jpg
-rw------- 1 ftp ftp 13848936 3월 31 16:23 boa_valenti.mp4
-rw-r--r--. 1 root heejae 7 3월 30 16:39 test_ftp
HTML 넣기
[root@centos7 heejae]# cd /var/www
[root@centos7 www]# ls -l
합계 0
drwxr-xr-x 2 root root 6 1월 28 02:37 cgi-bin //755
drwxr-xr-x 2 root root 6 1월 28 02:37 html //755
[root@centos7 html]# pwd ==>확인
/var/www/html
[root@centos7 www]# cd html
[root@centos7 html]# vi index.html
<html>
<head>
<title>한국정보교육원</title>
</head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<p><span style="font-size:40pt;"><marquee style="left:">방가 방가 ^.^ 우리는 클라우트컴퓨팅 501호랍니다.~</marquee></span></p>
<p><img src="boa.jpg" width="851" height="229" border="0"></p>
<video oncontextmenu="return false;" id="myVideo" width="640" controls autoplay>
<source src="boa_valenti.mp4" type="video/mp4">
</video>
</body>
</html>
파일 옮기고 파일에 권한주기
[root@centos7 pub]# cp boa.jpg boa_valenti.mp4 /var/www/html/
[root@centos7 heejae]# cd /var/www
[root@centos7 www]# ls -l
합계 0
drwxr-xr-x 2 root root 6 1월 28 02:37 cgi-bin
drwxr-xr-x 2 root root 62 4월 3 15:06 html //author에 x가 있어야 접근이 가능하다.
[root@centos7 pub]# cd /var/www/html
[root@centos7 html]# ls -l
합계 13556
-rw------- 1 root heejae 21662 3월 31 16:27 boa.jpg
-rw------- 1 root heejae 13848936 3월 31 16:27 boa_valenti.mp4
-rw-r--r-- 1 root heejae 498 3월 31 15:59 index.html
[root@centos7 html]# chmod 755 boa.jpg
[root@centos7 html]# chmod 755 boa_valenti.mp4
//또는 그냥 [root@centos7 www]# chmod 755 *
아파치 환경설정 파일 확인 및 재시작
[root@centos7 www]# vi /etc/httpd/conf/httpd.conf ==>아파치의 환경설정 파일 (건드릴건 없다)
42 Listen 80 =>포트를 42번에서 정한다
119 DocumentRoot "/var/www/html" =>경로를 여기서 바꿀수있다
[root@centos7 html]# systemctl restart httpd
[root@centos7 www]# systemctl enable httpd.service
[root@centos7 html]# systemctl status httpd ==>아파치 상태확인.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since 금 2023-03-31 16:28:38 KST; 8s ago
//httpd 의 d는 데먼 = 리눅스의 프로그램(윈도우로 따지자면 프로그램이랑 같은것)
여기까지 하고
CentOS7에서 인터넷켜서
아파치 구축 성공!
DNS 구현
방화벽 ,셀리눅스 해제
[root@centos7 heejae]# firewall-config
CentOS7에서 FireFox열기
win702에서 크롬
[root@centos7 pub]# yum -y install bind bind-chroot ==>bind 패키지 설치. DNS 서비스에 필요한 패키지를 설치합니다. //conf 파일이 만들어진다.
root@centos7 pub]# vi /etc/named.conf
13 listen-on port 53 { any; }; ==> 127.0.0.1; 에서 any; 로 변경
21 allow-query { any; }; ==> localhost; 에서 any;로 변경
54에 놓고 esc 한다음 4yy 를 치기 (4줄 복사)
마지막줄에서 p
62 zone "kedu.edu" IN {
63 type master;
64 file "kedu.edu.db";
65 allow-update { none; };
66 };
우린 슬레이브가 없어서 none으로 쓴거임.
[root@centos7 pub]# named-checkconf =>아무것도 안나오면 오류 없는것.
[root@centos7 ~]# vi /var/named/kedu.edu.db ==> 아까 정의한 파일 생성
$TTL 3H ==>환경변수 TTL 이 3시간이다. TTL다음 스페이스바 2개 이상 눌러주기
@ SOA @ root. (2 1D 1H 1W 1H) ==> 교재 확인. ==>@는 자기 자신.(local host또는 27..?)
IN NS @ ==> IN을 기준으로 A레코드의 종류를 만들어주면된다. 왼쪽은 레코드 종류, NS가 자기자신인 @써주기.
IN A 192.168.10.100 ==> www. 안주고 그냥 kedu.edu 해도 열리게 해주기 위해 맨앞칸 비워주는것.
www IN A 192.168.10.100
ftp IN A 192.168.10.100
:wq ==> 얘는 오류검사기능이 없기때문에 오타 잘 확인하기
[root@centos7 ~]# systemctl restart named.service
[root@centos7 ~]# systemctl enable named.service
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@centos7 ~]# systemctl status named.service
● named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disabled)
Active: active (running) since 월 2023-04-03 16:57:26 KST; 18s ago
Main PID: 6585 (named)
CGroup: /system.slice/named.service
└─6585 /usr/sbin/named -u named -c /etc/named.conf
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './DNSKEY/IN': 2001:503:ba3e:...0#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './NS/IN': 2001:503:ba3e::2:30#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './DNSKEY/IN': 2001:dc3::35#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './NS/IN': 2001:dc3::35#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './DNSKEY/IN': 2001:7fe::53#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './NS/IN': 2001:7fe::53#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './DNSKEY/IN': 2001:500:9f::42#53
4월 04 02:10:57 centos7 named[6933]: network unreachable resolving './NS/IN': 2001:500:9f::42#53
//오류
[root@centos7 ~]# nslookup ==>구축
> server 192.168.10.100
Default server: 192.168.10.100
Address: 192.168.10.100#53
> www.kedu.edu
Server: 192.168.10.100
Address: 192.168.10.100#53
Name: www.kedu.edu
Address: 192.168.10.100
> ftp.kedu.edu
Server: 192.168.10.100
Address: 192.168.10.100#53
Name: ftp.kedu.edu
Address: 192.168.10.100
> kedu.edu
Server: 192.168.10.100
Address: 192.168.10.100#53
Name: kedu.edu
Address: 192.168.10.100
>
Win702가
이름 풀이 되는지 확인.
웹브라우저는 돼도 이건 되야함.
ftp> 로 ftp 에 연결이 됐다는 것을 알수있다.(현재 알드라이브의 오류로 알드라이브는 안됨..ㅣ;;;;)
오류해결
IPv4환경에서 bind를 구동할 때 아래와 같은 오류가 /var/log/massages에 쌓인다
위 메시지는 IPv6 기반의 통신을 하지 못해서 루트 서버로의 접근을 못해서 발생하는것으로 IPv4로만 동작하도록 설정하면 문제가 해결됩니다.
(출처: https://faq.hostway.co.kr/Linux_DNS/7618)
첫번째,
cd /etc/sysconfig
vi named
맨 마지막에
OPTIONS="-4" 넣기
두번째,
cd /etc
vi named.conf
// listen-on-v6 port 53 { ::1; }; ==>이 부분 주석처리
systemctl restart named.service
다시 알드라이브로 ftp.kedu.edu해주면 들어가진다
'네트워크 수업 > 리눅스' 카테고리의 다른 글
[리눅스] TELNET 23.04.05 (0) | 2023.04.05 |
---|---|
[리눅스] 텔넷 서버 구축.pdf 23.04.05 (0) | 2023.04.05 |
[리눅스] DNS 프로젝트관련(3) 23.04.03 (0) | 2023.04.03 |
[리눅스] 아파치 - 프로젝트관련(2) 23.03.31 (0) | 2023.03.31 |
[리눅스] Apache Web Server.pdf 23.03.31 (0) | 2023.03.31 |
댓글