기존 인터페이스에 추가 IP를 어떻게 설정합니까?

기존 인터페이스에 추가 IP를 어떻게 설정합니까?

인터페이스가 있는데 eth0추가 가상 IP를 제공하고 싶습니다. 나는 다음을 통해 이를 달성합니다.

ifconfig eth0:0 ip.address.goes.here netmask subnet.address.goes.here

이것은 잘 작동하지만 재부팅하면 손실됩니다.

/etc/network/interfaces다음을 추가하기 위해 편집을 시도했습니다 .

auto eth0:0 iface eth0:0 inet static
    address ip.address.goes.here
    netmask subnet.address.goes.here

그런데 재부팅하면 eth0의 고정ip는 잘 로딩되는데, eth0:0 가상IP는 전혀 로딩되지 않습니다.

그렇다면 eth0:0가상 IP를 영구적으로 추가하려면 어떻게 해야 할까요?

답변1

그 사업 대신에 eth0:0다음을 수행해야 합니다.

  • /etc/network/interfaces평소와 같이 하나의 고정 IP 주소를 구성하십시오 .

    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 192.168.0.201
    network 192.168.0.0
    netmask 255.255.255.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    
  • 다른 IP를 추가하세요.이것위 항목 바로 뒤에 다음을 추가하여 인터페이스를 구현하세요.

    up /sbin/ip addr add 192.168.0.203/24 dev eth0
    down /sbin/ip addr del 192.168.0.203/24 dev eth0
    
  • 완전한 파일은바라보다좋다이것

이제 를 실행하여 구성된 IP 주소를 확인하면 ip addr show둘 다 표시됩니다.

2: eth0: mtu 1500 qdisc pfifo_fast 상태 UP qlen 1000
    링크/이더 08:00:27:1d:fa:0b brd ff:ff:ff:ff:ff:ff
    아이넷 192.168.0.201/24brd 192.168.0.255 범위 글로벌 eth0
    아이넷 192.168.0.203/24범위 전역 보조 eth0

나에게 올바른 방향을 알려준 Lekenstein에게 감사드립니다. 인터넷의 모든 사이트는 eth0:0보조 IP 주소에 대해 이야기합니다.이것적절한 방법인 것 같습니다.

답변2

"전통적인" 방식으로 작업을 수행하려면 관련 부분이 다음 /etc/network/interfaces과 같아야 합니다.

auto eth0:0
iface eth0:0 inet static
    address ip.address.goes.here
    netmask subnet.address.goes.here

대신에 당신이 실수한 곳은 다음과 같습니다:

auto eth0:0 iface eth0:0 inet static
    address ip.address.goes.here
    netmask subnet.address.goes.here

관련 정보