I use dhcp for my network connection but I need a static ip that is in the same address pool than the ip of a device I need to connect in the LAN. For this I have set up a network alias in /etc/network/interfaces as following:
auto enp0s31f6 iface enp0s31f6 inet dhcp auto enp0s31f6:0 iface enp0s31f6:0 inet static name Ethernet alias LAN card address 192.168.1.20 netmask 255.255.255.0 broadcast 192.168.1.255 network 192.168.1.0
My problem is that every time when I change the network (I take the laptop into different LAN) and I want to connect to Internet, I first need to uncomment the added text in /etc/network/interfaces, then I need to execute "sudo service network-manager restart". After this in the GUI connections there appears to be Wired connection 1 and enp0s31f6, the enp0s31f6 is chosen by default. When I choose the Wired connection 1, I can connect to Internet and that enp0s31f6 option disappears. After this I have to enable the uncommented part in /etc/network/interfaces and execute "sudo service networking restart" to enable the static ip again.
Now my question is that if there is another way to do this that I can change the network and my computer can find the ip automatically without this hassle?