NFS Services and DHCP services explained

NFS server Overview

 

NFS, Network File System is short for that network file system. Network File System FreeBSD is a supported file system, also known as NFS; NFS allows a system to share directories and files with others on the network.

 

Mode: C / S Mode

port:

Net File System NFS is short for Network File System .NFS that is usually running on port 2049.

 

NFS deployment

 

Since before using the NFS file sharing service, you need to use the RPC (Remote Procedure Call, Remote Procedure Call) service sends information to the client NFS server's IP address and port number. Therefore, before you start the NFS service, incidentally, also you need to restart

And enable rpcbind service program.

 

Step One: Download

[root@ken ~]# yum install rpcbind nfs-utils -y

 

Step 2: Edit the configuration file

[root@ken ~]# cat /etc/exports
/ken 172.20.10.0/28(rw)

/ Ken 172.20.10.7 (rw) # ip to a specific share, rw means permission

/ Data * (rw) # ip share to all

/ Data 172.20.10.0/28(rw) # 28 out of the shared network represented by the mask

/ Data 172.20.10.0/28(rw) 192.168.64.0/24(rw) # plurality of networks

Note: * indicates the segment is open to all privileges

 

nfs can also share multiple directories

/ ken 192.168.64.5 (rw)
/ test 192.168.64.7 (rw)

 

 

The third step: Change owner

[root@ken ~]# chown -R nfsnobody:nfsnobody /ken

 

Step Four: Start nfs

[root@ken ~]# systemctl restart rpcbind
[root@ken ~]# systemctl restart nfs

 

Step five: Use the client mount

The client will need to download nfs-utils

Copy the code
[host1 the root @ ~] # yum the install NFS-utils -Y 
[host1 the root @ ~] # # See the showmount -e 172.20.10.6 share the Export List for 172.20.10.6: / Ken 172.20.10.0/28 [host1 the root @ ~] # mkdir / test # create the mount directory [root @ host1 ~] # mount -t nfs 172.20.10.6:/ken / test # mount [root @ host1 ~] # mkdir / test / ken # create a test file
Copy the code

 

 Overview of DHCP Services

 

DHCP Service Overview:

Name: DHCP - Dynamic Host Configuration Protocol Dynamic Host Configuration Protocol

Function: DHCP (Dynamic Host Configuration Protocol, Dynamic Host Configuration Protocol) is a local area network protocol, UDP protocol work, the main purposes:

To the internal network or Internet service provider automatically assigns an IP address, host name, DNS servers, domain name

 

Features: C / S Mode

Automatically assigns IP addresses to facilitate management

DHCP not simultaneously lease the same IP address to two hosts;

DHCP Administrators can constrain a specific computer to use a specific IP address;

Each DHCP scope can set many options;

The client does not need to re-set the IP address when you move between different subnets. Obtain an IP address automatically each time on it.

 

DHCP disadvantages:

When there are multiple servers on the network, a DHCP server can not find other servers have been rented out the IP address;

DHCP server across a router can not communicate with the client, unless the BOOTP protocol router allows forwarding.

port:

DHCP service uses: Port 67 (bootps) 68 (bootpc).

Example: View

# vim /etc/services

 

DHCP protocol developed by bootp protocol comes, is an enhanced version of BOOTP, bootps on behalf of the server port, bootpc behalf of the client port

bootp protocol: Bootstrap Protocol (BOOTP). It allows the diskless workstation to obtain an IP address from a central server, assign dynamic IP addresses to the diskless workstation LAN does not require each user to set a static IP address.

 

DHCP service operating principle:

 

Operating principles, frequently asked interview, we should all pay attention to the next!

 

DHCP Client discovery phase:

DHCP client process locate a DHCP server, DHCP client sends corresponding to the Discovery, because the DHCP Server corresponding to the DHCP client is unknown, the Discovery DHCP client sends a DHCP packet is a broadcast packet, the source address of 0.0.0.0 the destination address is 255.255.255.255. All supports TCP / IP host will receive the DHCP Discovery packets on the network, but only DHCP Server responds to the message.

Note: the client DHCP DISCOVER performed, if no DHCP server responds to the request of the client, the client using a random network 169.254.0.0/16 IP address configuration in a local address.

169.254.0.0/16 is automatic private IP addressing windows range, i.e. when it can not obtain an IP address via DHCP, the system automatically assigns the IP addresses.

 

 

DHCP Server provides stages:

DHCP Server provisioning phase, namely the Discovery DHCP Server DHCP response issued by the DHCP Offer stage, i.e., a DHCP server as an IP address. In the network received DHCPdiscover find the DHCP server will respond to information, which is assigned to the selection of a DHCP client from the IP address has not been rented, the sending IP address that contains a DHCPoffer rental and other settings to DHCP client provides information

DHCP Client confirmation phase:

The DHCP client selects an IP address to a DHCP server provides. If you have more than one DHCP server to DHCP clients sent DHCPoffer provide information, the DHCP client will only accept DHCPoffer first received information, then broadcast it to answer a DHCPrequest request information, which contains information it selected DHCP server IP address of the requested content. The reason for the answer in a broadcast manner, in order to inform all DHCP server, he will choose the IP address of a DHCP server provided by

 

DHCP Server validation phase:

 

The DHCP server acknowledges the IP address of the offer. When the DHCP server receives a DHCP client to answer DHCPrequest request information, it sends a Pianxiang DHCP client contains the IP address and other settings it offers the DHCPack confirmation message telling DHCP client can use an IP address that it provides . Then they put their DHCP client TCP / IP protocol and NIC teaming, in addition, in addition to the DHCP client selected server, other DHCP server will recover the IP address has been provided

 

