Announcement

Collapse
No announcement yet.

set IPv4 default gateway for connection

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] set IPv4 default gateway for connection

    this sounds simple but I seem to have a persistent default gateway and I can't manage to change it. I have been using the laptop on my home network with no problems. But when I connect to the new network it uses the old default gateway and therefore can't see the correct nameserver. I have no access to the router.

    #2
    I would like to set the default gateway with the network connection editor if possible. But it seems that's not the case.

    Comment


      #3
      The default gateway (192.168.x.x) is set by the router manufacturer.
      Some routers, in the "DHCP Settings" option, allow you to change the "Device IP address", the device being the router, hence the gateway address. In that same dialog is usually the beginning IP address for dispensing and the concluding IP address for dispensing. I have mine set for 192.168.1.100 to 105, which allows all the internet devices to be attached, and no others. That dialog also typically allows the gateway mask to be set. Mine is 255.255.255.0 (/24), which fixes the first three octets. Also on that dialog (at least on mine) is the IP address lease time.

      If you don't have access to your router you cannot change any of these settings. My ISP has a web app which allows me to access my cable modem with the login name (usually "admin") and password, usually a long number. These are often found on the back, under the chassis between the box and its foot rest, or on the underside of the lid which requires you to remove it to see the login info.
      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
      – John F. Kennedy, February 26, 1962.

      Comment


        #4
        Wifi, wired?
        What 'new' network?
        A different location, or your home one has been changed?
        You can iirc only change the gateway if you set things up manually, instead of Automatic (DHCP)


        if it is wired, have you tried creating a new connection, maybe?
        If the new location is not using automatic addressing (DHCP) you may well have to ask whoever is in charge of the router/networking/IT department.

        Without knowing more details, it is harder to give advice.

        Comment


          #5
          it is WIFI and I have no access to the router people .. none. I don't know if it is using DHCP .. but I do know what the default gateway and the DNS server and search domain should be. I have configured these into the connection using IPv4 parameters in the connection manager. all that is left is to change the default gateway from 192.168.0.254 to 10.1.10.1 but I have not been able to do that yet. the default gateway can be checked using IP ROUTE.
          Last edited by ruthless; Jan 11, 2022, 12:05 PM.

          Comment


            #6
            Well, AFAIK, NetworkManager or systemd-neworkd handle that for you for WiFi unless you've set your connection to a fixed IP setup. This is set in /etc/netplan. My desktop, systemd-networkd with fixed IP contains:

            Code:
            # This file describes the network interfaces available on your system
            # For more information, see netplan(5).
            network:
              version: 2
              renderer: networkd
              ethernets:
                enp0s31f6:
                  dhcp4: no
                  dhcp6: no
            
            bridges:
              br0:
                interfaces: [enp0s31f6]
                addresses: [192.168.1.199/23]
                gateway4: 192.168.1.1
                nameservers:
                  addresses: [8.8.8.8,8.8.4.4]
              parameters:
                stp: true
                forward-delay: 4
              dhcp4: no
              dhcp6: no

            While my laptop has only:
            Code:
            # This file describes the network interfaces available on your system
            # For more information, see netplan(5).
            network:
              version: 2
              renderer: NetworkManager
            My server is more complicated...
            Last edited by oshunluvr; Jan 12, 2022, 05:38 PM.

            Please Read Me

            Comment


              #7
              my laptop has the same netplan code as yours. what confuses me is .. somewhere .. I believe the address 192.168.0.254 is hard coded. the network manager on the laptop is using this address as the default gateway for the WIFI connection. this was correct for my home network but does not work for the new public network I want to use. My question is: where is the laptop getting the 192.168.0.254 value from and why not from DHCP? I thought maybe I could override this value in the Network Manager nmconnection file .. but was not able to that either. Weird and frustrating.
              Last edited by ruthless; Jan 13, 2022, 07:01 AM.

              Comment


                #8
                What do you have in /etc/NetworkManager/system-connections/ ?

                Maybe just clearing it will allow it to resume normal operation,

                Please Read Me

                Comment


                  #9
                  Or how about adding this to your netplan file:

                  Code:
                    wifis:
                      wlp3s0
                        dhcp4: yes
                  Obviously, replace wlp3s0 with your wifi adapter name.

                  Please Read Me

                  Comment


                    #10
                    here is the system connection file. note the hardcoded DNS values which are correct. the DHCP is not working and I have zero communication with the router people.

                    [connection]
                    id=SSID
                    uuid=4461bd8e-ed13-48f2-9c4a-4da89923b198
                    type=wifi
                    permissions=user:ruthless:;

                    [wifi]
                    mac-address-blacklist=
                    mode=infrastructure
                    ssid=SSID

                    [wifi-security]
                    key-mgmt=wpa-psk
                    psk=********

                    [ipv4]
                    dns=75.75.75.75;
                    dns-search=hsd1.fl.comcast.net;
                    ignore-auto-dns=true
                    may-fail=false
                    method=auto

                    [ipv6]
                    addr-gen-mode=stable-privacy
                    dns-search=
                    method=auto

                    Comment


                      #11
                      https://forums.xfinity.com/conversat...375f08cde06033
                      "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
                      – John F. Kennedy, February 26, 1962.

                      Comment


                        #12
                        I just needed to put all my findings together to fix this. the DNS was done in the connection settings. the default via needed to be done on the command line. but this was lost every time the computer woke up. so I found documentation and wrote a service to call a script which fixed it. yes I am a developer but not much linux experience

                        Comment


                          #13
                          Originally posted by ruthless View Post
                          I just needed to put all my findings together to fix this....I found documentation and wrote a service to call a script which fixed it. yes I am a developer but not much linux experience
                          What documentation?
                          What service did you write?
                          What script?
                          Using Kubuntu Linux since March 23, 2007
                          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                          Comment


                            #14
                            it is a systemd service that calls a script that adds the correct default via gateway using the route command. the script uses nmcli to make sure which connection is active and not run on all connections. The IPv4 DNS server was added by editing the connection via connection manager. I wrote the script and the service.

                            the service looks like this. it calls the CONNECTION script in the home directory every time a WIFI connection is made .. which was needed when the laptop woke up after the lid being closed.

                            [Unit]
                            Description=connection service
                            Requires=network-online.target
                            After=network-online.target

                            [Service]
                            Type=oneshot
                            RemainAfterExit=yes
                            ExecStart=/home/CONNECTION.sh




                            Comment


                              #15
                              Thanks for posting your solution, it may help someone else someday.

                              Please Read Me

                              Comment

                              Working...
                              X