2

I intend to pass Internet from openSUSE Leap 15.1 to CentOS 7:

  • openSUSE Leap 15.1 machine with access to Internet through a wireless router
  • CentOS 7 machine without access to Internet due to lack of proper wireless chip driver

I connect openSUSE machine to CentOS by an Ethernet cable. My understanding is that I should have two different sub-nets:

  • openSUSE
    • Has static IP address of 192.168.2.252/24
    • Has DHCP IP address of 192.168.1.51/24
      • Access to Internet through 192.168.1.1
  • CentOS
    • Has static IP address of 192.168.2.251/24

Observations

  • Inside CentOS 192.168.2.251 I can ping openSUSE 192.168.2.252
  • Inside CentOS 192.168.2.251 I can ping openSUSE 192.168.1.51
  • Inside CentOS 192.168.2.251 I can not ping internet router 192.168.1.1
  • Inside CentOS 192.168.2.251 I can not ping 1.1.1.1
  • Inside CEntOS 192.168.2.251 I do not have access to Internet

Routing on openSUSE

> ip route
default via 192.168.1.1 dev wlan0 proto dhcp metric 600 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.51 metric 600 
192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.252 metric 100

Question

I cannot figure out what is wrong with routing. It's strange that from CentOS I can ping openSUSE on both sub-nets, but I cannot ping internet router!

Megidd
  • 1,519
  • 3
  • 32
  • 44
  • 1
    You want openSUSE to act as a router. This requires it to forward traffic that is not destined to itself. Most Linux distros are configured to ignore such traffic. Ensure that [IP forwarding](https://unix.stackexchange.com/questions/14056/what-is-kernel-ip-forwarding) is enabled. Use `sysctl` to enable it permanently. – berndbausch Mar 13 '21 at 03:12
  • @berndbausch When I check with `sudo sysctl net.ipv4.ip_forward` I'm getting `net.ipv4.ip_forward = 1`. I think IP forwarding is enabled. – Megidd Mar 13 '21 at 14:09
  • 1
    Yes it is. A different thought: What's the routing table on Centos? – berndbausch Mar 13 '21 at 14:32
  • @berndbausch CentOS `ip route` output summary is `default via 192.168.1.1` and `192.168.1.1` and `192.168.2.0/24 src 192.168.2.251` – Megidd Mar 13 '21 at 14:58
  • 1
    That's the problem. There is no connectivity to the default router. Make 192.168.2.252 the default. I don't understand the rest of your routing table; can't you just add `ip route` to the question? – berndbausch Mar 13 '21 at 15:03

1 Answers1

3

The problem is that your internet router does not know about the network 192.168.2.0/24. The openSUSE machine knows that network and therefore answers even when accessed with the other address.

If you have access to the internet router and the address 192.168.1.51 is a fixed DHCP lease, you could add a route at the internet router pointing to 192.168.2.0/24 via 192.168.1.51.

A probably easier way would be to add masquerading to the wifi interface of the openSUSE machine like in this question at superuser.

Mathias Weidner
  • 669
  • 4
  • 10