码迷,mamicode.com
首页 > 其他好文 > 详细

19.ntp-chrony--PPTP ×××

时间:2019-08-02 22:51:18      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:which   安装   语法错误   manager   上网   mirrors   config   ***   ipc   

1.NTP

1.1安装ntp

yum -y install ntp
rpm -qa ntp

1.2官网

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/system_administrators_guide/

1.3配置

cp /etc/ntp.conf{,.ori}

[root@m02 ~]# vim /etc/ntp.conf
#nomodify:不允许客户端修改服务端时间 noquery不允许客户端查询服务端时间
#restrict default nomodify notrap nopeer noquery
restrict default nomodify
#允许哪些网段可以访问ntp服务器
#两个网段之间要两个空格,一个空格报语法错误
restrict 172.16.1.0/24 10.0.0.0/24
#将默认时间同步源注释改用可用源
#iburst意思是时间服务器连接不上,给服务器发送消息
server ntp1.aliyun.com iburst

[root@m02 ~]# systemctl stop chronyd.serveice

[root@m02 ~]# systemctl disable chronyd.serveice

1.4启动

#如果在ntp.conf中加上noquery,那么就不能执行ntpstat来查看时间同步状态了
systemctl start ntpd
ntpq -p 查看上级时间服务器状态
ntpstat 查看时间同步状态

1.5客户端验证

[root@m01 ~]# date -s 20190321
Thu Mar 21 00:00:00 CST 2019

[root@m01 ~]# ntpdate 10.0.0.62
20 Mar 19:11:54 ntpdate[1244]: step time server 10.0.0.62 offset -17298.841938 sec

[root@m01 ~]# date
Wed Mar 20 19:12:00 CST 2019

[root@m01 ~]#ntpdate -d 172.16.1.62 #debug 不会修改系统时间只是进行测试
20 Mar 19:20:38 ntpdate[1267]: ntpdate 4.2.6p5@1.2349-o Mon Feb 6 07:22:46 UTC 2017 (1)
Looking for host 10.0.0.62 and service ntp
host found : 10.0.0.62
transmit(10.0.0.62)
receive(10.0.0.62)
transmit(10.0.0.62)
receive(10.0.0.62)
transmit(10.0.0.62)
receive(10.0.0.62)
transmit(10.0.0.62)
receive(10.0.0.62)
server 10.0.0.62, port 123
stratum 3, precision -24, leap 00, trust 000
refid [10.0.0.62], delay 0.02576, dispersion 0.00000
transmitted 4, in filter 4
reference time: e03ca07a.56d6ab61 Wed, Mar 20 2019 19:20:26.339
originate timestamp: e03ca087.17c913f0 Wed, Mar 20 2019 19:20:39.092
transmit timestamp: e03ca087.1986c7f0 Wed, Mar 20 2019 19:20:39.099
filter delay: 0.02583 0.02576 0.02576 0.02583
0.00000 0.00000 0.00000 0.00000
filter offset: -0.00687 -0.00688 -0.00688 -0.00692
0.000000 0.000000 0.000000 0.000000
delay 0.02576, dispersion 0.00000
offset -0.006885

20 Mar 19:20:39 ntpdate[1267]: adjust time server 10.0.0.62 offset -0.006885 sec

2.chrony时间同步

chrony更好一些
yum install -y chrony

[root@m02 ~]# vim /etc/chrony.conf
server ntp1.aliyun.com iburst
##两个网段,两个空格隔开
allow 10.0.0.0/24 172.16.1.0/24
客户端验证

[root@m01 ~]# date -s 20190324
Sun Mar 24 00:00:00 CST 2019

[root@m01 ~]# ntpdate 10.0.0.62
20 Mar 19:30:48 ntpdate[1296]: step time server 10.0.0.62 offset -275354.367909 sec

[root@m01 ~]# date
Wed Mar 20 19:32:34 CST 2019

[root@m01 ~]#

3.PPTP ×××

3.1配置好epel源

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install pptpd

3.2配置

