Fedora 21에서 호스트 이름을 영구적으로 변경하는 방법

Fedora 21에서 호스트 이름을 영구적으로 변경하는 방법

hostnamectl최신 버전의 Fedora에서는 호스트 이름을 변경하는 작업 이 명령을 통해 수행된다고 들었습니다 . 또한 최근에 이 방법을 사용하여 Arch Linux에서 호스트 이름을 성공적으로 변경했습니다. 그러나 실행 시:

[root@localhost ~]# hostnamectl set-hostname --static paragon.localdomain
[root@localhost ~]# hostnamectl set-hostname --transient paragon.localdomain
[root@localhost ~]# hostnamectl set-hostname --pretty paragon.localdomain

많은 사람들이 말하는 것과 달리 이러한 변경 사항은 재부팅 후에도 유지되지 않습니다. 뭐가 문제 야?

  • 진짜수동으로 편집하고 싶지 않습니다 /etc/hostname.

나는 또한 이것이 하나라는 점을 지적해야 한다.완전히재고 있음 페도라 모자. 아직 핵심 애플리케이션 설치도 시작하지 않았습니다.

답변1

호스트 이름을 설정하는 명령은 확실히 입니다 hostnamectl.

root ~ # hostnamectl set-hostname --static "YOUR-HOSTNAME-HERE"

다음은 이 기능을 자세히 설명하는 추가 소스입니다.호스트 이름을 올바르게 설정하기 - Amazon EC2의 Fedora 20.

추가적으로 다음 매뉴얼 페이지도 있습니다 hostnamectl:

HOSTNAMECTL(1)                    hostnamectl                   HOSTNAMECTL(1)

NAME
       hostnamectl - Control the system hostname

SYNOPSIS
       hostnamectl [OPTIONS...] {COMMAND}

DESCRIPTION
       hostnamectl may be used to query and change the system hostname and
       related settings.

       This tool distinguishes three different hostnames: the high-level
       "pretty" hostname which might include all kinds of special characters
       (e.g. "Lennart's Laptop"), the static hostname which is used to
       initialize the kernel hostname at boot (e.g. "lennarts-laptop"), and
       the transient hostname which is a default received from network
       configuration. If a static hostname is set, and is valid (something
       other than localhost), then the transient hostname is not used.

       Note that the pretty hostname has little restrictions on the characters
       used, while the static and transient hostnames are limited to the
       usually accepted characters of Internet domain names.

       The static hostname is stored in /etc/hostname, see hostname(5) for
       more information. The pretty hostname, chassis type, and icon name are
       stored in /etc/machine-info, see machine-info(5).

       Use systemd-firstboot(1) to initialize the system host name for mounted
       (but not booted) system images.

Fedora 21에는 SELinux가 hostnamectl 액세스를 차단하는 버그가 있습니다. 이 버그는 여기에서 찾을 수 있습니다.버그 1133368 - SELinux는 systemd-hostnam이 파일 호스트 이름에 대한 액세스를 "연결 해제"하지 못하도록 방지합니다..

이 오류는 관련이 있는 것 같습니다. /etc/hostname설치 중에 SELinux 컨텍스트가 파일에 올바르게 적용되지 않는 문제가 발생했습니다. 이는 도구가 hostnamectl파일에서 작동할 수 없음 을 의미합니다 /etc/hostname. 동일한 스레드가 다음 해결 방법을 제공합니다.

$sudo restorecon -v /etc/hostname

노트:패치가 Anaconda(설치 도구)에 적용되었으므로 향후 신규 사용자에게는 이 문제가 사라질 것입니다.

답변2

가능한 원인은 DHCP 클라이언트입니다. 일반적인 dhcpcd를 사용하는 경우 해결 방법은 다음 줄을 추가하는 것입니다 /etc/dhcpcd.conf.

nohook hostname

이렇게 하면 dhcpcd가 시스템의 호스트 이름을 변경하는 스크립트를 호출하는 것을 방지할 수 있습니다.

기본적으로 dhcpcd는 기존 후크를 모두 실행합니다 /lib/dhcpcd/dhcpcd-run-hooks(경로는 시스템에 따라 다를 수 있음). 특정 비활성화를 사용하십시오 nohook.

관련 정보