防火墙学习随笔
来源:互联网 发布:重点软件企业 编辑:程序博客网 时间:2024/06/10 00:42
应用方法:
#pkill 正在运行的程序名
举例:
[root@localhost beinan]# pgrep -l gaim
2979 gaim
[root@localhost beinan]# pkill gaim
也就是说:
kill 对应的是 PID
pkill 对应的是COMMAND
1. cd /etc/vsftpd 进入ftp配置文件目录
2. vi vsftpd.conf编辑此文件,找到#chroot_list_enable=YES,删除前面的那个#号,表示开启此限制功能
找到chroot_list_file:chroot_list_file=/etc/vsftpd/chroot_list
3. 编辑chroot_list文件,加入你要限制的用户名,一行一个用户.
如果更新了vsftpd.conf,一定要重启ftp,命令如下:
[root@linuxsir001 root]# /etc/init.d/vsftpd restart
关闭 vsftpd: [ 确定 ]
为 vsftpd 启动 vsftpd: [ 确定 ]
- ⑴、命令配置法:ifconfig和ip
- Ifconfig ethx:x IP/netmask
- ip addr add IP dev ethx label ethX:X
- 利用命令配置的只是暂时的IP地址,如果重启网络服务和系统都会失效的。
- ⑵、配置文件配置法:
- 修改/etc/sysconfig/network-scripts/ifcfg-ethx:x
- DEVICE=ethx:x
- BOOTPROTO=static
- IPIPADDR= IP地址
- NETMASK= 子网掩码
- GATEWAY= 网关
- ONBOOT=YES 是否开机启用
- HWADDR=...... MAC
- 非主要地址不能用DHCP服务获得,必须为静止的。
八、 DNS配置文件:
- ⑴、DNS配置文件位置:/etc/resolv.conf
- ⑵、DNS配置格式:
- nameserver DNS_IP1
- nameserver DNS_IP2
- 指定本地解析:
- /etc/hosts下添加
- 目标主机IP 主机名
- fg:172.16.36.1 www.chris.com
- DNS解析过程-->/etc/hosts-->DNS 服务器
九、主机名配置文件:
- ⑴、配置文件位置: /etc/sysconfig/network
- ⑵、配置格式:
- HOSTNAME=名称
- NETWORKING={yes|no}:是否开启网络功能
# watch ntpq -p
Every 2.0s: ntpq -p Sat Jul 7 00:41:45 2007
remote refid st t when poll reach delay offset jitter
===========================================================
+193.60.199.75 193.62.22.98 2 u 52 64 377 8.578 10.203 289.032
*mozart.musicbox 192.5.41.41 2 u 54 64 377 19.301 -60.218 292.411
现在我就来解释一下其中的含义
remote: 它指的就是本地机器所连接的远程NTP服务器
refid: 它指的是给远程服务器(e.g. 193.60.199.75)提供时间同步的服务器
st: 远程服务器的层级别(stratum). 由于NTP是层型结构,有顶端的服务器,多层的Relay Server再到客户端. 所以服务器从高到低级别可以设定为1-16. 为了减缓负荷和网络堵塞,原则上应该避免直接连接到级别为1的服务器的.
t: 这个.....我也不知道啥意思^_^
when: 我个人把它理解为一个计时器用来告诉我们还有多久本地机器就需要和远程服务器进行一次时间同步
poll: 本地机和远程服务器多少时间进行一次同步(单位为秒). 在一开始运行NTP的时候这个poll值会比较小,那样和服务器同步的频率也就增加了,可以尽快调整到正确的时间范围.之后poll值会逐渐增大,同步的频率也就会相应减小
reach: 这是一个八进制值,用来测试能否和服务器连接.每成功连接一次它的值就会增加
delay: 从本地机发送同步要求到服务器的round trip time
offset: 这是个最关键的值, 它告诉了我们本地机和服务器之间的时间差别. offset越接近于0,我们就和服务器的时间越接近
jitter: 这是一个用来做统计的值. 它统计了在特定个连续的连接数里offset的分布情况. 简单地说这个数值的绝对值越小我们和服务器的时间就越精确
NTP安全设置(restrict)
运行一个NTP Server不需要占用很多的系统资源,所以也不用专门配置独立的服务器,就可以给许多client提供时间同步服务, 但是一些基本的安全设置还是很有必要的
那么这里一个很简单的思路就是第一我们只允许局域网内一部分的用户连接到我们的服务器. 第二个就是这些client不能修改我们服务器上的时间
关于权限设定部分
权限的设定主要以 restrict 这个参数来设定,主要的语法为:
restrict IP地址 mask 子网掩码 参数
其中 IP 可以是IP地址,也可以是 default ,default 就是指所有的IP
参数有以下几个:
ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询
1参考文献:
1.鸟哥的Linux私房菜:第十五章、时间服务器: NTP 服务器(强烈建议看完)
2.http://www.crsay.com/wiki/wiki.php/server/centos/ntp-set
3.常见错误集锦:http://www.blogjava.net/spray/archive/2008/07/10/213964.html
2架构
Stratum 1/2 Internet NTP Server
Stratum 3 公司防火墙(防火墙带有ntp功能,并且能够连接外网)
Stratum 4 自己搭建ntp server(跟公司防火墙的ntp server对时,这样的好处有两个,一是降低了防火墙的压力,二是降低耦合性,防止因为防火墙的变更而带来更多的改动)
Stratum 5 公司内的各台机器,相当于是一个ntp client。
3安装
3.1在线安装
ntp在线安装的方式很简单,只需要执行以下命令即可帮你安装好ntp以及所有的依赖包
sudo apt-get install ntp
3.2离线安装
如果要离线安装,那么就需要下载ntp安装包和依赖包。我们可以在一个有线环境下运行上面的在线安装,然后到/var/cache/apt/archives这个目录下拷贝完整的ntp安装包和依赖包。当前我已经将这些安装包放到网盘上面去了:http://pan.baidu.com/s/1dDzg95f。
对于下载的deb包,我们使用dpkg安装包来安装,先安装依赖包,最后安装程序包。具体安装过程如下:
root@BJCGNMON01:/var/cache/apt/archives# dpkg -i libopts25_1%3a5.12-0.1ubuntu1_amd64.deb
Selecting previously unselected package libopts25.
(Reading database ... 51276 files and directories currently installed.)
Unpacking libopts25 (from libopts25_1%3a5.12-0.1ubuntu1_amd64.deb) ...
Setting up libopts25 (1:5.12-0.1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@BJCGNMON01:/var/cache/apt/archives# dpkg -i ntp_1%3a4.2.6.p3+dfsg-1ubuntu3.1_amd64.deb
(Reading database ... 51324 files and directories currently installed.)
Preparing to replace ntp 1:4.2.6.p3+dfsg-1ubuntu3.1 (using ntp_1%3a4.2.6.p3+dfsg-1ubuntu3.1_amd64.deb) ...
Unpacking replacement ntp ...
Setting up ntp (1:4.2.6.p3+dfsg-1ubuntu3.1) ...
* Starting NTP server ntpd
...done.
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db ...
当然还有更加简单的方法,将下载的deb包拷贝到/var/cache/apt/archives目录下,然后在执行一下命令同样可以安装。
sudo apt-get install ntp
安装完毕以后我们可以查看服务是否启动,执行以下命令:
enadmin@ubuntu-server:~/ftp/ntp_ubuntu$ service --status-all
[ ? ] acpid
[ ? ] apache
[ + ] apache2
[ - ] apparmor
[ ? ] apport
[ ? ] atd
[ - ] bootlogd
[ ? ] console-setup
[ ? ] cron
[ ? ] dbus
[ ? ] dmesg
[ ? ] dns-clean
[ ? ] friendly-recovery
[ - ] grub-common
[ ? ] hostname
[ ? ] hwclock
[ ? ] hwclock-save
[ ? ] irqbalance
[ ? ] killprocs
[ ? ] module-init-tools
[ ? ] mysql
[ + ] nagios
[ + ] nagios-bak
[ ? ] network-interface
[ ? ] network-interface-container
[ ? ] network-interface-security
[ ? ] networking
[ + ] ntp
[ ? ] ondemand
可以看到ntp服务已经启动([+]表示已经启动。)
4配置文件/etc/ntp.conf解析
sudo vim /etc/ntp.conf
这个文件是配置ntp最重要的一个文件,也是ntp配置过程中的唯一难点,之前一直不知道这个配置问价当中配置选项的含义,所以一直无从下手。
4.1配置上层server
利用 server 关键字设定上层 NTP 服务器,上层 NTP 服务器的设定方式为:
server [IP or hostname] [prefer]
在 server 后端可以接 IP 或主机名,个人比较喜欢使用 IP 来设定, perfer 表示『优先使用』的服务器。
4.2利用 restrict 来管理权限控制
在 ntp.conf 档案内可以利用『 restrict 』来控管权限,这个参数的设定方式为:
restrict [IP] mask [netmask_IP] [parameter]
其中 parameter 的参数主要有底下这些:
ignore: 拒绝所有类型的 NTP 联机;
nomodify: 客户端不能使用 ntpc 与 ntpq 这两支程序来修改服务器的时间参数, 但客户端仍可透过这部主机来进行网络校时的;
noquery: 客户端不能够使用 ntpq, ntpc 等指令来查询时间服务器,等于不提供 NTP 的网络校时;
notrap: 不提供 trap 这个远程事件登录 (remote event logging) 的功能。
notrust: 拒绝没有认证的客户端。
如果你没有在 parameter 的地方加上任何参数的话,这表示『该 IP 或网段不受任何限制』。一般来说,我们可以先关闭 NTP 的权限,然后再一个一个的启用允许登入的网段。
ntp server配置
ntp server的需求:
我的上层 NTP 服务器共只有防火墙的ntp server:10.138.16.251。
不对Internet 提供服务,仅允许来自内部网域10.138.0.0/255.255.0.0的查询而已;
侦测一些 BIOS 时钟与 Linux 系统时间的差异并写入 /var/lib/ntp/drift 档案当中。
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift #草稿文件
#日志文件
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
#上层ntp server
server 10.138.16.251 prefer
#让NTP Server和其自身保持同步,如果在/etc/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端
server 127.127.1.0
fudge 127.127.1.0 stratum 5
#不允许来自公网上ipv4和ipv6客户端的访问
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
#运行上层ntp server的所有权限
restrict 10.138.16.251
#允许这个网段的对时请求
restrict 10.138.0.0 mask 255.255.0.0 nomodify
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
使用 ntpd渐进式更新时间
ntp又是服务器,又是客户端,只需要通过配置即可。上面我们将10.138.16.232配置成了ntp服务器,下面这台服务器我们以10.138.16.232作为ntp服务器配置client。
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# Specify one or more NTP servers.
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#server 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org
# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com
server 10.138.16.251 prefer
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 10.138.16.251
restrict 10.138.0.0 mask 255.255.0.0 nomodify
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
使用ntpdate更新时间
在客户端只需要运行一下命令接口进行对时操作
sudo ntpdate 10.138.16.232
ntpdate命令是要在ntp进程退出的情况下执行,如果执行上述命令出错,那么请先关闭ntp进程,具体操作日下所示:
root@BJCGNMON01:/etc/init.d# ntpdate 10.138.16.232
27 Feb 14:59:32 ntpdate[18546]: the NTP socket is in use, exiting
root@BJCGNMON01:/etc/init.d# service ntp stop
* Stopping NTP server ntpd
...done.
root@BJCGNMON01:/etc/init.d# ntpdate 10.138.16.232
27 Feb 14:58:13 ntpdate[18557]: step time server 10.138.16.232 offset -98.402560 sec
如果是windows操作系统,按照参考文献1进行修改。
应用方法:
#pkill 正在运行的程序名
举例:
[root@localhost beinan]# pgrep -l gaim
2979 gaim
[root@localhost beinan]# pkill gaim
也就是说:
kill 对应的是 PID
pkill 对应的是COMMAND
1. cd /etc/vsftpd 进入ftp配置文件目录
2. vi vsftpd.conf编辑此文件,找到#chroot_list_enable=YES,删除前面的那个#号,表示开启此限制功能
找到chroot_list_file:chroot_list_file=/etc/vsftpd/chroot_list
3. 编辑chroot_list文件,加入你要限制的用户名,一行一个用户.
如果更新了vsftpd.conf,一定要重启ftp,命令如下:
[root@linuxsir001 root]# /etc/init.d/vsftpd restart
关闭 vsftpd: [ 确定 ]
为 vsftpd 启动 vsftpd: [ 确定 ]
- ⑴、命令配置法:ifconfig和ip
- Ifconfig ethx:x IP/netmask
- ip addr add IP dev ethx label ethX:X
- 利用命令配置的只是暂时的IP地址,如果重启网络服务和系统都会失效的。
- ⑵、配置文件配置法:
- 修改/etc/sysconfig/network-scripts/ifcfg-ethx:x
- DEVICE=ethx:x
- BOOTPROTO=static
- IPIPADDR= IP地址
- NETMASK= 子网掩码
- GATEWAY= 网关
- ONBOOT=YES 是否开机启用
- HWADDR=...... MAC
- 非主要地址不能用DHCP服务获得,必须为静止的。
八、 DNS配置文件:
- ⑴、DNS配置文件位置:/etc/resolv.conf
- ⑵、DNS配置格式:
- nameserver DNS_IP1
- nameserver DNS_IP2
- 指定本地解析:
- /etc/hosts下添加
- 目标主机IP 主机名
- fg:172.16.36.1 www.chris.com
- DNS解析过程-->/etc/hosts-->DNS 服务器
九、主机名配置文件:
- ⑴、配置文件位置: /etc/sysconfig/network
- ⑵、配置格式:
- HOSTNAME=名称
- NETWORKING={yes|no}:是否开启网络功能
# watch ntpq -p
Every 2.0s: ntpq -p Sat Jul 7 00:41:45 2007
remote refid st t when poll reach delay offset jitter
===========================================================
+193.60.199.75 193.62.22.98 2 u 52 64 377 8.578 10.203 289.032
*mozart.musicbox 192.5.41.41 2 u 54 64 377 19.301 -60.218 292.411
现在我就来解释一下其中的含义
remote: 它指的就是本地机器所连接的远程NTP服务器
refid: 它指的是给远程服务器(e.g. 193.60.199.75)提供时间同步的服务器
st: 远程服务器的层级别(stratum). 由于NTP是层型结构,有顶端的服务器,多层的Relay Server再到客户端. 所以服务器从高到低级别可以设定为1-16. 为了减缓负荷和网络堵塞,原则上应该避免直接连接到级别为1的服务器的.
t: 这个.....我也不知道啥意思^_^
when: 我个人把它理解为一个计时器用来告诉我们还有多久本地机器就需要和远程服务器进行一次时间同步
poll: 本地机和远程服务器多少时间进行一次同步(单位为秒). 在一开始运行NTP的时候这个poll值会比较小,那样和服务器同步的频率也就增加了,可以尽快调整到正确的时间范围.之后poll值会逐渐增大,同步的频率也就会相应减小
reach: 这是一个八进制值,用来测试能否和服务器连接.每成功连接一次它的值就会增加
delay: 从本地机发送同步要求到服务器的round trip time
offset: 这是个最关键的值, 它告诉了我们本地机和服务器之间的时间差别. offset越接近于0,我们就和服务器的时间越接近
jitter: 这是一个用来做统计的值. 它统计了在特定个连续的连接数里offset的分布情况. 简单地说这个数值的绝对值越小我们和服务器的时间就越精确
NTP安全设置(restrict)
运行一个NTP Server不需要占用很多的系统资源,所以也不用专门配置独立的服务器,就可以给许多client提供时间同步服务, 但是一些基本的安全设置还是很有必要的
那么这里一个很简单的思路就是第一我们只允许局域网内一部分的用户连接到我们的服务器. 第二个就是这些client不能修改我们服务器上的时间
关于权限设定部分
权限的设定主要以 restrict 这个参数来设定,主要的语法为:
restrict IP地址 mask 子网掩码 参数
其中 IP 可以是IP地址,也可以是 default ,default 就是指所有的IP
参数有以下几个:
ignore :关闭所有的 NTP 联机服务
nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。
notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网
noquery :不提供客户端的时间查询
1参考文献:
1.鸟哥的Linux私房菜:第十五章、时间服务器: NTP 服务器(强烈建议看完)
2.http://www.crsay.com/wiki/wiki.php/server/centos/ntp-set
3.常见错误集锦:http://www.blogjava.net/spray/archive/2008/07/10/213964.html
2架构
Stratum 1/2 Internet NTP Server
Stratum 3 公司防火墙(防火墙带有ntp功能,并且能够连接外网)
Stratum 4 自己搭建ntp server(跟公司防火墙的ntp server对时,这样的好处有两个,一是降低了防火墙的压力,二是降低耦合性,防止因为防火墙的变更而带来更多的改动)
Stratum 5 公司内的各台机器,相当于是一个ntp client。
3安装
3.1在线安装
ntp在线安装的方式很简单,只需要执行以下命令即可帮你安装好ntp以及所有的依赖包
sudo apt-get install ntp
3.2离线安装
如果要离线安装,那么就需要下载ntp安装包和依赖包。我们可以在一个有线环境下运行上面的在线安装,然后到/var/cache/apt/archives这个目录下拷贝完整的ntp安装包和依赖包。当前我已经将这些安装包放到网盘上面去了:http://pan.baidu.com/s/1dDzg95f。
对于下载的deb包,我们使用dpkg安装包来安装,先安装依赖包,最后安装程序包。具体安装过程如下:
root@BJCGNMON01:/var/cache/apt/archives# dpkg -i libopts25_1%3a5.12-0.1ubuntu1_amd64.deb
Selecting previously unselected package libopts25.
(Reading database ... 51276 files and directories currently installed.)
Unpacking libopts25 (from libopts25_1%3a5.12-0.1ubuntu1_amd64.deb) ...
Setting up libopts25 (1:5.12-0.1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
root@BJCGNMON01:/var/cache/apt/archives# dpkg -i ntp_1%3a4.2.6.p3+dfsg-1ubuntu3.1_amd64.deb
(Reading database ... 51324 files and directories currently installed.)
Preparing to replace ntp 1:4.2.6.p3+dfsg-1ubuntu3.1 (using ntp_1%3a4.2.6.p3+dfsg-1ubuntu3.1_amd64.deb) ...
Unpacking replacement ntp ...
Setting up ntp (1:4.2.6.p3+dfsg-1ubuntu3.1) ...
* Starting NTP server ntpd
...done.
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db ...
当然还有更加简单的方法,将下载的deb包拷贝到/var/cache/apt/archives目录下,然后在执行一下命令同样可以安装。
sudo apt-get install ntp
安装完毕以后我们可以查看服务是否启动,执行以下命令:
enadmin@ubuntu-server:~/ftp/ntp_ubuntu$ service --status-all
[ ? ] acpid
[ ? ] apache
[ + ] apache2
[ - ] apparmor
[ ? ] apport
[ ? ] atd
[ - ] bootlogd
[ ? ] console-setup
[ ? ] cron
[ ? ] dbus
[ ? ] dmesg
[ ? ] dns-clean
[ ? ] friendly-recovery
[ - ] grub-common
[ ? ] hostname
[ ? ] hwclock
[ ? ] hwclock-save
[ ? ] irqbalance
[ ? ] killprocs
[ ? ] module-init-tools
[ ? ] mysql
[ + ] nagios
[ + ] nagios-bak
[ ? ] network-interface
[ ? ] network-interface-container
[ ? ] network-interface-security
[ ? ] networking
[ + ] ntp
[ ? ] ondemand
可以看到ntp服务已经启动([+]表示已经启动。)
4配置文件/etc/ntp.conf解析
sudo vim /etc/ntp.conf
这个文件是配置ntp最重要的一个文件,也是ntp配置过程中的唯一难点,之前一直不知道这个配置问价当中配置选项的含义,所以一直无从下手。
4.1配置上层server
利用 server 关键字设定上层 NTP 服务器,上层 NTP 服务器的设定方式为:
server [IP or hostname] [prefer]
在 server 后端可以接 IP 或主机名,个人比较喜欢使用 IP 来设定, perfer 表示『优先使用』的服务器。
4.2利用 restrict 来管理权限控制
在 ntp.conf 档案内可以利用『 restrict 』来控管权限,这个参数的设定方式为:
restrict [IP] mask [netmask_IP] [parameter]
其中 parameter 的参数主要有底下这些:
ignore: 拒绝所有类型的 NTP 联机;
nomodify: 客户端不能使用 ntpc 与 ntpq 这两支程序来修改服务器的时间参数, 但客户端仍可透过这部主机来进行网络校时的;
noquery: 客户端不能够使用 ntpq, ntpc 等指令来查询时间服务器,等于不提供 NTP 的网络校时;
notrap: 不提供 trap 这个远程事件登录 (remote event logging) 的功能。
notrust: 拒绝没有认证的客户端。
如果你没有在 parameter 的地方加上任何参数的话,这表示『该 IP 或网段不受任何限制』。一般来说,我们可以先关闭 NTP 的权限,然后再一个一个的启用允许登入的网段。
ntp server配置
ntp server的需求:
我的上层 NTP 服务器共只有防火墙的ntp server:10.138.16.251。
不对Internet 提供服务,仅允许来自内部网域10.138.0.0/255.255.0.0的查询而已;
侦测一些 BIOS 时钟与 Linux 系统时间的差异并写入 /var/lib/ntp/drift 档案当中。
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift #草稿文件
#日志文件
statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
#上层ntp server
server 10.138.16.251 prefer
#让NTP Server和其自身保持同步,如果在/etc/ntp.conf中定义的server都不可用时,将使用local时间作为ntp服务提供给ntp客户端
server 127.127.1.0
fudge 127.127.1.0 stratum 5
#不允许来自公网上ipv4和ipv6客户端的访问
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
#运行上层ntp server的所有权限
restrict 10.138.16.251
#允许这个网段的对时请求
restrict 10.138.0.0 mask 255.255.0.0 nomodify
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
使用 ntpd渐进式更新时间
ntp又是服务器,又是客户端,只需要通过配置即可。上面我们将10.138.16.232配置成了ntp服务器,下面这台服务器我们以10.138.16.232作为ntp服务器配置client。
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# Specify one or more NTP servers.
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#server 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org
# Use Ubuntu's ntp server as a fallback.
#server ntp.ubuntu.com
server 10.138.16.251 prefer
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.
# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 10.138.16.251
restrict 10.138.0.0 mask 255.255.0.0 nomodify
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust
# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255
# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines. Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient
使用ntpdate更新时间
在客户端只需要运行一下命令接口进行对时操作
sudo ntpdate 10.138.16.232
ntpdate命令是要在ntp进程退出的情况下执行,如果执行上述命令出错,那么请先关闭ntp进程,具体操作日下所示:
root@BJCGNMON01:/etc/init.d# ntpdate 10.138.16.232
27 Feb 14:59:32 ntpdate[18546]: the NTP socket is in use, exiting
root@BJCGNMON01:/etc/init.d# service ntp stop
* Stopping NTP server ntpd
...done.
root@BJCGNMON01:/etc/init.d# ntpdate 10.138.16.232
27 Feb 14:58:13 ntpdate[18557]: step time server 10.138.16.232 offset -98.402560 sec
如果是windows操作系统,按照参考文献1进行修改。
- 防火墙学习随笔
- 防火墙 的配置规则 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- 学习随笔
- CentOS 防火墙学习
- 防火墙学习笔记
- 《Linux防火墙》学习摘要
- Linux学习 防火墙
- 逻辑回归
- openflow协议规范1.1.0翻译
- CentOS安装jdk1.8 及服务器之间的拷贝
- Android Studio 分析内存泄漏
- 小型软件公司发展路线
- 防火墙学习随笔
- UNPv1第二十六章:数据链路访问
- 《effectivec++》不在构造和析构过程中调用virtual函数
- solr源码入门1
- POJ 1830 开关问题 (01高斯消元)
- 构架相关
- 照片预览的scrollView控件
- PHP5.6之后php-fpm重启
- jquery ui dialog 中使用select2 导致select2的input失去焦点的解决方法