vim /etc/pptpd.conf
#localip 本机公网IP
#remoteip 分配给***客户端的地址,一般是内网网段地址
localip 10.0.0.62
remoteip 172.16.1.100-110
#分配内网网段注意点:
#1.避开内网服务器使用的或预备使用的IP
#2.想好有多少客户端,上限100人(IP)

sed -i ‘$a localip 10.0.0.62\nremoteip 172.16.1.100-110‘ /etc/pptpd.conf
#添加×××登陆用户
#vi /etc/ppp/chap-secrets
oldboy * 123456 *

/etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p

3.3重启服务

systemctl start pptpd.service

3.4查看日志

[root@m02 ~]# tail -30f /var/log/messages
Mar 24 00:38:14 oldboyedu-7 systemd: Started PoPToP Point to Point Tunneling Server.
Mar 24 00:38:14 oldboyedu-7 systemd: Starting PoPToP Point to Point Tunneling Server...
Mar 24 00:38:14 oldboyedu-7 pptpd[3533]: MGR: Maximum of 100 connections reduced to 11, not enough IP addresses given
Mar 24 00:38:14 oldboyedu-7 pptpd[3533]: MGR: Manager process started
Mar 24 00:38:14 oldboyedu-7 pptpd[3533]: MGR: Maximum of 11 connections available

3.5使用×××

技术图片
技术图片
技术图片
技术图片
技术图片
技术图片
技术图片

后台日志

[root@m02 ~]# tail -30f /var/log/messages
Mar 24 01:01:01 oldboyedu-7 systemd: Started Session 6 of user root.
Mar 24 01:01:01 oldboyedu-7 systemd: Starting Session 6 of user root.
Mar 24 01:02:27 oldboyedu-7 pptpd[3696]: CTRL: Client 10.0.0.1 control connection started
Mar 24 01:02:27 oldboyedu-7 pptpd[3696]: CTRL: Starting call (launching pppd, opening GRE)
Mar 24 01:02:27 oldboyedu-7 pppd[3697]: Plugin /usr/lib64/pptpd/pptpd-logwtmp.so loaded.
Mar 24 01:02:27 oldboyedu-7 pppd[3697]: pppd 2.4.5 started by root, uid 0
Mar 24 01:02:27 oldboyedu-7 pppd[3697]: Using interface ppp0
Mar 24 01:02:27 oldboyedu-7 pppd[3697]: Connect: ppp0 <--> /dev/pts/2
Mar 24 01:02:30 oldboyedu-7 pppd[3697]: peer from calling number 10.0.0.1 authorized
Mar 24 01:02:30 oldboyedu-7 kernel: PPP MPPE Compression module registered
Mar 24 01:02:30 oldboyedu-7 pppd[3697]: MPPE 128-bit stateless compression enabled
Mar 24 01:02:32 oldboyedu-7 pppd[3697]: found interface eth1 for proxy arp
Mar 24 01:02:32 oldboyedu-7 pppd[3697]: local IP address 10.0.0.62
Mar 24 01:02:32 oldboyedu-7 pppd[3697]: remote IP address 172.16.1.100
Mar 24 01:02:34 oldboyedu-7 kernel: e1000: eth0 NIC Link is Down
Mar 24 01:02:38 oldboyedu-7 kernel: e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
此时可以Ping通内网ip了

技术图片

连接上了发现无法上网了
因为网关指向了×××服务器

技术图片
技术图片
技术图片
技术图片

设置之后保存,***断开重新链接,就发现可以上网了
下面可查看通过***设置的本机IP

技术图片
技术图片
技术图片
技术图片

链接了***后,就可以连接到172.16.1.61了
对172.16.1.61做个说明,这个虚拟机只有内网Ip,配置如下,这种没有配置网关,与本地电脑是不能网络互通的,由于连接了***,就可通过***的内核转发功能,进行与其网络互通。
这里我在操作的时候,修改了配合转发功能,配置成了1,但是没有让其生效,所以在本地电脑ping不通172.16.1.61,后来让内核转发功能配置生效后net.ipv4.ip_forward = 1,就可成功ping通了
×××服务端ifconfig查看

技术图片

