From http://linux.vbird.org/linux_server/0230router.php
1. 先設定外部 eth0 的 ARP Proxy,讓三個 IP 對應到自己的 MAC
[root@www ~]# arp -i eth0 -s 192.168.1.10 08:00:27:71:85:BD pub [root@www ~]# arp -i eth0 -s 192.168.1.20 08:00:27:71:85:BD pub [root@www ~]# arp -i eth0 -s 192.168.1.30 08:00:27:71:85:BD pub [root@www ~]# arp -n Address HWtype HWaddress Flags Mask Iface 192.168.1.30 * * MP eth0 192.168.1.10 * * MP eth0 192.168.1.20 * * MP eth0
# 首先需要讓外部介面擁有三個 IP 的操控權,透過這三個指令來建立 ARP 對應!
2. 開始處理路由,增加 PC2~PC4 的單機路由經過內部的 eth1 來傳遞
[root@www ~]# route add -host 192.168.1.10 eth1 [root@www ~]# route add -host 192.168.1.20 eth1 [root@www ~]# route add -host 192.168.1.30 eth1 [root@www ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.20 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 192.168.1.10 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 192.168.1.30 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth0
# 這樣就處理好單向的單機路由囉!不過有個問題啊!那就是 192.168.1.0/24 # 的網域,兩個介面都可以傳送!因此,等一下第四個步驟得要將 eth1 刪除才行!3. 設定一下內部的 ARP Proxy 工作 (綁在 eth1 上頭囉)!
[root@www ~]# arp -i eth1 -s 192.168.1.101 08:00:27:2A:30:14 pub [root@www ~]# arp -i eth1 -s 192.168.1.254 08:00:27:2A:30:14 pub
# 這樣可以騙過 PC2 ~ PC4 ,讓這三部主機傳遞的封包可以透過 router 來傳遞! 4. 開始清除掉 eth1 的 192.168.1.0/24 路由
[root@www ~]# route del -net 192.168.1.0 netmask 255.255.255.0 eth1