1

I've got two ubuntu PCs and one Android tablet. Android tablet tethers via usb with PC1. I'd like to connect the PC2 with PC1 so PC2 also becomes able to access the internet. Moreover it should also be possible for the Tablet to access both PCs (via ping for example). The setup should preferably use static IPs.

Tablet <---- (USB-Tethering) ---- PC1 <---- (Ethernet) ---- PC2

I managed to tether the tablet via USB with this PC1 /etc/network/interfaces configuration:

PC1:

auto usb0
iface usb0 inet static
   address 192.168.1.1
   network 192.168.1.0
   netmask 255.255.255.0

Here's my current setup for eth0: PC1

auto eth0
iface eth0 inet static
    address 192.168.2.1
    network 192.168.2.0
    netmask 255.255.255.0
    broadcast 192.168.2.255

PC2

auto eth0
iface eth0 inet static
   address 192.168.2.2
   network 192.168.2.0
   netmask 255.255.255.0
   broadcast 192.168.2.255

Is the setup of PC1 and PC2 so far correct? How do I link PC2 with the Tablet and therefore the internet?

ip forwarding is activated on PC1.

2
  • The part you posted looks fine, but it is only part of what you need to do. Can you add the changes you made to the routing table to the post?
    – Hennes
    Feb 18, 2014 at 10:57
  • I don't have any experience in setting up networks. This is why I haven't changed anything with the routing table. What changes should be made? Feb 18, 2014 at 11:03

1 Answer 1

0

If PC1 is now connected to the Internet, then the following commands will assure that PC2 is also connected to the Internet.

On PC1:

sudo iptables -t nat -A POSTROUTING -j MASQUERADE

On PC2:

sudo ip ro add default via 192.168.2.1 dev eth0

You must log in to answer this question.

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