다른 인터페이스에서 dhclient를 사용하여 IP 업데이트

다른 인터페이스에서 dhclient를 사용하여 IP 업데이트

내 컴퓨터에는 두 개의 인터페이스가 eth0있고 eth1.

두 서브넷 모두에 DHCP 서버가 있습니다. dhclient두 인터페이스의 IP 주소를 어떻게 업데이트합니까 ?

만약 내가한다면:

dhclient -r && dhclient eth0

에서 IP를 업데이트했습니다 eth0. 그렇다면 내가 이것을 하고 싶다면:

dhclient eth1

오류로 인해 실패합니다.

dhclient(22421) is already running - exiting.

저 할 수 있어요:

dhclient -r && dhclient eth1

하지만 그 dhclient -r부분은 임대를 해제하고 eth0IP 주소를 해제합니다.

현재 내가 원하는 작업을 수행할 수 있는 유일한 방법은 dhclientfor 를 실행 eth0하고 잔인하게 종료한 다음 실행하는 것입니다 eth1. 결국 두 인터페이스 모두에서 업데이트된 IP를 얻게 됩니다.

나는 또한 행운을 dhclient -x빌어 대체하여 테스트했습니다 dhclient -r.

물론 이것이 유일한 방법은 아닙니다!

편집하다:

두 가지 대답은 dhclient -r eth0 eth1 && dhclient eth0 eth1 이를 수행하는 것을 제안하며, 이는 이러한 인터페이스에 대한 브로드캐스트 호출을 제한합니다. 그러나 응답하는 첫 번째 DHCP 서버만 사용되므로 두 개의 인터페이스가 아닌 단일 인터페이스에서 새 IP가 생성됩니다. 여기서는 DHCPDISCOVER두 인터페이스 모두에서 호출이 이루어지고 있지만 DHCPREQUESTDHCP 서버가 있는 첫 번째 인터페이스에서만 호출이 수행되는 것을 볼 수 있습니다 .eth0

Listening on LPF/eth0/0a:00:27:00:00:00
Sending on   LPF/eth0/0a:00:27:00:00:00
Listening on LPF/eth1/84:8f:69:d3:d4:a1
Sending on   LPF/eth1/84:8f:69:d3:d4:a1
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5 (xid=0x170fcb67)
DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 4 (xid=0x115a24c3)
DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x170fcb67)
DHCPOFFER from 192.168.1.1
DHCPACK from 192.168.1.1 (xid=0x170fcb67)
bound to 192.168.1.4 -- renewal in 1710 seconds.

답변1

누구나

dhclient -r && dhclient

또는

dhclient -r eth0 eth1 && dhclient eth0 eth1

편집 1:

다음 시도: 인스턴스 중 하나가 다른 파일을 사용하도록 하여 "dhclient(22421)가 이미 실행 중입니다 - 종료 중" 오류를 제거할 수 있습니다. PATH_DHCLIENT_PIDPATH_DHCLIENT_DB변수(또는 동등한 명령줄 옵션, 매뉴얼 페이지 참조)를 사용하여 구분하십시오.

답변2

아이디어 #1: dhclient에 2개의 인터페이스를 전달해 보세요

매뉴얼 페이지를 보면 dhclient예제 끝에 bit가 사용된 것을 알 수 있습니다 [ if0 [ ...ifN ]. 즉, dhclient실행하려는 만큼 많은 인터페이스를 실행하고 전달할 수 있습니다.

에서 발췌dhclient 매뉴얼 페이지

dhclient [ -4 | ] -6] [ -S ] [ -N [ -N... ] ] [ -T [ -T... ] ] [ -P [ -P... ] ] [ -p 포트 ] [ -d ] [ -e VAR=값] [ -q ] [ -1 ] [ -r | -x] [ -lf 임대 파일] [ -pf pid 파일] [ -cf 구성 파일] [ -sf 스크립트 파일 ] [ -s 서버 ] [ -g 릴레이 ] [ -n ] [ -nc ] [ -nw] [ -w ] [ -B ] [ -I dhcp 클라이언트 식별자] [ -H 호스트 이름] [ -F fqdn.fqdn ] [ -V 공급업체 클래스 식별자] [ -R 요청 옵션 목록] [ -timeout 시간 초과] [ -v ] [ --version ] [ if0 [ ...ifN ] ]

dhclient따라서 여러 인터페이스에 게시하고 연결할 수 있어야 합니다 .

dhclient -r eth0 eth1
dhclient eth0 eth1

아이디어 #2: NetworkManager가 어떻게 작동하는지 알아보세요.

dhclient내 시스템에 NetworkManager를 설정하는 방법은 다음과 같습니다. 매개변수를 사용하여 명시적으로 두 번째 dhclient를 호출해 볼 수 있습니다.

/sbin/dhclient -d -4 \
   -sf /usr/libexec/nm-dhcp-client.action \
   -pf /var/run/dhclient-wlan0.pid \
   -lf /var/lib/dhclient/dhclient-01f0476d-04bf-4ce7-8ced-844fae73f430-wlan0.lease \
   -cf /var/run/nm-dhclient-wlan0.conf wlan0

답변3

해결책을 찾았습니다.. 명시적인 dhclient-conf를 작성해야 했습니다..

이제 다음을 사용하여 호출하세요.

dhclient -cf /etc/dhcp/dhclient.conf -v vmbr1 --no-pid

dhclient -cf /etc/dhcp/dhclient-vmbr3.conf -v vmbr3 --no-pid

표준 단락에 댓글을 달 수 있습니다. 새 인터페이스를 추가하는 경우 여기에 명시적으로 명시하지 않으면 dhcp 요청이 발생하지 않습니다.

:/etc/dhcp# cat dhclient.conf

interface "vmbr1" {
send host-name = gethostname();
select-timeout 3;
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;
}

#send host-name = gethostname();
#request subnet-mask, broadcast-address, time-offset, routers,
      #  domain-name, domain-name-servers, domain-search, host-name,
      #  dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
     #   netbios-name-servers, netbios-scope, interface-mtu,
      #  rfc3442-classless-static-routes, ntp-servers;

:/etc/dhcp# cat dhclient-vmbr3.conf

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

interface "vmbr3" {
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;
}

나는 이것이 하나의 dhclient가 두 인터페이스를 모두 제공할 수 없게 만드는 dhcp 상태 머신 때문이라고 생각합니까?

관련 정보