Hi guys I connect to the internet using one of the following methods:
1. LAN cable 2. Tethering to a mobile phone using a USB cable 3. Wireless (4 different wireless networks) Based on the result of ip addr show my wireless interface is called wlo1 The contents of /etc/network/interfaces are # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface #auto lo #iface lo inet loopback There are three files in /etc/network/interfaces.d/ depending on how I connect to the internet. They are: a. lan b. usb0 c. wlo1 The contents of lan are: # The primary network interface (connect to internet using a LAN cable) allow-hotplug enx6 iface enx6 inet static address 192.168.1.38/24 gateway 192.168.1.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 1.1.1.1 8.8.8.8 The contents of usb0 are: # The primary network interface (tethering to mobile phone using a USB cable) allow-hotplug usb0 iface usb0 inet dhcp address 192.168.30.70 gateway 192.168.30.129 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 1.1.1.1 8.8.8.8 The contents of wlo1 are: # The primary network interface (connect to wireless network #1) #allow-hotplug wlo1 #iface wlo1 inet dhcp # wpa-ssid wireless-network-1 # wpa-psk {string of alphanumeric characters} # address 192.168.22.85 # gateway 192.168.22.1 # dns-nameservers 1.1.1.1 8.8.8.8 # The primary network interface (connect to wireless network #2) allow-hotplug wlo1 iface wlo1 inet dhcp wpa-ssid wireless-network-2 wpa-psk {string of alphanumeric characters} address 192.168.15.27 gateway 192.168.15.1 dns-nameservers 1.1.1.1 8.8.8.8 # The primary network interface (connect to wireless network #3) #allow-hotplug wlo1 #iface wlo1 inet dhcp # wpa-ssid wireless-network-3 # wpa-psk {string of alphanumeric characters} # address 192.168.51.45 # gateway 192.168.51.1 # dns-nameservers 1.1.1.1 8.8.8.8 # The primary network interface (connect to wireless network #4) #allow-hotplug wlo1 #iface wlo1 inet dhcp # wpa-ssid wireless-network-4 # wpa-psk {string of alphanumeric characters} # address 192.168.70.31 # gateway 192.168.70.1 # dns-nameservers 1.1.1.1 8.8.8.8 For example when I wish to connect to wireless-network-3, I ensure that all the lines after # The primary network interface (connect to wireless network #2) commented with a # And I remove the # from all the lines after # The primary network interface (connect to wireless network #3) I save the changes and type the commands: sudo ifdown wlo1 && sudo ifup wlo1 Questions I. Depending on how I connect to the internet, I create a file each called lan, usb0 and wlo1 and place them in /etc/network/interfaces.d. Is there a neater way of doing it? 2. In the file called wlo1, I have four parts that correspond to the four different wireless networks. is there a neater way of doing it? Best regards. Stella