리눅스 [ DNS ] Web, FTP Server 실습
시나리오
Server A : Web server
Server B : FTP server, DNS server
소프트웨어 설치
dnf -y install httpd vsftpd bind
먼저 관련 소프트웨어들을 설치 - httpd,vsftpd,bind(namd)
방화벽 열어주기
firewall-cmd --add-service={http,https,dns,ftp} --permanent && firewall-cmd --reload
firewall-cmd --list-all
HTTP (Server A)
설정파일은 '/var/www/html/http.conf'에 존재한다.
간단하게 실습만할것이므로 대문페이지만
/var/www/html/index.html 생성 = 대문 페이지
내용은 더보기란 참조
<Html>
<head>
<title>
Registration Page
</title>
</head>
<body bgcolor="Lightskyblue">
<br>
<br>
<form>
<label> Firstname </label>
<input type="text" name="firstname" size="15"/> <br> <br>
<label> Middlename: </label>
<input type="text" name="middlename" size="15"/> <br> <br>
<label> Lastname: </label>
<input type="text" name="lastname" size="15"/> <br> <br>
<label>
Course :
</label>
<select>
<option value="Course">Course</option>
<option value="BCA">BCA</option>
<option value="BBA">BBA</option>
<option value="B.Tech">B.Tech</option>
<option value="MBA">MBA</option>
<option value="MCA">MCA</option>
<option value="M.Tech">M.Tech</option>
</select>
<br>
<br>
<label>
Gender :
</label><br>
<input type="radio" name="male"/> Male <br>
<input type="radio" name="female"/> Female <br>
<input type="radio" name="other"/> Other
<br>
<br>
<label>
Phone :
</label>
<input type="text" name="country code" value="+91" size="2"/>
<input type="text" name="phone" size="10"/> <br> <br>
Address
<br>
<textarea cols="80" rows="5" value="address">
</textarea>
<br> <br>
Email:
<input type="email" id="email" name="email"/> <br>
<br> <br>
Password:
<input type="Password" id="pass" name="pass"> <br>
<br> <br>
Re-type password:
<input type="Password" id="repass" name="repass"> <br> <br>
<input type="button" value="Submit"/>
</form>
</body>
</html>
출처 : https://www.javatpoint.com/html-registration-form
HTML Registration Form - javatpoint
HTML Registration Form with html tutorial, tags, anchor, img, div, entity, textarea, marquee, p tag, heading tag, h1, h2, table, formatting, attribute, elements, ol, ul, Input Types, block element tag, inline element tag, html tags, phrase tag, head, body,
www.javatpoint.com
systemctl --now enable httpd
systemctl status httpd
systemctl --now enable httpd 켜주는 동시에 재시작시 자동으로 켜지게 설정.
systemctl status httpd로 확인
FTP (Server B)
/etc/vsftpd/vsftpd.conf < FTP 설정파일
banner_file=/var/ftp/welcom.msg < 맨윗줄에 내용을 추가해준다.
이후 적혀있는 /var/ftp/welcom.msg에 배너로 설정할 내용 추가
이런식으로 ftp서버에 접속할때 보여주는 메세지를 추가하는것이다.
systemctl --now enable vsftpd
systemctl status vsftpd
DNS (Server B)
이제 DNS설정을 통해 정방향 DNS와 역방향 DNS를 만들어 주려고 한다.
/etc/named.conf <- 설정에 들어가서
11, 12, 19 행을 변경해준다 (any none any)
그후 맨아래쪽을 보면 include 함수로 /etc/named.rfc1912.zones 파일을 포함해주는것을볼수있음.
이 파일로 DB를 관리한다.
rfc1912.zones를 수정(내용추가)해주자.
양식에 맞춰 내용을 추가해준다
zone "s3yfri3d.com" IN {
type master;
file "s3yfri3d.com.db";
allow-update { none; };
};
zone "s3yfri3d.com" IN { //IN = internet
type master; //master,slave,hint 인자값 가능
file "s3yfri3d.com.db"; // file "포워딩존파일" = DNS DB파일.만들어야함
allow-update { none; }; // 2차 네임서버의 주소 or 생략시 none
};
*file부분에 db파일은"/var/named/" 하위에 포워딩존파일을 만들어준다.
이후 named-checkconf을 이용해 문법에 이상이 있는지 없는지 확인해주고
이후 포워딩존 파일을 생성해줘야한다 .(s3yfri3d.com.db)
$TTL 3H
@ -> 도메인 그 자체( 해당 존 파일의 도메인 )
SOA(Start Of Authority) -> 권한 부여 시작
@ 네임 서버의 도메인
이메일 주소(관리자) rname.invalid. -> 계정.도메인 형태로 입력
root. -> 위 과정을 생략한것
2 - Serial(일련번호, DNS 갱신 시 증가하는 숫자, YYYYMMDDNN 형식 2023082102
1D - Refresh(보조 네임 서버가 존재할 경우 어느 주기로 주 네임 서버에 접근을 요청할 것인가)
1H - Retry(주 네임 서버 접근 실패 시 재 접속 간격)
1W - Expire(주 네임 서버 접근 실패 시 만기일)
3H - Minimum(SOA 영역의 TTL, 보조 TTL)
IN - 클래스(Internet)
NS - 레코드(Name Server)
@ - 도메인
IN - 클래스(Internet)
A - 레코드(도메인과 IP의 매칭을 주선하는 레코드)
밑에서부터는 호스트, 서브도메인 정보 입력
www IN A 192.168.111.100
ftp IN A 192.168.111.200
뼈대는 named.empty를 참고하고, 권한설정(chown)을 root.named로 해주는것이 보안설정에 좋다.
named-checkzone s3yfri3d.com /var/named/s3yfri3d.com.db
를 이용해 문법이 이상이 있는지 확인해주고,
서비스를 켜준다.
마무리
Server A (확인 및 테스트)
다시 A로 돌아와서 , 확인을 위해 DNS서버주소를 바꿔준다
vi /etc/resolv.conf
resolv.conf 설정 후
nslookup 명령어를 이용하여
DNS 서버가 잘 적용이 됬는지 확인
이렇게 설정이 됬다면,
Server A(resolv.conf를 수정한) 에서 파이어폭스를 키고 www.s3yfri3d.com 등을 입력하면
HTTP는 정상적으로 작동이 되는것을 볼 수 있고
FTP는 Filezilla 등을 이용해 ftp.s3yfri3d.com 등으로 이용할 수 있는것을 확인할 수 있다.