0

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

And route command gives:

route command output

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.

6
  • What is your internet gateways IP? The 10.x.x.x? Have you tried to ping outside or just tried to open a webpage?
    – Ziazis
    Jun 8 '17 at 7:42
  • route add default gw 192.168.1.1 enp0s31f6 not sure what your :0 should accomplish?
    – Ziazis
    Jun 8 '17 at 7:48
  • I tried to ping outside and I'm able to do that as well open the pages when it works but I am not able to ping on the device unless I change a static ip address. And when I change a static ip, I cannot ping to the gateway 10.x.x.x. I thought that if the gateway of the alias for the network should be within the ip starting 192.168.1.x which I want to connect so that I would be able to connect that if I change the gateway. But really I don't know if it makes any sense, I am just guessing.
    – Pedro
    Jun 8 '17 at 11:55
  • Do you know how networks work in general, or did you just configure everything on a hunch on how it should be?
    – Ziazis
    Jun 8 '17 at 11:58
  • 1
    You have to use the same network to communicate with both. You can not use 192.168.x.x/24 and at the same time communicate with a 10.x.x.x/x network. You either have to use the 10.x.x.x network on the other client aswell or connect those via a router and add the router to your route as the next hop of the network 192.168. that you want to reach. Or connect them point to point/switch via an extra ethernet adapter and use that connection to communicate with that one client and use the other interface as your internet ethernet port.
    – Ziazis
    Jun 8 '17 at 12:37
0

I was able to solve the problem by making alias for my ethernet. It was just that I needed to add the original interface into /etc/network/interface followingly:

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 was that since originally my ethernet was not defined in the etc/network/interfaces and I didn't define it, the system lost it's connection to the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.