二、安装和配置dnsmasq和tftpd-hpa
1.安装dnsmasq和tftpd-hpa
1.1 安装dnsmasq
dnsmasq是一个轻量级的tFTP、DHCP、PXE和DNS服务器。其中PXE、DHCP和tFTP服务是PXE网卡网络启动安装程序所必须的。我们在这里使用它提供DHCP和DNS服务。
# apt-get install dnsmasq
1.2 安装tftpd-hpa
tfpd-hpa是另外一个tFTP服务器。我们用tftpd-hpa来提供tFTP服务。
# apt-get install tftpd-hpa
2 配置cobbler 接管dnsmasq和tftpd-hpa
cobbler本身具备管理dnsmasq和tftpd-hpa的功能。所以我们只需要配置cobbler就可以了。
2.1 配置cobbler接管DHCP、DNS和tFTP服务
修改配置文件 /etc/cobbler/settings
需修改和修改后的值如下:
manage_dhcp: 1
manage_dns: 1
manage_tftpd: 1
restart_dhcp: 1
restart_dns: 1
pxe_just_once: 1
next_server: <server's IP address>
server: <server's IP address>
修改后:
# egrep -v '^#|^$' /etc/cobbler/settings
---
allow_duplicate_hostnames: 0
allow_duplicate_ips: 0
allow_duplicate_macs: 0
anamon_enabled: 0
build_reporting_enabled: 0
build_reporting_sender: ""
build_reporting_email: [ 'root@localhost' ]
build_reporting_smtp_server: "localhost"
build_reporting_subject: ""
cheetah_import_whitelist:
- "random"
- "re"
- "time"
- "orchestra"
createrepo_flags: "-c cache -s sha"
default_kickstart: /var/lib/cobbler/kickstarts/ubuntu-server.preseed
default_name_servers: []
default_ownership:
- "admin"
default_password_crypted: ""
default_virt_bridge: virbr0
default_virt_file_size: 5
default_virt_ram: 512
default_virt_type: qemu
enable_menu: 1
func_auto_setup: 0
func_master: overlord.example.org
http_port: 80
kernel_options:
ksdevice: bootif
lang: ' '
text: ~
locale: en_US
priority: critical
kernel_options_s390x:
RUNKS: 1
ramdisk_size: 40000
root: /dev/ram0
ro: ~
ip: off
vnc: ~
ldap_server: "ldap.example.com"
ldap_base_dn: "DC=example,DC=com"
ldap_port: 389
ldap_tls: 1
ldap_anonymous_bind: 1
ldap_search_bind_dn: ''
ldap_search_passwd: ''
ldap_search_prefix: 'uid='
mgmt_classes: []
mgmt_parameters:
from_cobbler: 1
puppet_auto_setup: 0
sign_puppet_certs_automatically: 0
puppetca_path: "/usr/sbin/puppetca"
remove_old_puppet_certs_automatically: 0
manage_dhcp: 1
manage_dns: 1
manage_tftpd: 1
manage_rsync: 0
manage_forward_zones: []
manage_reverse_zones: []
next_server: 192.168.88.253
power_management_default_type: 'ether_wake'
power_template_dir: "/etc/cobbler/power"
pxe_just_once: 1
pxe_template_dir: "/etc/cobbler/pxe"
consoles: "/var/consoles"
redhat_management_type: "off"
redhat_management_server: "xmlrpc.rhn.redhat.com"
redhat_management_key: ""
redhat_management_permissive: 0
register_new_installs: 0
reposync_flags: "-l -m -d"
restart_dns: 1
restart_dhcp: 1
run_install_triggers: 1
scm_track_enabled: 0
scm_track_mode: "git"
server: 192.168.88.253
snippetsdir: /var/lib/cobbler/snippets
template_remote_kickstarts: 0
use_gpxe: 0
virt_auto_boot: 1
webdir: /var/www/cobbler
xmlrpc_port: 25151
yum_post_install_mirror: 1
yum_distro_priority: 1
2.2 指定接管的DHCP、DNS和tFTP服务器类型
修改配置文件/etc/cobbler/modules.conf
修改后
# egrep -v '^#|^[ \t]*$' /etc/cobbler/modules.conf
[authentication]
module = authn_configfile
[authorization]
module = authz_allowall
[dns]
module = manage_dnsmasq # uses dnsmasq
[dhcp]
module = manage_dnsmasq # uses dnsmasq
[tftpd]
module = manage_in_tftpd # defaut, uses the system's tftp server, in this example, use tftpd-hpa
3 配置DHCP、DNS、tFTP服务
由于我们配置了cobbler接管DHCP、DNS和tFTP服务,所以我们不需要单独修改dnsmasq和tftpd-hpa的配置文件,只需要修改Cobbler中DHCP、DNS和tFTP相应的配置模板即可。
Cobbler会自动帮助我们做同步工作。
3.1 配置DHCP和DNS服务
3.1.1 修改配置
修改/etc/cobbler/dnsmasq.template
修改后:
# Cobbler generated configuration file for dnsmasq
# $date
#
# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts
#domain=
dhcp-range=192.168.88.100,192.168.88.254
dhcp-option=3,$next_server
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,$elilo
$insert_cobbler_system_definitions
3.1.2 同步配置
同步配置到dnsmasq
# cobbler sync
3.2 配置tFTP服务
3.2.1 修改配置
修改配置文件/etc/cobbler/tftpd.template
修改后:
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = $user
server = $binary
server_args = -B 1380 $args
per_source = 11
cps = 100 2
flags = IPv4
}
3.2.2 同步配置
同步配置到tftp-hpa
# cobbler sync
4. 检查前边的操作
4.1 检查端口开放
# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 7548/apache2
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 8875/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2217/sshd
tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN 1083/xrdp-sesman
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN 1078/xrdp
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 8387/python
tcp6 0 0 :::53 :::* LISTEN 8875/dnsmasq
tcp6 0 0 :::22 :::* LISTEN 2217/sshd
udp 0 0 0.0.0.0:53 0.0.0.0:* 8875/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 8875/dnsmasq
udp 0 0 0.0.0.0:69 0.0.0.0:* 7274/in.tftpd
udp 0 0 0.0.0.0:177 0.0.0.0:* 1213/lightdm
udp6 0 0 :::53 :::* 8875/dnsmasq
udp6 0 0 :::177 :::* 1213/lightdm
服务说明
80 Aapche服务
53 dnsmasqt程序的dns服务
67 dnsmasq程序的DHCP服务
69 tftp-hpa程序的tftp服务
25151 Apache2 的cobbler-web站点支持
4.2 检查PXE网络启动
在与cobbler服务器同一个网络找一台机器,BIOS调整从网络启动:
重新启动机器,正常情况下应该会进入Cobbler的网络启动菜单:
如果不能进入这个菜单,首先需要检查前边的步骤是否正确。还可以检查cobbler程序的日志。