두 번째 Linux 라우터(B)를 통해 일부 서브넷을 라우팅하는 기본 BSD 라우터(A)가 있고 모든 것이 잘 작동합니다. 하지만 두 번째 라우터에서 이러한 서브넷에 액세스하려고 하면 작동하지 않습니다. 반환 패킷이 삭제되거나 올바르게 라우팅되지 않는 것 같나요?
나는 그것이 다음과 같다고 가정하고 있습니다: B로부터의 요청(A는 기본 게이트웨이입니다) -> A는 B를 통해 라우팅하기로 결정합니다 -> ... 거기에서 어려움을 겪고 있습니다...
만약을 대비해 A의 서브넷 목록은 동적이므로 B의 경로를 재정의하기 위해 복사본을 보관할 수 없습니다.
A(OPN센스)
ifconfig
:
ix0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=4803828<VLAN_MTU,JUMBO_MTU,WOL_UCAST,WOL_MCAST,WOL_MAGIC,NOMAP>
ether xx:xx:xx:xx:xx:xx
media: Ethernet autoselect (10Gbase-Twinax <full-duplex,rxpause,txpause>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
igb0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: WAN (wan)
options=4802028<VLAN_MTU,JUMBO_MTU,WOL_MAGIC,NOMAP>
ether xx:xx:xx:xx:xx:xx
inet xx.xx.100.162 netmask 0xfffffe00 broadcast xx.xx.101.255
inet6 xxxx::xxxx:xxxx:xxxx:xxxx%igb0 prefixlen 64 scopeid 0x2
groups: IG_WAN
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
igb1: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: WAN2 (opt7)
options=4802028<VLAN_MTU,JUMBO_MTU,WOL_MAGIC,NOMAP>
ether xx:xx:xx:xx:xx:xx
groups: IG_WAN
media: Ethernet autoselect
status: no carrier
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
enc0: flags=0<> metric 0 mtu 1536
groups: enc
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
...
ix0_vlan4: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: SERVICE (opt4)
options=4000000<NOMAP>
ether xx:xx:xx:xx:xx:xx
inet 192.168.4.1 netmask 0xffffff00 broadcast 192.168.4.255
groups: vlan IG_BROADCAST IG_SRV_ACCESS IG_WAN_ACCESS
vlan: 4 vlanproto: 802.1q vlanpcp: 0 parent interface: ix0
media: Ethernet autoselect (10Gbase-Twinax <full-duplex,rxpause,txpause>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
netstat -rn
(xx.xx - WAN 주소):
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default xx.xx.100.1 UGS igb0
8.8.4.4 192.168.4.58 UGHS ix0_vlan
xx.xx.1.2 xx.xx.100.1 UGHS igb0
xx.xx.1.4 xx.xx.100.1 UGHS igb0
xx.xx.100.0/23 link#2 U igb0
xx.xx.100.162 link#2 UHS lo0
127.0.0.1 link#5 UH lo0
127.0.1.1 link#14 UH lo1
...
192.168.4.0/24 link#11 U ix0_vlan
192.168.4.1 link#11 UHS lo0
B(데비안)
ip a
:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
altname enp0s18
inet 192.168.4.58/24 metric 1024 brd 192.168.4.255 scope global dynamic ens18
valid_lft 85211sec preferred_lft 85211sec
inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope link
valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 500
link/none
inet 198.18.0.1/15 brd 198.19.255.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope link stable-privacy
valid_lft forever preferred_lft forever
ip r
:
default via 192.168.4.1 dev ens18 proto dhcp src 192.168.4.58 metric 1024
192.168.4.0/24 dev ens18 proto kernel scope link src 192.168.4.58 metric 1024
192.168.4.1 dev ens18 proto dhcp scope link src 192.168.4.58 metric 1024
198.18.0.0/15 dev tun0 proto kernel scope link src 198.18.0.1
ip r s t 1000
:
default via 198.18.0.1 dev tun0 proto static
198.18.0.0/15 dev tun0 proto static scope link
ip ru
:
0: from all lookup local
32765: from all iif ens18 lookup 1000 proto static
32766: from all lookup main
32767: from all lookup default
tun0
을 통해 생성되고 있습니다.github.com/xjasonyu/tun2socks:
ip tuntap add mode tun dev tun0
ip addr add 198.18.0.1/15 dev tun0
ip link set dev tun0 up
tun2socks -loglevel info -device tun0 -proxy socks5://127.0.0.1:1080
노트
- B에서 액세스를 시도할 때
8.8.4.4
(예: A를 통해 A로 라우팅되는 경우192.168.4.1
) 시스템 로그에서 다음 내용이 발견되었습니다.IPv4: martian source 8.8.4.4 from 192.168.4.58, on dev ens18
- @AB가 제안한 대로 시도했지만
ip rule add iif lo lookup 1000 suppress_prefixlength 0
성공하지 못했습니다.