Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I network two Ubuntu computers, so that they can "see" each other at an IP address?

share|improve this question
5  
What are your requirements? Do you use a router? –  nixnotwin Jan 23 '11 at 1:05
1  
what you want exactly, be more clear please edit your question :) –  aziz joh Jan 23 '11 at 15:55
1  
Do you have a crossover cable? en.wikipedia.org/wiki/Ethernet_crossover_cable –  Brandon Bertelsen Jul 16 '12 at 8:16

3 Answers 3

If you are using two computers with no router to connect them. To physically connect the computers you will either need a switch, a hub or a crossover cable(*). Then, you need to manually assign ip address in the same range.

In ubuntu this is simple right click on the network manager applet in the

  1. edit connections
    • wired tab
      • add
  2. put the mac address of the interface you will be configuring ifconfig command can show you what the mac address is.

    $ ifconfig
    eth0 Link encap:Ethernet HWaddr 00:30:1b:b9:53:94

HWaddr 00:30:1b:b9:53:94 = mac address

  1. Then click the ipv4 settings tab set method to manual.
  2. click add to add ip address

example for computer one would be

address  | netmask       | gateway   
10.0.0.1 | 255.255.255.0 |  
example for computer two would be  
10.0.0.2 | 255.255.255.0 | 

see if you can ping each other
from computer one.

$ ping 10.0.0.2  
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=0.457 ms

means everything is working.

(*) Most modern computers can use a normal cable instead of a crossover. Some old computers will require a crossover cable

share|improve this answer
    
I found this more reliable than command line method –  8128 Jul 16 '12 at 7:50
1  
Do you absolutely need a cross-over cable? –  Seanny123 Sep 5 '13 at 1:35
4  
I think most modern network cards are smart enough to detect whether a cross-over cable is being used or not. en.wikipedia.org/wiki/Medium_dependent_interface –  Seanny123 Sep 5 '13 at 1:51

command line example cause it is so quick and simple

On computer A

sudo ip ad add 10.0.0.10/24 dev eth0

On computer B

sudo ip ad add 10.0.0.20/24 dev eth0

To test from A to B

ping 10.0.0.20

To test from B to A

ping 10.0.0.10

Provided that a cable is connecting the two computers and the network interface on both of them is enabled and called eth0 this should work. The rest of this post is to help trouble shoot if there are problems.

10.0.0.xx is the ip address of the computers. /24 tells the computers that the last 8 bits of the 32 bit ip address can change. It is similar to saying netmask 255.255.255.0. This set ups the routes that the computer / network has available to it.

you should see some thing similar to this using

ip route
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.20

If you don't see some thing like above in the route table but see some thing like this when you use ip ad. You need add the address again using /24 subnet syntax.

ip ad
inet 172.16.1.40/32 scope global eth0

Notice the /32 which effectively is saying that is the only computer that exists on a network of one computer. Which is its self. Net mask 255.255.255.255. Hence no routes and the network does not work.

To find out which network interfaces you have and which are working

# ip ad
1: lo:  mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 46:fd:51:f9:f5:2e brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.186/24 brd 172.16.0.255 scope global eth0
    inet 172.16.1.10/24 scope global eth0
    inet 172.16.1.40/32 scope global eth0
    inet6 fe80::44fd:51ff:fef9:f52e/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1:  mtu 1500 qdisc noop qlen 1000
    link/ether 72:3f:92:eb:a4:cc brd ff:ff:ff:ff:ff:ff

If you need to delete an ip address cause you made a mistake

ip ad del 10.0.0.40/32 dev eth0 ip ad del 10.0.0.40/24 dev eth0

This will remove the routes as well as the ip address.

share|improve this answer
    
This worked initially, but seemed to be less reliable than the graphical method. –  8128 Jul 16 '12 at 7:50
    
This setup does not persist. It will be lost after a reboot. It is a simple and quick method to set up a working network connection between two computers. –  nelaar Oct 17 '12 at 7:23

Your question is not quite brief, I am going to assume you just want 2 Ubuntu computers in network.

Connecting 2 Ubuntu computers is easy enough, just get a Networking cable (Cat 5e Cross Cable) and connect both computers using that cable and Ubuntu should be able to get both of them an "Auto Eth" (Automatic IP) connection. This should be pretty much it to get 2 ubuntu computers in the network.

Later on If you want to see the Automatic IP assigned to the computer, run the command ifconfig or right click on the 'NetworkManager applet' and click on connection information

enter image description here

share|improve this answer
1  
I have tried this but the connection just goes crazy trying to connect and failing every time. What could the problem be? I have set the IPv4 method to "Shared with other computers" –  Wolter Hellmund Jan 28 '12 at 23:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.