0

I've been having some trouble wrapping my head around how static routes work.

Long story short I have the following:

  1. Fedora26 server with CentOS7 VM.
  2. Host IP: 192.168.0.6 assigned to eth0
  3. VM IP: 192.168.122.205
  4. Host is also the gateway IP of 192.168.122.1 on vibr0

If I do ip route add 192.168.122.0/24 via 192.168.0.6 dev wlp3s0 then i will get:

PING 192.168.122.205 (192.168.122.205) 56(84) bytes of data.
From 192.168.122.1 icmp_seq=1 Destination Host Unreachable
From 192.168.122.1 icmp_seq=2 Destination Host Unreachable

Here is my route script from /etc/sysconfig/network-scripts:

default 192.168.0.1 dev wlp3s0
192.168.122.1 via 192.168.0.15 dev wlp3s0
192.168.122.0/24 via 192.168.122.1 dev wlp3s0
192.168.100.0/24 via 192.168.0.20 dev wlp3s0

Please note that I've tried this with and without that first hop, and just had the third line say: 192.168.122.0/24 via 192.168.0.6 dev wlp3s0

The routing between the two works fine, as the vibr0 is configured as the gateway for the 192.168.122.0/24 subnet. However, I cannot figure out how to get any other machines in the 192.168.0.0/24 subnet to connect to the VMs in the 192.168.122.0/24 subnet on that host.

I have a laptop running Fedora with an IP of 192.168.0.16 that i want to connect to the 192.168.122.205 VM in the other host.

I assume I need to do a default route addition, using the 192.168.0.6 as the gateway to 192.168.122.0/24, but i've not had any success doing that.

So I guess my questions are: What would I need to do to make a connection from 192.168.0.16 → 192.168.0.6 (192.168.122.1) → 192.168.122.205?

Can a single interface be in two subnets? So can my wlp3s0 wifi card with the 192.168.0.16 also be assigned an IP in the 122 subnet, or is this even necessary?

Thank you for any help.

1
  • What interface is the 192.168.0.6 address assigned to? Does the host have any IP address assigned to the virbr0 interface? Commented Jul 20, 2017 at 20:05

1 Answer 1

1

The static route you would need to add to devices on the 192.168.0.0/24 network would probably need to look like this.

ip route add 192.168.122.0/24 via 192.168.0.6

Keep in mind that the Fedora26 probably also be setup to permit routing (ip_forwarding), and if you have any firewall rules on that system you probably need to add additional rules.

Can a single interface be in two subnets?

Yes you can have multiple IPs on different subnets assigned to a single interface in a system. But that is probably not a good idea. It usually makes things even more complicated and weird.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .