centos7安装nslookup工具、ntp工具

本文详细介绍了在CentOS7系统中如何安装和配置DNS解析工具nslookup及DNS服务器dnsmasq,实现localhost的本地解析,并通过设置NTP同步服务器,确保系统时间的准确性和一致性。

2018-12-13


 

centos7安装nslookup工具

yum install bind-utils -y

DNS解析localhost到本机

# 1.检测
[root@node2 ~]# nslookup localhost
Server:     118.118.118.9
Address:    118.118.118.9#53
 
Non-authoritative answer:
Name:   localhost.openstacklocal
Address: 183.136.168.91
 
# 2.搭建DNS
yum -y install dnsmasq
cp /etc/resolv.conf{,.bak}
rm -rf /etc/resolv.conf
echo -e "nameserver 127.0.0.1\nnameserver $(hostname -i)" >> /etc/resolv.conf
chmod 444 /etc/resolv.conf
chattr +i /etc/resolv.conf
echo -e "server=8.8.8.8\nserver=8.8.4.4" > /etc/dnsmasq.conf
echo -e "$(hostname -i)\tlocalhost.$(hostname -d)" >> /etc/hosts
service dnsmasq restart
 
# 3.再次检测
[root@master ~]# nslookup localhost
Server:     127.0.0.1
Address:    127.0.0.1#53
 
Name:   localhost
Address: 192.168.1.78

 

centos7安装ntp工具

 yum -y install ntp

同步系统时间

ntpdate 0.centos.pool.ntp.org

 

转载于:https://www.cnblogs.com/fqxy/p/10112193.html

<think>嗯,用户想将CentOS7加入Windows AD域,这是个经典的跨平台认证集成问题。用户可能是系统管理员,需要实现Linux服务器与现有Windows域的整合,可能是为了统一身份认证或满足安全合规要求。从技术实现看,核心步骤是配置DNS解析、主机名、安装realmd/sssd套件、执行域加入操作。特别要注意DNS配置——很多失败案例都源于此。用户提供的引用[3]详细描述了操作流程,但需要根据实际环境调整:比如AD域名可能是"example.com"而非"ad.example.com",主机名需符合NetBIOS命名规范。 用户可能遇到的坑点包括:防火墙未放行AD端口(389/tcp等)、时间未同步(需配NTP)、SELinux干扰(可临时setenforce0测试)。引用[2]提到的winbind是备选方案,但realmd+sssd组合更现代,支持离线登录等特性。在安全方面,建议提醒用户:域帐户登录需配置sudo权限;生产环境应使用TLS加密LDAP;可配置自动创建家目录(pam_mkhomedir.so)。最后生成的三个问题覆盖了排错、权限管理、自动化维护,都是实施后必然面对的实际需求。</think>以下是将 CentOS 7 加入 Windows Server Active Directory 域的详细步骤,结合引用内容整理: --- ### **核心步骤** #### 1. **环境准备** - **DNS 配置** 确保 CentOS 7 的 DNS 指向 AD 域控制器(DC): ```bash # 修改网卡配置(如 ens192) vi /etc/sysconfig/network-scripts/ifcfg-ens192 ``` 添加/修改: ```ini DNS1=192.168.1.10 # 替换为域控的 IP DOMAIN=ad.example.com # 替换为你的 AD 域名 ``` 生效配置: ```bash systemctl restart network # 验证解析 nslookup ad.example.com ``` - **主机名设置** ```bash hostnamectl set-hostname centos7-client.ad.example.com # 格式:主机名.域名 hostnamectl status # 确认修改 ``` #### 2. **安装必要软件** ```bash yum install realmd sssd oddjob oddjob-mkhomedir adcli samba-common ``` #### 3. **发现并加入域** - **发现域控** ```bash realm discover ad.example.com # 成功会显示域信息 ``` - **加入域** ```bash realm join ad.example.com -U administrator # 输入 AD 管理员密码 ``` > **注意**:若提示权限不足,在域控的 **Active Directory 用户和计算机** 中,将 CentOS 主机名加入 `Domain Admins` 组。 #### 4. **验证加入状态** ```bash realm list # 显示域信息表示成功 id administrator@ad.example.com # 测试域用户解析 ``` #### 5. **配置自动创建家目录** 编辑 `/etc/sssd/sssd.conf`: ```ini [domain/ad.example.com] fallback_homedir = /home/%u # 添加此行 ``` 重启服务: ```bash systemctl restart sssd chmod 600 /etc/sssd/sssd.conf # 确保权限 ``` #### 6. **防火墙放行 AD 端口** ```bash firewall-cmd --permanent --add-service={kerberos,ldap,ldaps,dns} firewall-cmd --reload ``` #### 7. **在 Windows AD 中确认** 打开 **Active Directory 用户和计算机** → `Computers` 容器,检查 CentOS 主机是否已加入。 --- ### **常见问题排查** - **时间同步问题** 确保 CentOS 与域控时间一致: ```bash yum install chrony systemctl enable --now chronyd chronyc sources # 检查同步状态 ``` - **DNS 解析失败** 检查 `/etc/resolv.conf` 是否包含域控的 DNS IP,且 `search` 参数包含 AD 域名。 - **权限不足** 在 AD 中为 CentOS 主机名授予 **加入域的权限**(如添加到 `Domain Admins` 组)。 --- ### **引用说明** > 配置 DNS 和主机名是加入域的关键前提(引用[3] 1.1-1.4步骤)。`realmd` 工具简化了域加入流程(引用[3] 3.1-3.2),而 `sssd` 负责后续认证(引用[2])。加入后需在 AD 控制台确认机器对象(引用[3] 步骤4)[^3][^2]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值