dhcp和ansible
发表于:2024-10-09 作者:千家信息网编辑
千家信息网最后更新 2024年10月09日,一、搭建DHCP服务,为局域网内用户提供10.1.1.0/24网段的IP,且租约期默认为48小时1.安装软件包:yum install -y dhcp*2.配置服务:[root@localhost d
千家信息网最后更新 2024年10月09日dhcp和ansible
一、搭建DHCP服务,为局域网内用户提供10.1.1.0/24网段的IP,且租约期默认为48小时
1.安装软件包:yum install -y dhcp*
2.配置服务:
[root@localhost dhcp]# vim dhcpd.conf option domain-name "example.org";option domain-name-servers ns1.example.org, ns2.example.org;default-lease-time 172800;max-lease-time 172800;log-facility local7;subnet 10.1.1.0 netmask 255.255.255.0 { range 10.1.1.100 10.1.1.200;
3.启动服务并验证:
systemctl start dhcpdhclient -d
二、在上述实验基础上,实现DHCP中继:
# 开启路由转发功能vim /etc/sysctl.confnet.ipv4.ip-forward=1sysctl -p# 启动dhcp中继服务dhcrelay dhcp_server_ip
中继服务实际使用中,基本没有必要使用。其他网络的主机另外新建一个dhcp服务就好,没有必要非得使用中继
三、借助Ansible Playbook自动化搭建LNMP环境(可借助yum)
1.实验主机:
ansible主机:172.20.10.6webservers:172.20.10.3appservers:172.20.10.4
2.ansible主机免密钥认证
(1)
[root@localhost playbooks]# ssh-keygen Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:SHA256:LFUqZ3zNLyVoJzwgIo+LzGwHhd2YCnKh7kOl6IZQcZ4 root@localhostThe key's randomart image is:+---[RSA 2048]----+| *o* . . . ||ooo@ + o = + ||+o+.E . * B = . ||*++. * o + + ||=B.. . S . . ||B . . . ||.= ||. . || |+----[SHA256]-----+
(2)
[root@localhost] ssh-copy-id 172.20.10.3[root@localhost]# ssh-copy-id 172.20.10.4
3.ansible配置文件
[webservers]172.20.10.3[appservers]172.20.10.4
4.定义playbook剧本:
[root@localhost playbooks]# vim lnmp.yml ---- hosts: webservers remote_user: root tasks: - name: install nginx yum: name=nginx - name: config copy: src=/data/nginx.conf dest=/etc/nginx/nginx.conf tags: conf notify: restart nginx - name: start nginx service: name=nginx state=started enabled=yes handlers: - name: restart nginx service: name=nginx state=restarted- hosts: appservers remote_user: root tasks: - name: install services yum: name={{ item }} with_items: - mariadb - mariadb-server - php - php-fpm - php-mysql - name: php-fpm config copy: src=/data/www.conf dest=/etc/php-fpm.d/www.conf notify: restart php-fpm - name: start php-fpm service: name=php-fpm state=started enabled=yes - name : start mysql service: name=mariadb state=started enabled=yes - name : config mysql shell: mysqladmin -uroot password "centos" - name: config php-index-file copy: src=/data/index.php dest=/var/www/html/ - name: config php-mysql-file copy: src=/data/mysql.php dest=/var/www/html/ handlers: - name: restart php-fpm service: name=php-fpm state=restart
(5)执行结果:
(6)测试:
四、采用Ansible Role方式自动化搭建LNMP
1.实验主机:
ansible主机:172.20.10.6webservers:172.20.10.3appservers:172.20.10.4
2.ansible主机roles目录:
3.执行结果为:
4.访问测试为:
主机
服务
中继
实验
必要
结果
测试
自动化
配置
剧本
功能
基础
实际
密钥
小时
局域
局域网
文件
方式
环境
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
mysql数据库插入语句
外包软件开发 免增值税吗
数据库 导出csv
暗黑2重制版ns怎么切换服务器
有哪些网络安全平台
网络安全该注意哪些事项
画数据库的软件
小程序云开发删除数据库所有数据
平板电脑应用软件开发
网络安全宣传周在哪里开幕
初中网络安全教育知识
数据库系统工程师 挂靠
广西的发票软件服务器地址
数据库表分页
网络安全公众平台演讲稿
免费报纸数据库
mac系统 处理数据库
乡镇网络安全教育会议记录
上海积点网络技术
我的世界逗比熊服务器介绍
美团的软件开发花了多钱
阳江卫星软件开发厂家直销
计算机网络技术(陆军)
服务器网络流量计算公式
崇明区推广软件开发供应商有哪些
揭阳卫星软件开发市价
计算机网络技术学就业
如何构建dns服务器的配置管理
网络安全账户资金损失保险
元气骑士服务器制作