How to establish ROS1 network between multiple machines
In ROS1, one machine/robot should serve as ROS Master whereas all the other machines/robots/devices in the same ROS network serve as ROS Clients. ROS Master can be a computer or a robot. The ROS Client can be a computer, a robot, or a device. The following is some steps to setup ROS1 network between multiple machines/robots/devices:
Step 1: To avoid a dynamic change of the IP addresses of all the machines to be connected, the IP addresses of all the machines should be set as static IPs. This can be done in two ways: 1) using GUI or 2) manual setup. The GUI can be found in Settings > Network. The manual setup of a static IP address can be performed as follows:
1 List all the network interfaces available in the computer by typing this command in the terminal:
1 |
ip a |
or:
1 |
ip link show |
The output will look like this:
1 2 3 4 |
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s3: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:2f:a4:ad brd ff:ff:ff:ff:ff:ff |
Notice the network interface you would like to provide a static IP address.
2 Open /etc/network/interfaces. It will look like this:
1 2 3 |
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback |
3 Add the static IP information of the network interface of interest. Let’s say you want to assign a static IP address to the network interface “enp0s3”, then the following lines should be added to /etc/network/interfaces:
1 2 3 4 5 6 |
auto enp0s3 iface enp0s3 inet static address 10.1.1.83 netmask 255.0.0.0 gateway 10.1.1.1 dns-nameservers 8.8.8.8 8.8.4.4 |
Step 2: Type in the bashrc file in every computer, which can be either a development computer or a robot computer:
1 2 |
export ROS_MASTER_URI = http://ip_of_master_computer:11311 export ROS_IP = ip_of_local_computer |
Alternatively, ROS_HOSTNAME can also be used instead of ROS_IP, so that it looks like this:
1 2 |
export ROS_MASTER_URI = http://ip_of_master_computer:11311 export ROS_HOSTNAME = hostname_of_local_computer |
ROS_MASTER_URI should be the same in all the computers because there is only one ROS Master in the ROS network. ROS_IP or ROS_HOSTNAME is the IP address or the hostname of the local computer, respectively. The IP address of a computer’s network card can be found by typing this command in the terminal:
1 |
ifconfig |
The output of this command will look like this:

Assuming that this computer is connected to the ROS network through Wifi, then the IP address is the one indicated under the “wlan0” entry, i.e. 10.25.0.128.
To find the hostname of a local computer, there are two ways: 1) looking at the hostname in /etc/hostname, or 2) looking at the hostname in an opened terminal; the hostname is what comes after @ in the terminal prompt. The hostname of a computer can be changed by opening /etc/hostname and changing the hostname in this file.
Step 3: List in /etc/hosts the IP addresses and the hostnames of all the computers (both the development computer and the robot’s computer(s)) and the devices that are expected to be connected in the ROS network.
Step 4: Test the connectivity by pinging other machines in the ROS network.