Ubuntu에서 전용 네트워크 인터페이스를 사용하는 게이트웨이

Ubuntu에서 전용 네트워크 인터페이스를 사용하는 게이트웨이

Ubuntu 16.04 VM에 다음과 같은 개인 네트워크 인터페이스가 있습니다.

# Private network
auto ens19
iface ens19 inet static
    address 10.10.10.179
    netmask 255.255.255.0
    mtu 1450

내 vLAN이 제대로 작동하려면 지정된 게이트웨이가 필요하므로 다음과 같이 연결했습니다.

# Private network
auto ens19
iface ens19 inet static
    address 10.10.10.179
    netmask 255.255.255.0
    mtu 1450
    gateway 10.10.10.1

그러나 해당 게이트웨이를 추가하고 networking서비스를 다시 시작할 때마다 다음 오류와 함께 시작되지 않습니다.

Dec 15 10:50:08 postfix0 ifup[1968]: RTNETLINK answers: File exists
Dec 15 10:50:08 postfix0 ifup[1968]: Failed to bring up ens19.

실행은 ip addr flush dev xxx도움이 되지 않습니다.

그렇다면 이 문제를 어떻게 해결해야 할까요?

답변1

명명된 라우팅 테이블을 만듭니다. pvtnet이라는 이름은 임의적입니다. DHCP가 10.10.10 네트워크에 주소를 배포하는 경우 이 작업은 작동하지 않습니다.

echo '200 pvtnet' >> /etc/iproute2/rt_tables

파일 수정, /etc/network/interfaces.

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# DHCP hands out the DEFAULT gateway.
auto eth0 # use the real device name on your system
allow-hotplug eth0
iface eth0 inet dhcp

# The private network interface
auto ens19
allow-hotplug ens19
iface ens19 inet static
address 10.10.10.179
netmask 255.255.255.0
mtu 1450
post-up ip route add 10.10.10.0/24 dev ens19 src 10.10.10.179 table pvtnet
post-up ip route add default via 10.10.10.1 dev ens19 table pvtnet
post-up ip rule add from 10.10.10.179/32 table pvtnet
post-up ip rule add to 10.10.10.179/32 table pvtnet

관련 정보