
イーサネット デバイスとポイントツーポイント方式を使用して 2 つのホスト間でインターネット接続を共有しようとしていますが、まだ適切な応答が得られていません。
時系列は次のとおりです。
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
Google に ping すると、次のような応答が返されます。
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
さらに詳しい情報を提供していただければ、この回答を拡張して、より役立つ情報を提供させていただきます。