Cannot set gateway with 2 interfaces (1 only connected to printer)

Forum Forums General Hardware Cannot set gateway with 2 interfaces (1 only connected to printer)

  • This topic has 8 replies, 4 voices, and was last updated May 30-3:04 am by Dave.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #107692
    Member
    Fientje

      I’m running AntiX 22 32-bit on a system with 3 network interfaces (2 wires, 1 wireless). Connman is used to setup the network. One wired interface is connected to a printer only, the wireless connection is used for network/internet access. But I cannot get any default gateway set as soon as I bring up the wired interface (so internet access is not possible).

      The first wired interface (eth0) is not connected.

      The second wired interface (eth1) is connected to a network printer (fixed at 192.168.0.31) with a cross cable. The IPv4 settings are static:
      IP: 192.168.0.100
      Netmask: 255.255.255.0
      No gateway/DNS

      The wireless interface (wlan0) is used for network and internet access. The IPv4 settings are get by DHCP:
      IP: 192.168.117.95
      Netmask: 255.255.255.0
      Gateway: 192.168.117.52
      DNS: 192.168.117.51

      I can print to the printer without problems and can access the local network, but not internet because there’s no gateway set. I even have tried to set the wlan0 to static and input the gateway manually. But it blanks out as soon as I turn on eth1.

      If I turn off eth1, the gateway will appear automatically and internet access restores. But then I cannot use the printer.

      How can I have both interfaces turned on and keep a working gateway setting?

      I’ve added the Inxi system information.

      Attachments:
      #107705
      Member
      Robin

        Please let us see the output of the command:

        route

        entered from within a console window, e.g. roxterm. I guess the default route is set wrongly. Maybe you need to assign two different subnet ranges to the two interfaces, so they won’t conflict. You can try to use any other private networking segment for one of the interfaces, e.g. addresses in the range from 172.16.0.0 to 172.31.255.255 or from 10.0.0.0 to 10.255.255.255 for the direct printer connection via eth0, while keeping the adresses in the range from 192.168.0.0 to 192.168.255.255 for internet and LAN access managed by your router via the other networking interface wlan0 (or vice versa).

        You can manually reassign the routes for each interface by route add and route delete commands. See man route for details.

        Windows is like a submarine. Open a window and serious problems will start.

        #107754
        Member
        Fientje

          This is the output of “route”:

          $ route
          Kernel IP routing table
          Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
          0.0.0.0         0.0.0.0         255.255.255.255 UH    0      0        0 eth1
          default         0.0.0.0         0.0.0.0         U     0      0        0 eth1
          192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
          192.168.117.0   0.0.0.0         255.255.255.0   U     0      0        0 wlan0
          192.168.117.52  0.0.0.0         255.255.255.255 UH    0      0        0 wlan0

          The printers IP is fixed and cannot be changed by me. And I also cannot change the network, this PC is not the only device, I can’t mess with the whole network including 2 servers, just to get this device working.

          #107790
          Member
          Robin

            This is the problematic line:

            default         0.0.0.0         0.0.0.0         U     0      0        0 eth1
            

            As you can see the default route sits on eth1 for some strange reason, even when the printer should not provide any gateway propagation by dhcp. You can try something like this to fix it:

            sudo route delete default
            sudo route add default gw 192.168.117.52 wlan0

            Wherein 192.168.117.52 must match your actual Router IP address under which it is available in your LAN.
            Check out whether this makes already work both.

            The printers IP is fixed and cannot be changed by me.

            This is pretty unlikely. It would mean you can’t use two of these printers in your LAN.

            You may run into issues, since your router won’t know about the private IP 192.168.0.31 of your printer on the eth1 interface. So it can happen the router assigns this address to some other network device, causing the address to be present twice then. Also the router might answer when asked, that the device is not available (since he can’t know about it), causing you can’t print. For a clean solution you actually should use different network segments for the two networking interfaces.

            But you might get away with bridging the interfaces so the router is aware of the printer connected to the other network interface. For details about network bridging please read:
            http://web.archive.org/web/20190505173235/www.linux.com/news/what-can-you-do-second-ethernet-port

            Windows is like a submarine. Open a window and serious problems will start.

            #107835
            Member
            Fientje

              The commands work, but only for a short amount of time:

              $ route
              Kernel IP routing table
              Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
              0.0.0.0         0.0.0.0         255.255.255.255 UH    0      0        0 eth1
              default         _gateway        0.0.0.0         UG    0      0        0 wlan0
              default         0.0.0.0         0.0.0.0         U     0      0        0 eth1
              192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
              192.168.117.0   0.0.0.0         255.255.255.0   U     0      0        0 wlan0
              _gateway        0.0.0.0         255.255.255.255 UH    0      0        0 wlan0

              After some time the internet access goes away and the route output is changed back automatically to what was not working.

              The printers IP can be changed with a (Windows-only) tool from the manufacture which I don’t have. And the router doesn’t need to see the printer. Normally it should not as the printer is only connected with a crosscable directly to eth1. It’s a thermal printer integrated in an panel PC, so there won’t be two of them in a network.

              #107851
              Forum Admin
              Dave

                I am not too familiar with connman or how complicated of a network configuration it can handle. It should be configurable via /var/lib/connman/settings in a fashion similar to this IPv4 = 192.168.1.42/255.255.255.0/192.168.1.1 or address/netmask/gateway. Though I am not sure how to set the preferred gateway other than changing the “preffered technology” setting in /etc/connman/main.conf to wifi,ethernet; though that seems like a poor way.

                Instead if I were in your situation I would consider switching to ceni and using it or directly editing /etc/network/interfaces. There is a utility in the control centre for switching from the default connman to ceni under network called select wifi application (which I think should be named select network application to be more accurate as to what it does). Once switched try running ceni to see if it works for your configuration leaving the printer interface gateway as 0.0.0.0.

                Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

                #107887
                Member
                stevesr0

                  Hi Fientje,

                  Sorry for a noobie question.

                  Do you connect to the internet thru a router?

                  stevesr0

                  #108017
                  Member
                  Fientje

                    I tried the “preferred technology” method by adding “PreferredTechnologies = wifi,ethernet” to /etc/connman/main.conf and it does work. But this should not be needed… what if it was both ethernet interfaces?

                    Does Ceni also auto-connect wifi at boot-up? I remember from a older AntiX version that it doesn’t.

                    Yes, I use a router. Otherwise I can’t have internet access on multiple devices with only one public IP-address.

                    #108019
                    Forum Admin
                    Dave

                      Yes I believe ceni does auto connect. If I recall correctly this requires checking auto instead of allow-hotplug in the ip address portion of the setup or something similar to that.

                      Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • You must be logged in to reply to this topic.