
我正在嘗試使用乙太網路設備並使用 pointopoint 方法在兩台主機之間共享互聯網連接,但尚未獲得任何正確的回應,
以下是時間順序:
設定IP:
主持一個
ifconfig eth0 10.0.1.1 pointopoint 10.0.1.2 netmask 255.255.255.255
主機b
ifconfig eth0 10.0.1.2 pointopoint 10.0.1.1 netmask 255.255.255.255
設定路由器(主機A):
來自主機 a,其中主機 a 已設定ip_forward
為“1”(sysctl
和/proc/net/ipv4/
)
iptables -A PREROUTING -t nat -j MASQUERADE
在主機 b 上我已經在 cli 上完成了
route add default dev eth0
與/etc/resolv.conf
包含
nameserver 8.8.8.8
當 ping google 時,回應如下:
PING google.com (209.85.231.104) 56(84) bytes of data.
From 10.0.1.2 icmp_seq=2 Destination Host Unreachable
From 10.0.1.2 icmp_seq=3 Destination Host Unreachable
天啊?我到底錯在哪裡?
先感謝大家:)
答案1
首先,不要使用pointopoint。
其次,您在主機 B 上的路由應該是:
route add default gw 10.0.1.2
您希望將iptables
規則設定為以下內容:
iptables -A PREROUTING -t nat -i eth0 -o ppp0 -j MASQUERADE
如果您可以提供更多信息,我將擴展此答案以更好地幫助您。