DHCP Client log back into the network:

 

When the DHCP Client log back in, you do not need to send DHCP discover discovery information, but rather sent directly DHCP request contains the previous assigned IP address request information. When the DHCP server receives this information, it will try to get DHCP client continues to use the original IP address, and answer a DHCP ack confirmation. If this IP address can not be allocated to the original DHCP client to use (so than the IP address has been assigned to other clients use DHCP), the DHCP server to the DHCP client to answer a DHCP nack deny information. When the original DHCP client receives this DHCP nack denied the information, it must resend DHCP discover discovery information to request a new IP address.

DHCP Client lease renewal:

 

DHCP to obtain an IP address has a lease after the lease expires, DHCP Server will recover this IP address, so if DHCP Client If you want to continue using the IP address, you must update the lease. Update way is, when the current lease half after deadlines have passed, DHCP Client DHCP Renew message will be sent to renew the lease.

 

 

Deploy DHCP Service

 

lab environment:

My virtual machine to use bridged mode is feasible? No, because you're likely to have LAN DHCP server, so it is hard to let your client is to obtain an IP address from your DHCP server.

In addition, it may cause the company LAN access to other machines because the IP address on your DHCP server, not on the net. Only host mode can be selected or custom mode.

 

 

I use two virtual machines only the host mode

Server define a static IP (xshell connectable)

DHCP client is set to automatically obtain (to restart the network card fails, wait for DHCP server configuration is complete and then restart the card!)

 

Turn off the virtual machine host mode only comes with DHCP

 

Server-side operations

 

Step 1: Install dhcp

[root@ken ~]# yum install dhcp -y

 

Step Two: View Profile

[root@ken ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#

 

The third step: Import sample files

[root@ken ~]# cat /usr/share/doc/dhcp*/dhcpd.conf.example >> /etc/dhcp/dhcpd.conf

 

Step Four: Edit the configuration file

 
[root@ken ~]# cat /etc/dhcp/dhcpd.conf
subnet 192.168.182.0 netmask 255.255.255.0 {       #指定网段,需要和掩码保持一致
  range 192.168.181.10 192.168.182.20;                     #指定IP池    
  option domain-name-servers ns1.internal.example.org;  #指定DNS地址
  option domain-name "internal.example.org";         #指定域       
  option routers 192.168.182.1;                           #指定网关default-lease-time 600;                             #指定默认租约时间
  max-lease-time 7200;                                 #指定最大租约时间
}

 

第五步:重启DHCP服务

[root@ken ~]# systemctl restart dhcpd

 

客户端操作

 

第六步:修改客户端网络配置文件为dhcp

 

第七步:重启客户端网络

[root@ken ~]# systemctl restart network

 

第八步:查看获取到的IP

 

DHCP分配固定IP地址

 

在DHCP协议中有个术语是“预约”,它用来确保局域网中特定的设备总是获取到固定的IP地址。换句话说,就是dhcpd服务程序会把某个IP地址私藏下来,只将其用于相匹配的特定设备。

要想把某个IP地址与某台主机进行绑定,就需要用到这台主机的MAC地址。MAC地址是网卡上面的一串独立的标识符,具备唯一性,因此不会存在冲突的情况,

 

查看MAC地址

 

 

使用格式

 

host 服务端主机名称 {        
  hardware ethernet 该主机的MAC地址;  
  fixed-address 欲指定的IP地址;    
}

 

如果不方便查看主机的MAC地址,该怎么办呢?比如,要给老板使用的主机绑定IP地址,总不能随便就去查看老板的主机信息吧。针对这种情况,我们首先启动dhcpd服务程序,为老板的主机分配一个IP地址,这样就会在DHCP服务器本地的日志文件中保存这次的IP地址分配记录。然后查看日志文件,就可以获悉主机的MAC地址了

 

分配固定IP部署实践

 

第一步:编辑dhcp配置文件

host后面跟的主机名是DHCP服务器端的主机名

 

 

第二步:重启dhcp服务

[root@ken1 ~]# systemctl restart dhcpd

 

第三步:如果您刚刚为这台主机分配了IP地址,则它的IP地址租约时间还没有到期,因此不会立即换成新绑定的IP地址。要想立即查看绑定效果,则需要重启一下客户端的网络服务

[root@ken2 ~]# systemctl restart network

 

第四步:查看IP

 

 

scp用法

 

 

scp可以实现远程主机之间的文件复制

scp使用ssh协议,所有想要免密进行复制,需要发送秘钥给相应的节点

 

scp使用格式:

scp [user@]host1:]file1 … [[user@]host2:]file2

 

常用选项:

-r: 复制目录时使用

-P:大写的P指定端口

 

scp发送主机文件到远程节点

 

[root@ken ~]# ls
anaconda-ks.cfg  ken  ken1  test
[root@ken ~]# scp /root/test 192.168.64.5:/tmp
test                                                                                                100%    0     0.0KB/s   00:00

 

scp拉取远程节点文件到本地

 

[root@ken ~]# scp  192.168.64.7:/root/test /tmp/
[email protected]'s password: 
test                                                                                                100%    0     0.0KB/s   00:00

 

scp复制本地目录到远程节点

 

[root@ken ~]# scp ken 192.168.64.7:/root/
[email protected]'s password: 
ken: not a regular file
[root@ken ~]# scp -r ken 192.168.64.7:/root/    #需要加上选项-r
[email protected]'s password: 

 

scp远程节点目录到本机

 

[root@ken ~]# scp -r [email protected]:/tmp/test /tmp/
[email protected]'s password: 
[root@ken ~]# ls /tmp
test

Guess you like

Origin www.cnblogs.com/it-peng/p/11404408.html
Recommended