Home » Linux, OS Concepts and Networking » Linux Networking » How to setup Local Area Network (LAN) using switch on Ubuntu ?

How to setup Local Area Network (LAN) using switch on Ubuntu ?

Setting up LAN using switch is required if we don’t have the router but still we want to share the internet / network available on one PC to other PC’s.

In the below block diagram, we tries to show how do we connect the hardware. i.e. PC on which network is accessible, switch and other PC’s where we want the network to be setup.

To manually set your network settings:

The below steps to be followed on the pc which is going to share internet to switch (sharing PC).

  1. Click the network menu on the menu bar and click Edit Connections.
  2. Select the network connection that you want to set up manually. For example, if you plug into the network with a cable, look at the Wired tab.
  3. The system sharing settings should be as shown in the figure 1.
Figure 1: Settings of internet sharing system.

After the above step obtain the IP address from the Terminal using command ifconfig.

$ ifconfig

FIG2: IP address of the machine 10.42.0.1 and mask as 255.255.255.0

The Below steps to be carried out on the machines connected to switch which are shown as local user in block diagram.

1. Click the connection you want to edit to select it, then click Edit.

2.  Go to the IPv4 Settings tab and change the Method to Manual.

3.  Click Add and type the IP address, network mask and default gateway IP address into the    corresponding columns of the Addresses list. Press Enter or Tab after typing each address.

4.  These three addresses must be IP addresses; that is, they must be four numbers separated by periods (e.g., 123.45.6.78).

Fig: Manual settings in the user systems adding IP address.

Use the command line in terminal to change IP address and netmask.

$ sudo ifconfig eth0 <IP>  netmask 255.255.255.0

Even we can use the following command to add Gateway.

$ sudo route add default gw <IP address>

5.   Click Save. If you are not connected to the network, click the network icon on the menu bar and connect. 

Run command ifconfig to obtain details.

Fig: IP address of the local user systems after following above steps.

6.Test the network settings by trying to visit a website or look at shared files on the network, for example.

The connection can be confirmed using the ping command.

$ ping 8.8.8.8
pfSense VMWare ESXi Installation an...
pfSense VMWare ESXi Installation and Basic Wizard Configuration

Leave a Comment

Sign up to our newsletter!