0

In a virtual network, I have two hosts,let's call : A and B with ip addresses of 10.0.0.1 and 10.0.0.4. Beetween the hosts there is a router with two different network cards,and two different ip addresses.I've set the gateway, and the hosts can now ping with the router and vice versa.Still, A can't reach B towards the router.I've already enabled the ip forwarding in sysctl. Am I missing something here?

closed as too broad by Ron Maupin Jul 7 '18 at 20:37

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What subnet masks are you using for the above two subnets? They need to be in different subnets to forward traffic to the default gateway when pinging the other hosts. The addresses above don’t look correct if you are using 255.255.255.252 as the second one is a network address. If you are using a larger mask then they are in the same network and aaRP directly for the other host – Karl Billington Jul 5 '18 at 6:03
  • Routers route between networks, not from a network back to the same network. Your addressing can only be host addresses on two different networks if you are using /31 networks, but you have not provided any information, such as the router model or configuration, to see where you have made a mistake. Please edit your question to include more information. – Ron Maupin Jul 7 '18 at 20:36
1

You need to make sure the two hosts are in different IP networks. If the hosts are in the same network then they will attempt to ARP directly for the other host and not use the gateway. In this case as they are not in the same LAN, pings will fail.

Most routers won’t let you configure the same network on two different interfaces, but I know that some do. If this is the case, they expect the two interfaces to be connected to the same LAN, which it doesn’t sound like yours is.

So you can either connect both hosts to the same LAN, they won’t need the gateway to speak to each other in this case. Alternatively put both hosts on different IP networks and use the router as default gateway for both networks.

If you are using /24 subnet masks (255.255.255.0) try:

Interface 1 Router address: 10.0.0.1/24 Host address: 10.0.0.2/24

Interface 2 Router address 10.0.1.1/24 Host address 10.0.1.2/24

Make sure you configure the correct default gateways on the hosts and as long as routing is enabled on the router it will probably work.

  • I've done as you suggested,but I still can't ping.When from host A I try to ping the ip address of B,it says that network is unreachable.I'm probably don't understand something obvious here.Maybe because the nics are in bridge and not in NAT? – Kuze Jul 5 '18 at 10:18
  • That is what you want, for your NICs to be in bridge mode, not NAT. Do you have the correct default gateways configured on each host? Should be 10.0.0.1 on the first host and 10.0.1.1 on the second one? Can you still ping each default gateway from the host? – Karl Billington Jul 5 '18 at 10:33
  • Maybe I've did it. I've managed to put a route beetween the two different ip of the nics of the router.Now I can ping the second host – Kuze Jul 5 '18 at 16:48
1

A and B with ip addresses of 10.0.0.1 and 10.0.0.4

First of all: For routing, is not posible that you have those IPs in differents networks connected across router, because:

  • If you use netmask 24, there are on the same subnet,
  • If you use netmask 30, the firts is correct, 10.0.0.0/30 with network 10.0.0.0/30, 10.0.0.1 and 10.0.0.2 for hosts and 10.0.0.3 for broadcast; but for the second one, network address would be 10.0.0.4/30, 10.0.0.5 and 10.0.0.6 for hosts and 10.0.0.7 for broadcast, like you see, your are using 10.0.0.4 as host address.

So, with this, your scenario will be something like this:

A:10.0.0.1---------10.0.0.2(router)10.0.0.5-----------B:10.0.0.6

Not the answer you're looking for? Browse other questions tagged or ask your own question.