我在一台机器上有一个公共IP地址:
a.b.c.156/32
GW 为 abc133(位于 /27 网络中,其网关为 abc129)
我静态添加了一个 arp 路由:
sudo arp -an
a.b.c.133 at ab:cd:ef:12:34:56 [ether] PERM on eth0
如果我从 ping a.b.c.156/32
:
From a.b.c.133: icmp_seq=2 Redirect Host (New nexthop: a.b.c.129)
然后:
sudo arp -an
a.b.c.129 at aa:bb:cc:dd:ee:ff [ether] on eth0 # !<------ why? (it is even not from the same network)
a.b.c.133 at ab:cd:ef:12:34:56 [ether] PERM on eth0
如何防止它在我的路由器 (abc133) 后面发送 arp?这样 abc129 就只能通过 IP 级别 3 访问,而不是像子网一样?
更新:
网络结构:
provider's GW (a.b.c.129/27) <--- my host (a.b.c.133/27) <--- my second host (a.b.c.156/32)
<--- my third host (a.b.c.151/32)
...
(a.b.c.x - public IP)
如何防止后面的主机"my host (a.b.c.133)"
向 发送 arp "provider's GW (a.b.c.129/27)"
,而是使用路由?这样 abc129 就只能通过 IP 级别 3 访问,而不能直接访问?那么如何隔离第二台、第三台……主机,使其不向 发送 arp "provider's GW (a.b.c.129/27)"
?
更新 2:
我有以下内容"route -n"
:
Dest. GW. Mask Flags Metrics Ref Interface
0.0.0.0 a.b.c.133 0.0.0.0 UG 0 0 eth0
a.b.c.133 0.0.0.0 255.255.255.255 UH 0 0 eth0
更新 3:
===============
my host (a.b.c.133/27):
> ip r
a.b.c.151 dev vmbr0 scope link # third host
a.b.c.156 dev vmbr0 scope link # second host
192.168.1.0/24 dev vmbr1 proto kernel scope link src 192.168.1.1 # local network
default via a.b.c.129 dev vmbr0 # provider's gw
> ip n
a.b.c.129 dev vmbr0 lladdr AA:BB:CC:DD:EE:FF REACHABLE
a.b.c.156 dev vmbr0 lladdr AB:CD:EF:12:34:56 PERMANENT
a.b.c.151 dev vmbr0 lladdr A1:B2:C3:D4:E5:F6 PERMANENT
===============
my second host (a.b.c.156/32):
> ip r
default via a.b.c.133 dev eth0
a.b.c.133 dev eth0 scope link
> ip n # before "ping a.b.c.129" or "ping 8.8.8.8"
a.b.c.133 dev eth0 lladdr F1:E2:D3:C4:B5:A6 PERMANENT
> ip n # after "ping a.b.c.129" or "ping 8.8.8.8"
a.b.c.129 dev eth0 lladdr AA:BB:CC:DD:EE:FF REACHABLE # after some minutes idle => STALE
a.b.c.133 dev eth0 lladdr F1:E2:D3:C4:B5:A6 PERMANENT
===============
other hosts the similar to "my second host"
答案1
a.b.c.129 at aa:bb:cc:dd:ee:ff [ether] on eth0 # !<------ why?
(it is even not from the same network)
它位于同一个网络上。否则您将看不到节点的硬件地址。如果您在不同的网络上,您只会看到路由器的 MAC 地址*。逻辑上分离的子网可以位于同一个物理网络上。没有什么可以阻止它们使用最短的物理路径。在示例中,提供商的网关和您的网关共享一个子网。
如果您希望强制所有流量通过网关,我认为您需要在主机上创建防火墙规则。
* 您将看到+'. (十字代表 NIC)
[local subnet]---------+' local gw +"
|
|
[ remote subnet]----+. remote gw +,