I'm kind of a novice for Ubuntu and trying to find a working solution for my problem. I have an external device with fixed IP 192.168.1.x connected through a switch and I need to have a TCP connection to this device. I am able to set up a static IP 192.168.1.x in the same subnet and successfully connect the device but then I cannot connect to internet.
At the moment my solution is to change with two connections but I would like to have this so that I can connect the device and web without changing the connection all the time while I am debugging the device and creating software.
I have tried to make an alias with a static IP for my network card but that results only to a solution in which I am able perhaps able to connect to web but not the device or not to connect anything. I changed the
/etc/network/interfaces as follows:
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`
Then I get the following result with
ifconfig after restarting the network:
enp0s31f6:0 Link encap:Ethernet HWaddr d4:81:d7:62:1f:d5
inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:16 Memory:dd500000-dd520000
route command gives:
I don't know if the problem is in the gateway or if the solution just doesn't work, with route, I also tried adding the gateway with:
sudo route add default gw 192.168.1.1 enp0s31f6:0
but that makes the internet connection not to work.
Then In addition I thought maybe bridging could do this, but I followed the instructions here https://help.ubuntu.com/lts/serverguide/network-configuration.html and couldn't get that working.
In addition I tried to add the route to my network connection but couldn't get that working either. I would greatly appreciate if someone could help me with this problem. I have been searching a solution for 2 days and I doubt that an easy solution exists.