1

I have recently messed up my network in the attempt to connect two computers using network cards so that comp1 has an access to the internet directly and comp2 uses the comp1 to do the same thing.

General scheme is this:

comp2(eth0)  -> comp1(eth1)  
                comp1(eth0) -> switch -> network  

I mixed up comp1 and com2 (thnx Jos)
My interfaces look like this:

comp1:

auto lo  
iface lo inet loopback  

auto eth0  
iface eth0 inet dhcp  

auto eth1  
iface eth1 inet static  
address 10.10.0.10  
netmask 255.255.255.0  
up/sbin/iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -d 0/0 -j MASQUERADE 

comp2:

auto eth0  
iface eth0 inet static  
address 10.10.0.20  
netmask 255.255.255.0  
gateway 10.10.0.10  

Computers see each other. comp1 can see outside network:

ping 8.8.8.8   

works. As comp2 does. But when I try to download stuff on comp2 I get error:

sudo aptitude install geany   

Err http:// ....
Temporary failure resulting security.ubuntu.com

Could someone please help me setup this last bit??
My original question is here
I apologize if this is considered spamming or something negative

1
  • I believe that at the start of your question, you mixed up comp1 and comp2, so that according to the "General scheme" section comp2 is the one with the direct internet access, not comp1.
    – Jos
    Nov 19, 2013 at 9:51

1 Answer 1

1

On comp1, remove the iptables command from /etc/network/interfaces and then run the following:

sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sudo iptables -t nat -A POSTROUTING -o eth0 -s 10.10.0.0/24 -j MASQUERADE
sudo echo "@reboot root iptables -t nat -A POSTROUTING -o eth0 -s 10.10.0.0/24 -j MASQUERADE" >> /etc/crontab

===============

On comp2, run the following

sudo ip route del default
sudo ip route add default via 10.10.0.10

At this point, comp2 should be able to access the internet. If it can, there is one more change you need to make on comp2 so that these changes will persist after reboots. There is a file at either /etc/dhcp/dhclient.conf or /etc/dhcp3/dhclient.conf with a line that starts with 'request'. Remove the word 'routers' from this line and add 'default routers 10.10.0.10;' to the bottom of the file.

Then run:

sudo /etc/init.d/networking restart

You must log in to answer this question.

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