I messed up. I have two network cards in one machine and one in the second. I tried to connect two computers together by setting a static IP on two machines like this:
comp1:
sudo ip ad add 10.0.0.10/24 dev eth1
comp2:
sudo ip ad add 10.0.0.20/24 dev eth0
Where eth0
on comp1
was an outside line with ip 192.168.132.100
After I rebooted the comp1
I lost network connection and I cannot see the other computer comp2
.
Can someone give some advice on how to set this up?
UPDATE:
Let start from the begining:
Two computers comp1 and comp2
comp1 -> two network cards
eth0 and eth1
eth0 is an outside connection:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
Its IP is 10.140.20.20
eth1 is for cross computer connection:
auto eth1
iface eth1 inet static
address 10.10.0.0
netmask 255.255.255.0
gateway 10.140.20.20
dns-nameservers 10.140.20.20
comp2:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.10.0.1
netmask 255.255.255.0
gateway 10.140.20.20
dns-nameservers 10.140.20.20
I know that this is not working but could someone pleas explain why. I had some experience with this but years ago but it looks like I'm a newbe
UPDATE2:
Since for some reason I cannot add any more comments below you answers I am just add my progress here.
So I changed everything as you guys suggested and now I can see comp1
from comp2
and comp2
from comp1
and I can see net from comp1
but what I cannot see is the net from comp2
. I have enabled ipv4 forwarding but I believe there is a problem with my setup:
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
comp2:
auto eth0
iface eth0 inet static
address 10.10.0.20
netmask 255.255.255.0
gateway 10.10.0.10
So I think there needs to be a connection form eth1 to eth0 on my comp1 but I don't know how to set it up. Do I need to have a static IP on eth0 (comp1)?
When I add:
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
I can access outside network but when I try to download something to comp2 like geany
sudo aptitude install geany
I get:
Err http:// ....
Temporary faliour rsulting security.ubuntu.com