Solved About IP forwarding

Hello everyone,

Code:
Internet
    | 192.168.0.1/24 (defaultrouter)
    |
    | em0 192.168.0.2/24
+--------+
|  host1 |
+--------+
    | em1 10.0.0.1/24
    |
+--------+
|  host2 | 10.0.0.2/24
+--------+


host1:
em0: 192.168.0.2/24
em1: 10.0.0.1/24
defaultrouter="192.168.0.1"
gateway_enable="YES"

host2:
em0: 10.0.0.2/24
defaultrouter="10.0.0.1"

The two interfaces of host1 can be pinged on host2. But ping 192.168.0.1 failed.
Do it need additional settings besides enabling IP forwarding?

No firewall.

Thanks.
 
Yes, you'd need a better understanding of TCP/IP based networking. How are both hosts supposed to reach their default gateway when it's not even part of their own network? That's obviously never going to work. Therefor I also doubt your testing conclusions btw.

(edit) I see you edited some stuff but some problems still remain: how do you expect 10.0.0.2/24 to access 10.0.0.1? It can't, 10.0.0.1 isn't part of that network so the host has no knowledge on how to reach that.
 
You need the following route on host 192.168.0.1

Destination Gateway Flags Netif
10.0.0/24 192.168.0.2 UGS em0
 
  • Thanks
Reactions: sdf
Thank you!

This is my default routing table

Code:
Routing tables
Destination    Gateway       Flags Netif Expire
default        192.168.0.1   UGS   em0
10.0.0.0/24    link#2        U     em1
10.0.0.1       link#2        UHS   lo0
127.0.0.1      link#3        UH    lo0
192.168.0.0/24 link#1        U     em0
192.168.0.2    link#1        UHS   lo0
 
this is your 192.168.0.2 host, it's ok

The 192.168.0.1 need to know how to reach 10.0.0.0/24 that's why it can't respond to your ping from 10.0.0.2.

If you can't modify the routing on 192.168.0.1 host then instead routing you can use NAT to translate all traffic from 10.0.0.0/24 to 192.168.0.0/24
 
  • Thanks
Reactions: sdf
Back
Top