1

My scenario is:

  • host1 has internet connection through interface eth0;
  • host1 dial up host2 and establishes a PPP connection with it;
  • host2 has no internet access;
  • host1 needs to share internet connection with host2 using this interface ppp0;

So, I think that basically we have this:

(internet) <eth0> === host1 === <ppp0> === host2

This is from host1:

# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 7409  bytes 29789661 (28.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5933  bytes 422162 (412.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 28  bytes 2352 (2.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 28  bytes 2352 (2.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.100.0.2  netmask 255.255.255.255  destination 10.100.0.1
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 5  bytes 78 (78.0 B)
        RX errors 2  dropped 0  overruns 0  frame 0
        TX packets 5  bytes 90 (90.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

This is from host2:

# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0

ppp0      Link encap:Point-to-Point Protocol
          inet 10.100.0.1  P-t-P: 10.100.0.2 Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
          RX packets:5 errors:1 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3

I tried to use iptables to forward the traffic between interface, as suggested here.

In host2 I added default route for dev ppp0 using gw 10.100.0.2, which is that ip of host1.

Any suggestion? I am really not used to networking techniques.

I think the most important remarks are:

  • host1 is the one that calls host2;
  • on host1 I can do whathever I want, however host2 has a read-only file system, I can only add routes and change minor stuff;
Thiago Melo
  • 111
  • 1
  • 5

1 Answers1

1

This set up is some how tricky :

If host1 was the one acting as ppp server then the problem would be easy to solve. Just configure the ppp daemon to push a default route to the client

But since host1 is the one calling host2 I don't see how host1 could push a default route (and setting this manually is not really acceptable) unless ...

For me the solution is to use a routing protocol process (rip or ospf) so that when to link is up these processes agree on an adequate routing tables

Finally the NAT has to include all the used IP ranges in order to reach the Internet

  • Hi @Soulimane, thanks for your answer. I am starting to realize this is definitely a tricky set up as you pointed out, lucky me :) ... Say I could set the default route manually, something like `route add default gw 10.100.0.2 ppp0` (which I can since I have physical access to `host2` for now), what else should I do? It seems to be not enough. Thanks for telling me about rip and pspf, I will give a check on them. – Thiago Melo Mar 10 '19 at 19:41
  • 1
    If you choose to set the default route manually each time you bring the ppp link up (which is not at all convenient), you have to add a route for ``10.100.0.0/32`` to you Internet router and NAT this subnet as well – Soulimane Mammar Mar 10 '19 at 22:26