/etc/hosts를 동적으로 변경

/etc/hosts를 동적으로 변경

IP 주소를 변경할 때마다 /etc/hosts다음 줄을 편집하고 변경해야 합니다.

myPc-Vaio  192.168.1.x

사용 중인 일부 프로그램을 이렇게 변경해야 하므로 이 줄을 127.0.0.1.

네트워크가 변경될 때마다 해당 회선을 변경할 수 있는 자동화가 있습니까?

편집하다. 저는 kubuntu 13.10을 사용하고 있으며 dhcp 서버와 ubuntu의 기본 dhclient를 사용하여 새 IP 주소(기본 구성)를 얻고 있습니다.

답변1

을 사용하는 경우 다음을 DHCP사용하여 IP 주소 변경을 트리거할 수 있습니다 dhclient-script.

NAME

       dhclient-script - DHCP client network configuration script

DESCRIPTION

       The  DHCP  client  network configuration script is invoked from time to
       time by dhclient(8).  This script is used by the  dhcp  client  to  set
       each  interface's initial configuration prior to requesting an address,
       to test  the  address  once  it  has  been  offered,  and  to  set  the
       interface's  final configuration once a lease has been acquired.  If no
       lease is acquired, the script is used to  test  predefined  leases,  if
       any, and also called once if no valid lease can be identified.

       This  script  is  not meant to be customized by the end user.  If local
       customizations are needed, they should be possible using the enter  and
       exit  hooks  provided (see HOOKS for details).   These hooks will allow
       the user to override the default behaviour of the client in creating  a
       /etc/resolv.conf file.

       No  standard  client  script  exists  for  some operating systems, even
       though the actual client may work, so a pioneering user may  well  need
       to  create  a  new  script  or  modify  an  existing  one.  In general,
       customizations specific to a particular computer should be done in  the
       /etc/dhcp3/dhclient.conf file.   If you find that you can't make such a
       customization without customizing /etc/dhcp3/dhclient.conf or using the
       enter and exit hooks, please submit a bug report.

새 IP 주소를 가져오고 파일을 바꾸는 스크립트를 작성할 수 있습니다 /etc/hosts. 그런 다음 에 넣으십시오 /etc/dhcp/dhclient-exit-hooks.d/.

관련 정보