zoukankan      html  css  js  c++  java
  • dhcp 和ntpdate时间同步

    为了防止路由器的dhcp服务干扰实验,我们2台机器分别新加了1快网卡. vmnet4

    dhcp安装

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

    将配置文件放在/etc/dhcp下
    [root@ygy130 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
    设置开机自启动
    [root@ygy130 ~]# chkconfig dhcpd on

    修改配置文件

    [root@ygy130 ~]# vim /etc/dhcp/dhcpd.conf 

    subnet 192.168.2.0 netmask 255.255.255.0{                               网段
    range 192.168.2.100 192.168.2.200;              范围
    option domain-name-servers 114.114.114.114;          dns
    option domain-name "ygy123.cn";                域名
    option routers 192.168.2.1;                   网关
    option broadcast-address 192.168.2.255;            广播
    default-lease-time 600;                    租期
    max-lease-time 7200;                    最长租期
    host ygy130{                        指定服务器主机
    hardware ethernet 00:0C:29:59:B1:B2;            绑定客户机地址
    fixed-address 192.168.2.110;                  客户机的ip
    }

    }

    启动

    [root@ygy130 ~]# service dhcpd restart
    Shutting down dhcpd: [ OK ]
    Starting dhcpd: [ OK ]

    要关闭防火墙,否则其他机器不能获得服务。
    注意,这里多网卡,要设置路由才能上网。
    [root@ygy130 ~]# route add default gw 192.168.1.1 eth0
    [root@ygy130 ~]# route add default gw 192.168.8.1 eth1
    [root@yu131 ~]# route add -net 192.168.8.0/24 gw 192.168.1.1 eth0
    这样就能上网了。

    重启失效。

    时间同步:ntpdate time.windows.com

    yum install ntpdate -y

    [root@ygy130 ~]# date +" %F"
    2016-09-25

    修改时间

    [root@ygy130 ~]# date -s "2015-3-6 21:13"
    Fri Mar 6 21:13:00 CST 2015
    [root@ygy130 ~]# date
    Fri Mar 6 21:13:03 CST 2015

    [root@ygy130 ~]# hwclock -r
    Sun 25 Sep 2016 11:59:48 PM CST -0.766794 seconds
    [root@ygy130 ~]# hwclock -w
    [root@ygy130 ~]# hwclock -r
    Fri 06 Mar 2015 09:14:06 PM CST -0.329304 seconds

    [root@yu131 ~]# ntpdate time.windows.com
    26 Sep 00:01:30 ntpdate[12406]: adjust time server 40.118.103.7 offset 0.040445 sec
    [root@yu131 ~]# date
    Mon Sep 26 00:01:35 CST 2016

  • 相关阅读:
    ubuntu: 环境搭建
    [转]unable to resolve superclass of 的奇怪问题和一种解决方法!
    [转]如何利用ndk-stack工具查看so库的调用堆栈【代码示例】?
    [转]TCP、UDP数据包大小的确定
    [转]教大家如何打造使用Tcpview(tcp查看器
    [转]帐号登录事件(事件编号与描述)
    [转]一个基于完成端口的TCP Server Framework,浅析IOCP
    [转]宏的高级使用--##,__VA_ARGS__, __FILE__, __FUNCTION__等
    mysql5.5 Replication 主从同步
    [转]adb pull Permission denied及no such file错误
  • 原文地址:https://www.cnblogs.com/yuguangyuan/p/5907668.html
Copyright © 2011-2022 走看看