1

I have a small cluster with several nodes. Only one node (let's call it root), can connect to the internet. All nodes are connected, so we can ping from one to another, but we can't reach Internet from common node (i.e. not root).

Root node ifconfig output:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:d8:53:25  
          inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4084 errors:0 dropped:1295 overruns:0 frame:0
          TX packets:841 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:249141 (243.3 KiB)  TX bytes:87110 (85.0 KiB)

eth1      Link encap:Ethernet  HWaddr b8:8d:12:54:75:aa  
          inet addr:158.184.27.129  Bcast:158.184.27.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1647 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:229772 (224.3 KiB)  TX bytes:68634 (67.0 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:260 (260.0 B)  TX bytes:260 (260.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:0f:13:39:02:c3  
          inet addr:158.196.122.94  Bcast:158.196.123.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:127 errors:0 dropped:0 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:37269 (36.3 KiB)  TX bytes:27150 (26.5 KiB)

Root node route -n output

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         158.184.27.1    0.0.0.0         UG    0      0        0 eth1
158.184.27.0    *               255.255.255.0   U     0      0        0 eth1
192.168.10.0    *               255.255.255.0   U     0      0        0 eth0

Common node ifconfig output:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:b3:ed:0e  
      inet addr:192.168.10.11  Bcast:192.168.10.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:5078 errors:0 dropped:2249 overruns:0 frame:0
      TX packets:1502 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:287740 (280.9 KiB)  TX bytes:179477 (175.2 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3590 (3.5 KiB)  TX bytes:3590 (3.5 KiB)

Common node route -n output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.10.10   0.0.0.0         UG    0      0        0 eth0
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0

Do you have any idea, how could I connect to the Internet from common node through the root node? I have very little knowledge of networking, so please, try to explain it in detail.


EDIT:

Considering Richard Neumann's answer, I enabled IP forwarding on the root node. And I think, that the root node already IS set as the default gateway (see Common node route -n output).

But the internet is still not working...


EDIT 2:

> traceroute 8.8.8.8
1 permonik0 (192.168.10.10) 0.972ms 0.957ms 0.922ms
2 * * *
...
30 * * *

EDIT 3:

I set NAT up according to this article and now I can even ping 8.8.8.8 successfully. But still, I can't ping any website, so it looks, there is some remaining DNS problem now.

2
  • @RichardNeumann I added the output into my question
    – Eenoku
    Sep 26 '17 at 14:55
  • I updated my answer. Sep 26 '17 at 15:05
3

If @Richard Neumann's answer did not work, there is a possibility of it being a DNS issue.

echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Set up IP Forwarding and Masquerading.

iptables -P FORWARD ACCEPT
iptables --table nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables --table nat --append POSTROUTING --jump MASQUERADE --source 192.168.10.10/24 
iptables-save > /root/clients.fw
echo "/sbin/iptables-restore < /root/clients.fw" >> /etc/rc.local

This above commands will enable IP Forwarding, and setup a firewall using iptables that allows you to access the internet from your client's.

8
  • Thank you, I added the line, but it still doesn't work...
    – Eenoku
    Sep 26 '17 at 14:59
  • What happens when you simply ping 8.8.8.8? @Eenoku Sep 26 '17 at 15:01
  • Ping doesn't work...
    – Eenoku
    Sep 26 '17 at 15:04
  • "Ping doesn't work" That does not help me at all. What does ping say? Sep 26 '17 at 15:05
  • Ok, I'm sorry :-) Ping hangs, like it can't connect the address.
    – Eenoku
    Sep 26 '17 at 15:06
2

Your root node will have to act as a router for the other nodes.

You'll need to enable IP forwarding, in your case for IPv4, on the router:

sysctl -w net.ipv4.ip_forward = 1

And to make it persistent, edit /etc/sysctl.conf and set:

net.ipv4.ip_forward=1

You'd probably also want to make the router the default gateway on the other nodes.

If the next hop beyond your router is not aware of the network 192.168.10.10/24, then you'll need to implement Network Address Translation (NAT).
Have a look at iptables and its MASQUERADE option.

For possible DNS issues, see @Hunter.S.Thompson's answer.

5
  • 1
    Just to add. Run "sysctl net.ipv4.ip_forward = 1" to make the change live and "sysctl -p /etc/sysctl.conf" to make the changes persistent after reboot. Sep 26 '17 at 14:27
  • sysctl -p loads the settings from sysctl.conf. Sep 26 '17 at 14:33
  • Thank you, I've made the changes and edited my question. But, it doesn't work yet
    – Eenoku
    Sep 26 '17 at 14:43
  • Could you, please, describe a little what do you mean by your last paragraph exactly?
    – Eenoku
    Sep 26 '17 at 15:14
  • Ok, NAT is set up, now I have a problem with DNS probably... I've edited my question...
    – Eenoku
    Sep 26 '17 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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