ubuntu

如何通过Cobbler设置Ubuntu系统的网络参数

小樊
34
2025-12-21 04:41:49
栏目: 智能运维

通过 Cobbler 设置 Ubuntu 系统的网络参数

一、前置准备与总体思路

二、DHCP 与 TFTP 的基础网络下发

subnet 192.168.1.0 netmask 255.255.255.0 {
    option routers 192.168.1.1;
    option domain-name-servers 223.5.5.5, 8.8.8.8;
    range dynamic-bootp 192.168.1.100 192.168.1.200;
    filename "pxelinux.0";
    next-server $next_server;
    default-lease-time 21600;
    max-lease-time 43200;
}

上述步骤完成后,客户端 PXE 启动即可通过 DHCP 获取安装所需网络参数与引导文件。

三、为指定主机设置静态网络参数

cobbler system add \
  --name=node01 \
  --mac=00:50:56:2B:B1:19 \
  --profile=ubuntu-20.04-amd64 \
  --ip-address=192.168.1.105 \
  --subnet=255.255.255.0 \
  --gateway=192.168.1.1 \
  --interface=ens33 \
  --static=1 \
  --hostname=node01 \
  --name-servers="223.5.5.5 8.8.8.8" \
  --kickstart=/var/lib/cobbler/kickstarts/ubuntu-20.04.seed

说明:上述命令会在安装阶段为指定 MAC 的主机分配静态 IP/网关/DNS/主机名,并绑定到指定 profilekickstart

四、在 Ubuntu 安装阶段与安装后持久化网络

# 使用 DHCP(默认)
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_timeout string 60

# 或使用静态 IP(取消注释并按需修改)
# d-i netcfg/choose_interface select eth0
# d-i netcfg/get_ipaddress string 192.168.1.105
# d-i netcfg/get_netmask string 255.255.255.0
# d-i netcfg/get_gateway string 192.168.1.1
# d-i netcfg/get_nameservers string 223.5.5.5 8.8.8.8
# d-i netcfg/confirm_static boolean true

# 主机名
d-i netcfg/get_hostname string node01
d-i netcfg/get_domain string localdomain

要点:

五、验证与常见问题

0
看了该问题的人还看了