Linux는 가상 인터페이스의 소스 주소로 응답합니다.

Linux는 가상 인터페이스의 소스 주소로 응답합니다.

이것이 올바른 포럼이기를 바랍니다.

Quagga(BGP용) 및 DNSMASQ(DHCP용)가 설치된 Linux(Centos 7) 서버가 있습니다. 중복성을 위해 BGP를 통해 DHCP 서비스를 실행합니다.

현재 클라이언트는 BGP IP 주소(10.10.12.12)를 통해 DHCP 서버에 접속하고 DISCOVER 패킷을 보내고 있습니다. DHCP 서버는 이를 보고 OFFER를 발행하지만 DHCP 서버는 DHCP 서버 내부 IP의 소스 주소(172.18.25.10 - 보시다시피(아래 두 번째 tcpdump 패킷))를 대신 사용하기 때문에 해당 OFFER가 클라이언트에 반환되지 않습니다. BGP IP 주소(10.10.12.12) 중 172.18.25.10은 방화벽에 의해 차단되었습니다(열고 싶지 않습니다).

클라이언트에 반환되는 소스 주소를 내부 IP가 아닌 BGP 주소로 설정하려면 어떻게 해야 합니까? IP 라우팅 구성을 시도했지만 올바르게 설정할 수 없는 것 같습니다. 어떤 아이디어가 있나요?

노선

$ ip r
default via 172.18.25.1 dev ens256 proto static metric 100 
172.18.25.0/24 dev ens256 proto kernel scope link src 172.18.25.10 metric 100 

상호 작용

$ ifconfig
ens256: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 172.18.25.10  netmask 255.255.255.0  broadcast 172.18.25.255
    (truncated for brevity...)

lo:10: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 10.10.12.12  netmask 255.255.255.255
    loop  txqueuelen 1  (Local Loopback)

lo:10에 대한 가상 인터페이스 구성

DEVICE=lo:10
IPADDR=10.10.12.12
NETMASK=255.255.255.255
ONBOOT=yes
NAME=lo10

DHCP 서버 tcpdump

17:44:11.833026 IP (tos 0x0, ttl 62, id 4923, offset 0, flags [none], proto UDP (17), length 388)
192.168.69.1.67 > 10.10.12.12.67: [udp sum ok] BOOTP/DHCP, Request from a8:60:b6:0c:49:cd, length 360, hops 1, xid 0xad97213f, secs 8, Flags [none] (0x0000)
  Gateway-IP 192.168.69.1
  Client-Ethernet-Address a8:60:b6:0c:49:cd
  Vendor-rfc1048 Extensions
    Magic Cookie 0x63825363
    DHCP-Message Option 53, length 1: Discover
    Parameter-Request Option 55, length 10: 
      Subnet-Mask, Classless-Static-Route, Default-Gateway, Domain-Name-Server
      Domain-Name, Option 119, Option 252, LDAP
      Netbios-Name-Server, Netbios-Node
    MSZ Option 57, length 2: 1500
    Client-ID Option 61, length 7: ether a8:60:b6:0c:49:cd
    Lease-Time Option 51, length 4: 7776000
    Hostname Option 12, length 9: "tests-MBP"
    Agent-Information Option 82, length 57: 
      Circuit-ID SubOption 1, length 42: ToR-vc.corp.fake01:ge-0/0/20.0:dhcp-test-69
      Remote-ID SubOption 2, length 11: ge-0/0/20.0

17:44:11.833196 IP (tos 0xc0, ttl 64, id 4315, offset 0, flags [none], proto UDP (17), length 394)
172.18.25.10.67 > 192.168.69.1.67: [bad udp cksum 0xcc4d -> 0xe7d1!] BOOTP/DHCP, Reply, length 366, hops 1, xid 0xad97213f, secs 8, Flags [none] (0x0000)
  Your-IP 192.168.69.230
  Server-IP 172.18.25.10
  Gateway-IP 192.168.69.1
  Client-Ethernet-Address a8:60:b6:0c:49:cd
  Vendor-rfc1048 Extensions
    Magic Cookie 0x63825363
    DHCP-Message Option 53, length 1: Offer
    Server-ID Option 54, length 4: 172.18.25.10
    Lease-Time Option 51, length 4: 300
    RN Option 58, length 4: 150
    RB Option 59, length 4: 262
    Subnet-Mask Option 1, length 4: 255.255.255.0
    BR Option 28, length 4: 192.168.69.255
    Default-Gateway Option 3, length 4: 192.168.69.1
    Domain-Name-Server Option 6, length 4: 172.18.25.10
    Domain-Name Option 15, length 13: "example.com"
    Agent-Information Option 82, length 57: 
      Circuit-ID SubOption 1, length 42: ToR-vc.corp.fake01:ge-0/0/20.0:dhcp-test-69
      Remote-ID SubOption 2, length 11: ge-0/0/20.0

답변1

기반으로iptables: 대상 주소가 일치하면 로컬 소스 주소를 변경합니다.간단한 IP 경로를 추가하는 솔루션을 찾았습니다.

ip route add 192.168.69.1/32 via 172.18.25.1 src 10.10.12.12

또는

ip route add 0.0.0.0/0 via 172.18.25.1 src 10.10.12.12

답변2

이것이 dnsmasq의 문제라는 것이 확실하다면 해당 소프트웨어는 문제에 대한 몇 가지 해결책을 제공합니다. 예를 들어 인터페이스에서 지정된 인터페이스를 강제로 수신합니다.

interface=lo:10

no-dhcp-interface는 이 인터페이스에서 DHCP 할당을 비활성화합니다. 예:

no-dhcp-interface=ens256

수신 주소는 인터페이스처럼 보이지만 바인딩 IP를 지정합니다. 예:

listen-address=10.10.12.12

dnsmasq 문서에서:

-i, --interface=<interface name> Listen only on the specified interface(s). 
Dnsmasq automatically adds the loopback (local) interface to the list of 
interfaces to use when the --interface option is used. If no --interface or 

-2, --no-dhcp-interface=<interface name>
Do not provide DHCP or TFTP on the specified interface, but do provide DNS 
service.

-a, --listen-address=<ipaddr>
Listen on the given IP address(es). Both --interface and --listen-address 
options may be given, in which case the set of both interfaces and addresses 
is used. Note that if no --interface option is given, but --listen-address 
is, dnsmasq will not automatically listen on the loopback interface. To 
achieve this, its IP address, 127.0.0.1, must be explicitly given as a -- 
listen-address option.

관련 정보