My scenario is:
host1
has internet connection through interfaceeth0
;host1
dial uphost2
and establishes a PPP connection with it;host2
has no internet access;host1
needs to share internet connection withhost2
using this interfaceppp0
;
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 callshost2
;- on
host1
I can do whathever I want, howeverhost2
has a read-only file system, I can only add routes and change minor stuff;