Configuring network settings on Ubuntu – ONLYOFFICE

Viewing current settings

To view your current network parameters via the Terminal, you can use the following command:

ifconfig -a

It shows all the network interfaces (active and inactive) available on your machine and their parameters. You’ll see something like this:

eth0      Link encap:Ethernet  HWaddr 08:00:27:55:16:78 
          inet6 addr: fe80::a00:27ff:fe55:1678/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:92781 errors:0 dropped:11141 overruns:0 frame:0
          TX packets:13852 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24520116 (24.5 MB)  TX bytes:2543425 (2.5 MB)
 

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4433 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4433 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:453972 (453.9 KB)  TX bytes:453972 (453.9 KB)

eth0 – is your Ethernet adapter, where 0 – is its number.

lo (Local Loopback) – is used to establish a network connection to this machine (127.0.0.1), it does not require additional configuration.

To display the settings of a certain interface, use the ifconfig eth0 command, where eth0 is an interface name.

The ifconfig command also allows to configure the network settings, but the changes made in such a manner, will be reset to default when you restart your machine, so you can use them to temporarily configure the network for testing purposes. For example, you can use the following command to specify the primary IP address and netmask for the eth0 interface:

sudo ifconfig eth0 192.168.3.202 netmask 255.255.248.0 up
Configuring settings

To make the settings persistent, you need to change the network interfaces configuration file located at /etc/network/interfaces

Open it in a text editor:

sudo nano /etc/network/interfaces

Your network interface is currently set for using DHCP, when the network addresses are being assigned automatically by a DHCP server. You can see the following settings for a dynamic IP:

auto eth0
iface eth0 inet dhcp

To set a static IP for the network interface, replace the ‘dhcp’ value with the ‘static’ one and add some other parameters so that the configuration will look like this:

auto eth0
iface eth0 inet static
address 192.168.3.202
netmask 255.255.248.0
gateway 192.168.3.1
dns-nameservers 192.168.3.3 192.168.3.4

where:

  • auto eth0 – specifies that the network interface eth0 should start as the system boots
  • iface eth0 inet static – – specifies that the static IP address is used for the network interface eth0
  • address – specifies the IP address assigned to the network interface
  • netmask – specifies, which part of the IP address corresponds to the local network address, and which part corresponds to the machine address
  • gateway – specifies the IP address of the device which forwards traffic from the local network to all other remote networks
  • dns-nameservers – specifies the IP addresses of the DNS servers that your machine should query (several addresses must be separated by a space)

Save the changes (for nano, Ctrl+X → Y → Enter).

Once you have changed the configuration file, you need to restart the network interface with the following command:

sudo ifdown eth0 && sudo ifup eth0

To verify if your machine can connect to a network, try to reach an IP address of a computer on your local network, or an IP address/hostname of a remote host using the ping command:

ping 192.168.3.51