DHCPCD로 네트워크 관리하기

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Network management using DHCPCD and the translation is 34% complete.
Outdated translations are marked like this.

이 게시글은 posting in the 젠투 포럼 게시글에 기반하며, 완벽한 네트워크 스택 관리에 dhcpcd를 활용하는 방법을 설명합니다.

Of course, it's possible to use dhcpcd together with net.* scripts. In fact, if dhcpcd is installed, it's used as the default DHCP client if config_eth0="dhcp" is set in /etc/conf.d/net. This article is specifically about using dhcpcd standalone.

설치

dhcpcd를 설치했는지 확인하십시오. 다음 기본 런레벨에 추가하고 서비스를 시작하십시오:

If using OpenRC, do:

root #rc-update add dhcpcd default
root #/etc/init.d/dhcpcd start

Or, if using systemd:

root #systemctl enable dhcpcd
root #systemctl start dhcpcd

이 설치 과정은 젠투 핸드북에서 설명하는 기본 네트워크 설정 헐명 범위에서 벗어나지만, 유무선 네트워크 인터페이스를 자동으로 전환하는 기능을 활용하는 이점을 취할 수 있습니다.

Wireless

wpa_supplicant

wpa_supplicant can be used for authentication of wireless and wired network interfaces. Create the configuration file if it does not exist:

파일 /etc/wpa_supplicant/wpa_supplicant.conf
# Allow users in the 'wheel' group to control wpa_supplicant
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

# Make this file writable for wpa_gui / wpa_cli
update_config=1

For authentication for the wired interface, add the configuration file mentioned in Wpa_supplicant#Setup_wired_802.1X.

First follow the setup guide for dhcpcd.

Emerge wpa_supplicant (Version >=2.6-r2 is needed in order to get the CONFIG_MATCH_IFACE option added in April 2017):

root #emerge --ask net-wireless/wpa_supplicant

Using OpenRC

Complete its conf.d file with the -M option for the wireless network interface:

파일 /etc/conf.d/wpa_supplicant
wpa_supplicant_args="-B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"

In case authentication for the wired interface is needed, this configuration file should look like:

파일 /etc/conf.d/wpa_supplicant
wpa_supplicant_args="-ieth0 -Dwired -c/etc/wpa_supplicant/wpa_supplicant_wired.conf -B -M -c/etc/wpa_supplicant/wpa_supplicant.conf"

With the configuration done, run it as a service:

root #rc-update add wpa_supplicant default
root #rc-service wpa_supplicant start

Using Systemd

Systemd allows a simpler per-device setup without needing to create the above conf.d files. As explained under wpa_supplicant item in the Native services section, a service symlink such as wpa_supplicant@wlan0.service looks for a separate configuration file to manage the device wlan0 in this case.

To configure a specific device this way, first copy or rename the /etc/wpa_supplicant/wpa_supplicant.conf file as /etc/wpa_supplicant/wpa_supplicant-DEVNAME.conf where DEVNAME should be the name of the device, such as wlan0.

Then, navigate to /etc/systemd/system/multi-user.target.wants and create the symlink:

root #ln -s /lib/systemd/system/wpa_supplicant@.service wpa_supplicant@DEVNAME.service

where DEVNAME is same device name as in the conf file above.

중요
Note the @ signs on both arguments in the symlink step.

Test the system:

root #systemctl daemon-reload
root #systemctl start wpa_supplicant@DEVNAME
root #systemctl status wpa_supplicant@DEVNAME

Using net-wireless/iwd

See the iwd article.

시험

dhcpcdwpa_supplicant를 멈추고, 디버깅을 활성화 한 상태에서 dhcpcd를 포그라운드에서 시작하신 후 dhcpcd에서 연결을 시작하는지 확인하십시오.

root #/etc/init.d/dhcpcd stop
root #killall wpa_supplicant
root #dhcpcd -dB
dhcpcd[23772]: version 6.4.5 starting
dhcpcd[23772]: udev: starting
dhcpcd[23772]: dev: loaded udev
...
...

정적 IP 주소

네트워크 인터페이스 카드를 정적 IP 주소로 설정해야 한다면, 그래픽 사용자 인터페이스에 입력하십시오. 그래픽 사용자 인터페이스가 없으면, dhcpcd/ko#정적 IP 주소에 설명한대로 /etc/dhcpcd.conf 파일에 항목을직접 추가en할 수 있습니다.

젠투 net.* 스크립트 옮기기

젠투 net.* 스크립트에서 설정을 가져올 때 wpa_supplicantnet.* 스크립트를 런레벨에서 제거하는게 중요합니다.

user $rc-config list | grep 'wpa_supplicant\|dhcpcd\|net.'
  net.wlp8s0                default
  dhcpcd                    default
  wpa_supplicant

net.으로 시작하는 스크립트는 런레벨에 할당하면 안됩니다. 위 예제에서 net.wlp8s0 를 제거해야합니다.

root #rc-update del net.wlp8s0
root #/etc/init.d/net.wlp8s0 stop

네트워크 설정이 잘 동작한다면 이전 젠투 net.* 스크립트(불필요함)를 완전히 제거할 수 있습니다. netifrc USE 플래그를 비활성화하고 OpenRC를 다시 이머지한 후, 마지막으로 net-misc/netifrc를 언머지하십시오.

root #echo 'sys-apps/openrc -netifrc' >> /etc/portage/package.use
root #emerge --ask --newuse --oneshot sys-apps/openrc
root #emerge -C net-misc/netifrc

이전 설정 파일과 심볼릭 링크도 제거할 수 있습니다:

root #rm /etc/conf.d/net
root #rm /etc/init.d/net.*

네트워크 의존 서비스

dhcpcd네트워크 의존 서비스 조정은 openrc-0.16.4부터 더 이상 지원하지 않습니다.

그래픽 사용자 인터페이스

net-misc/dhcpcd-ui 꾸러미에 dhcpcd 그래픽 사용자 인터페이스가 들어있습니다.

추가 참조

외부 자료