3.6或者通过vmware的端口映射功能

技术图片

配置好后,

[d:~]$ ipconfig /all
无线局域网适配器 WLAN:

连接特定的 DNS 后缀 . . . . . . . :
描述. . . . . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8260
物理地址. . . . . . . . . . . . . : 14-AB-C5-6D-4C-46
DHCP 已启用 . . . . . . . . . . . : 是
自动配置已启用. . . . . . . . . . : 是
本地链接 IPv6 地址. . . . . . . . : fe80::cdc2:cbdf:97e6:5e26%19(首选)
IPv4 地址 . . . . . . . . . . . . : 192.168.1.102(首选)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
获得租约的时间 . . . . . . . . . : 2019年3月21日 星期四 10:22:09
租约过期的时间 . . . . . . . . . : 2019年3月21日 星期四 15:21:53
默认网关. . . . . . . . . . . . . : 192.168.1.1
DHCP 服务器 . . . . . . . . . . . : 192.168.1.1
DHCPv6 IAID . . . . . . . . . . . : 102017989
DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-24-24-95-48-14-AB-C5-6D-4C-46
DNS 服务器 . . . . . . . . . . . : 202.96.209.5
202.96.209.133
TCPIP 上的 NetBIOS . . . . . . . : 已启用

可以通过本地的9000端口连接到61的虚拟机

[d:~]$ ssh 192.168.1.102 9000

Connecting to 192.168.1.102:9000...
Connection established.
To escape to local shell, press Ctrl+Alt+].

WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Thu Mar 21 14:08:11 2019

[root@m01 ~]#
在同一个局域网的其他笔记本,也可通过本地电脑的9000端口连接到该虚拟机了

3.7×××企业案例一:用户日志审计

cat /etc/ppp/ip-up用户连接成功之后执行
…………
echo "$PEERNAME 分配IP: $5 登录IP: $6 登录时间: date -d today +%F_%T" >> /var/log/pptpd.log
#只加了上面echo一行
exit 0

cat /etc/ppp/ip-down用户断开时执行
…………
echo "$PEERNAME 下线IP: $6 下线时间: date -d today +%F_%T" >> /var/log/pptpd.log
exit 0

man pppd
搜索peername
搜索ip-up查看$5,$6含义
/etc/ppp/ip-up
A program or script which is executed when the link is available for sending and receiving IP packets (that is, IPCP has come up). It is executed with
the parameters

interface-name tty-device speed local-IP-address remote-IP-address ipparam

/etc/ppp/ip-down
A program or script which is executed when the link is no longer available for sending and receiving IP packets. This script can be used for undoing
the effects of the /etc/ppp/ip-up and /etc/ppp/ip-pre-up scripts. It is invoked in the same manner and with the same parameters as the ip-up script.

[root@m02 ppp]# systemctl restart pptpd.service

本地点解连接-断开***

[root@m02 ppp]# cat /var/log/pptpd.log
oldboy 分配IP: 172.16.1.100 登录IP: 10.0.0.1 登录时间: 2019-03-21_14:32:50
oldboy 下线IP: 10.0.0.1 下线时间: 2019-03-21_14:33:15

3.8企业案例二

子公司内部只有一台服务器,只有内网地址,没有公网IP,但可以访问公网。而且所有网络设备都归总公司管辖,子公司没有合理理由无法申请。公司内部也有×××服务器,但×××帐号也需要申请。在此种场景,如何让外部人员访问内网服务器?

解答:在外部有公网IP的机器上部署***服务,内网服务器拨号登录***,外部人员也登录***。只要***服务器不禁止客户端互联,外部用户就能访问内部服务器。

技术图片

建议使用Open×××,比较稳定
Open×××的参数
client-to-client允许多个××× client互相通信
pptp服务器上不开启防火墙,客户端能够互相访问,当然需要注意windows客户端的防火墙是否开放。

19.ntp-chrony--PPTP ×××

标签:which   安装   语法错误   manager   上网   mirrors   config   ***   ipc   

原文地址:https://blog.51cto.com/10983441/2426074

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!