Ubuntu Server 12.04下cobbler + dnsmasq +tftpd-hpa的安裝配置(二)

二、安裝和配置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調整從網絡啓動:

SUSE Linux Enterprise 11 64-bit-2013-11-02-01-31-28

重新啓動機器,正常情況下應該會進入Cobbler的網絡啓動菜單:

SUSE Linux Enterprise 11 64-bit-2013-11-02-21-37-04

如果不能進入這個菜單,首先需要檢查前邊的步驟是否正確。還可以檢查cobbler程序的日誌。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章