The building of Linux learning Environment Ftp+dhcp+dns

Source: Internet
Author: User
Tags rsync

A. Hardware environment:

1. Install Virtual machine VMware 10.

Create a new virtual machine, name the experiment Master, remove unnecessary devices, set the network card mode to Vnet1, and put the CentOS CD in, install the centos6.5, select the mini-install + Dev tool + server platform development.

2. Setup after the installation is complete:

1) Install the necessary tools:

cd/etc/yum.repos.d/

RM-RF./*

Vi/etc/yum.repos.d/centos.repo

[Local]name=cdrootbaseurl=file:///mntenabled=1gpgcheck=0

: Wq

Mount/dev/cdrom/mnt

RPM--import/etc/pki/rpm-gpg/*

Yum-y install wget lftp vim bind-utils man ELinks # #安装常用的软件包

2) Disable firewall and SELinux:

Chkconfig iptables off

Chkconfig Network on

Vim/etc/selinux/config

Selinux=disabled

: Wq

History-c

Poweroff


3) Take a snapshot of the virtual machine and name it clear, clone a virtual machine and name it "Ftp+dns+dhcp".


Two. Configure the FTP+DNS+DHCP virtual machine:

1) Edit the cloned virtual machine, set up the dual network card: eth0 (Vnet1 only), eth1 (bridge)

On the real machine, set the IP address for Vnet1:192.168.100.1 (vmnet1 in Network Settings), DNS: 192.168.100.100


2). Configure the IP address and the underlying settings:

[Email protected] ~]# Vi/etc/udev/rules.d/70-persistent-net.rules # #删除eth0的行, change eth1 to Eth0,eth2 to eth1

[[Email protected] ~]# IP a # #查看MAC

[[email protected] ~]# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 # #编辑设置如下, MAC address must be consistent with eth1

Device=eth0hwaddr=00:0c:29:0c:b9:49type=ethernetonboot=yesnm_controlled=nobootproto=staticipaddr= 192.168.100.100netmask=255.255.255.0dns1=192.168.100.100

: Wq

[[email protected] ~]# vi/etc/sysconfig/network-scripts/ifcfg-eth1 # #新建文件, enter the following to ensure that the MAC address must be the same as eth2

Device=eth1hwaddr=00:0c:29:0c:b9:53type=ethernetonboot=yesnm_controlled=nobootproto=dhcp

: Wq

[Email protected] ~]# vi/etc/sysconfig/network

hostname=ns.linuxyy.cn

: Wq


Reboot # #重启

[Email protected] named]# vi/etc/hosts

192.168.100.100 NS ns.linuxyy.cn

: Wq


3) Configure DHCP: Note If the real machine is a Windows environment, use the command "Services.msc" to turn off the DHCP service at the beginning of the VM

Mount/dev/cdrom/mnt

Yum-y Install DHCP vsftpd bind bind-chroot

[Email protected] ~]# vim/etc/dhcp/dhcpd.conf

Option Domain-name "linuxyy.cn"; option Domain-name-servers 192.168.100.100;default-lease-time 600;max-lease-time  7200;log-facility local7;subnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.150 192.168.100.250;  Option routers 192.168.100.100;  Next-server 192.168.100.100; FileName "pxelinux.0";}

: Wq

Vi/etc/sysconfig/dhcpd

Dhcpdargs=eth0

: Wq

/ETC/INIT.D/DHCPD restart

Chkconfig DHCPD on

NETSTAT-UTPLN |grep 67


4) Configure VSFTPD: Configuration file using default

/ETC/INIT.D/VSFTPD start

Chkconfig vsftpd on

Mkdir/var/ftp/tools

Cd/var/ftp/tools

Uploading common software packages

LS # #验证是否下载, if it has been downloaded to the real machine can be uploaded using Xshell

chmod 755/var/ftp/tools # #注意以后有什么新软件也可以下载到这个目录中, under Network Resource command "wget-p/var/ftp/tools resource URL"

Since CentOS has DVD1 and DVD2 two ISO images, use the following command to provide the client with a nearly complete Yum Source:

Mkdir/var/ftp/centos6

MOUNT/DEV/CDROM/MNT # #放入dvd -1.iso

rsync-av/mnt//var/ftp/centos6/

umount/mnt/

MOUNT/DEV/CDROM/MNT # #放入dvd -2.iso

rsync-av/mnt//var/ftp/centos6/

Access on the real machine:

FTP://192.168.100.100 # #测试是否能访问如果不能访问请检查: If the IP address of the virtual Vnet1 network card is set, can ping pass.


5) Configure DNS:


[Email protected] ~]# cd/var/named/chroot/etc/

[Email protected] etc]# vim named.conf

Options {directory "/var/named";}; Zone "linuxyy.cn." In {type master;file "Linuxyy.cn.zone";}; Zone "100.168.192.in-addr.arpa" in {type Master;file "192.168.100.arpa";};

: Wq

[Email protected] etc]# CD. /var/named/

[Email protected] named]# pwd

/var/named/chroot/var/named

[Email protected] named]# vim Linuxyy.cn.zone

$TTL  86400@    IN   SOA  linuxyy.cn.     root.linuxyy.cn.  (          20170630           1h          2m           3W           1D) @    in   ns     ns.linuxyy.cn.mail  in   mx 10  mail.linuxyy.cn.@    in   a       192.168.100.100mail IN   A       192.168.100.100ns   IN   A       192.168.100.100ftp  in   a      192.168.100.100ntp   in  &nbsP cname  nswww  in   a      192.168.100.150

: Wq


[Email protected] named]# vim 192.168.100.arpa

$TTL 86400@ in SOA linuxyy.cn. root.linuxyy.cn. (20170630 1H 2M 3W 1D) @ in NS Ns.linuxyy . cn.100 in ptr ns.linuxyy.cn.100 in ptr ntp.linuxyy.cn.100 in ptr ftp.linuxyy.cn.150 in PTR www.li nuxyy.cn.

: Wq

[Email protected] named]# chown named:named linuxyy.cn.zone 192.168.100.arpa.. /.. /etc/named.conf

[Email protected] named]# named-checkconf. /.. /etc/named.conf

[Email protected] named]# Named-checkzone linuxyy.cn.zone 192.168.100.arpa

Zone linuxyy.cn.zone/in:loaded Serial 20150630

Ok

[Email protected] named]#/etc/init.d/named restart

[Email protected] named]# chkconfig named on

[Email protected] named]# NETSTAT-UTPLN |grep 53

[email protected] named]# nslookup # #测试dns

> Server 192.168.100.100

Default server:192.168.100.100

address:192.168.100.100#53

> ns.linuxyy.cn

Server:192.168.100.100

Address:192.168.100.100#53


Name:ns.linuxyy.cn

address:192.168.100.100

> www.linuxyy.cn

Server:192.168.100.100

Address:192.168.100.100#53


Name:www.linuxyy.cn

address:192.168.100.150

> Ftp.ln

Server:192.168.100.100

Address:192.168.100.100#53


Name:ftp.linuxyy.cn

address:192.168.100.100

> Exit


[Email protected] named]#

5) Open Snat sharing Internet:

[Email protected] ~]# iptables-t nat-i postrouting-s 192.168.100.0/24-o eth1-j Masquerade

[Email protected] ~]#/etc/init.d/iptables Save

[Email protected] ~]# sed-i '/ip_forward/s/0/1/g '/etc/sysctl.conf # #开启路由功能

[Email protected] ~]# sysctl-p

Summarize:

Configure DHCP to assign IP addresses to future experimental virtual machines, VSFTPD provides resource downloads, and DNS provides name resolution.

Do a snapshot when everything is OK.

In the future if you need to use a virtual machine, using a master clone can be cloned after the NIC to Eth0,dns set to 192.168.100.100 and other basic settings (including/etc/sysconfig/network in the host name,/etc/hosts, etc.).

Clone 8 virtual machines:

Ctos-1:192.168.100.150

Ctos-2:192.168.100.151

Ctos-3:192.168.100.152

Ctos-4:192.168.100.153

Ctos-5:192.168.100.154

Ctos-6:192.168.100.155

Ctos-7:192.168.100.156

Ctos-8:192.168.100.157

Setup steps:

1. Modify eth1== "eth0

2. Modification of yum--

Vi/etc/yum.repos.d/centos.repo

[Local]

Name=local

Baseurl=ftp://192.168.100.100/centos6

Enabled=1

Gpgcheck=0

: Wq

Reboot

History-c

>.bash_history

3.xshell Connection: Terminal modified character UTF-8, appearance setting 16 size font, color scheme.

Poweroff

4. Set a snapshot for Ctos-1-"clear


When copying a virtual machine, select: I move the VM



This article is from the "11628205" blog, please be sure to keep this source http://11638205.blog.51cto.com/11628205/1981574

The building of Linux learning Environment Ftp+dhcp+dns

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.