How to Add or Change the Default Port on Linux

The default gateway is the router's IP address. Normally, the connection port will be automatically discovered by the operating system during the installation process, but you may need to change it, especially in cases where the computer has many adapters or routers on the network. .

Use Terminal

Picture 1 of How to Add or Change the Default Port on Linux

Open the Terminal application. You can open Terminal from the sidebar, or press Ctrl+ Alt+ T.

Picture 2 of How to Add or Change the Default Port on Linux

View the current default gateway. You can check which default gateway is installed by typing routeand pressing ↵ Enter. The address next to the word "default" is your default gateway and the interface to which it is assigned will be displayed on the right side of the table.

Picture 3 of How to Add or Change the Default Port on Linux

Delete the current default gateway. If the computer has multiple default ports set up, connection conflicts may occur. If you want to change your router's current IP address, you should delete it first.

Enter command . For example, to delete the default gateway 10.0.2.2 on the routersudo route delete default gw IP Address Adaptereth0, you type sudo route delete default gw 10.0.2.2 eth0.

Picture 4 of How to Add or Change the Default Port on Linux

Enter command. . For example, if you want to change the IP address of your routersudo route add default gw IP Address Adaptereth0to 192.168.1.254, type sudo route add default gw 192.168.1.254 eth0. You will be asked to enter your user password to complete the command.

Edit configuration file

Picture 5 of How to Add or Change the Default Port on Linux

Open the configuration file with an editor. Type the command sudo nano /etc/network/interfacesto open the file in Nano software. Editing system files will preserve your changes every time your computer restarts.

Picture 6 of How to Add or Change the Default Port on Linux

Navigate to the appropriate section. Find the section about the router whose IP address you want to change. For a wired connection, a router is usuallyeth0.

Picture 7 of How to Add or Change the Default Port on Linux

More . into this section. For example, type to set the default gateway to 192.168.1.254.gateway IP Addressgateway 192.168.1.254

Picture 8 of How to Add or Change the Default Port on Linux

Save your changes and exit. Press Ctrl+ Xthen press key Yto save changes and exit.

Picture 9 of How to Add or Change the Default Port on Linux

Restart the network. Restart your network by typing the command sudo /etc/init.d/networking restart.

Update 26 October 2023
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile