How can I network two Ubuntu computers, so that they can "see" each other at an IP address?
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 You need to do this on both computers
- edit connections
- wired tab
- wired tab
put the mac address of the interface you will be configuring. The ifconfig command can show you what the mac address is:
$ ifconfig eth0 Link encap:Ethernet HWaddr 00:30:1b:b9:53:94
2.1. On newer version of Linux the network card names have changed.
enp1s0. Look for some thing with similar names to
enbeing ethernet /
$ ip a l 2: enp1s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether 98:e7:f4:5d:59:90 brd ff:ff:ff:ff:ff:ff 3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 84:ef:18:7b:cd:39 brd ff:ff:ff:ff:ff:ff
HWaddr 00:30:1b:b9:53:94 = mac address
link/ether 84:ef:18:7b:cd:39 = mac address
- Then click the ipv4 settings tab. set method to manual.
- click add to add IP address on both Computer A and B.
example for computer A
address | netmask | gateway 10.0.0.1 | 255.255.255.0 |
example for computer B
address | netmask | gateway 10.0.0.2 | 255.255.255.0 |
see if you can ping each other
from computer A.
$ 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
from computer B.
$ ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: 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
command line example cause it is so quick and simple.
On newer version of Linux the network card names have changed.
enp1s0. Look for something with similar names to
en being ethernet /
wl being wireless.
$ ip a l 2: enp1s0: 3: wlp2s0:
You would need to update the below command to use different
dev enp1s0 etc.
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
To test from B to A
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
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.
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.
Pick one of the computers to be the server. If one computer has a connection to the Internet use that as the server.
On the server click the network indicator and chose
Edit Connections. Select the Ethernet connection then click the
Edit button. Go to the
IPv4 tab and change
Automatic (DHCP) to
Shared to other computers.
Connect the two computers together using an Ethernet cable. The second computer will get assigned an IP address from the server and get access to the Internet.
If you have old hardware you may need to make sure the Ethernet cable is a crossover cable. Modern hardware automatically does the crossover.
Tested on Ubuntu 14.04 LTS.
Below is a reprise of nelaar's answer, updated for Ubuntu 14.04.
In order to connect two computers without a router, you will need one of the following:
- A standard Ethernet cable, which should work with most modern hardware, or
- An Ethernet crossover cable, in lieu of a modern NIC, or
- A simple Ethernet hub (and two Ethernet cables).
In Ubuntu 14.04 LTS
You will need to manually assign IP address in the same range. The following steps assume you are using the standard Unity interface. Repeat these steps for each computer.
- Click the Network indicator on the Unity panel (top right).
- From the drop-down, select Edit Connections...
- In the Network Connections dialog box, click the Add button.
- When prompted to choose a connection type, choose Ethernet, and click the Create... button.
- Name your connection "Direct to [other hostname]" to differentiate from a typical Ethernet connection.
- In the Device MAC address drop-down, select the one corresponding to the interface you plan to use.
- Switch to the IPv4 Settings tab.
- Change the Method to Manual.
- click the Add button to add an IP address.
- Example settings for Computer #1:
- Address: 10.0.0.1
- Netmask: 255.255.255.0
- Example settings for Computer #2:
- Address: 10.0.0.2
- Netmask: 255.255.255.0
- Example settings for Computer #1:
Once that's set up, and the computers are wired together, try pinging each other.
user@computer1:~$ ping 10.0.0.2
The output should look something like this:
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
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
protected by Community♦ Mar 15 '18 at 11:38
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?