Debian server – Setting a Default Gateway

To set up or change default gateway, you can use ip command, route command or you can manually edit /etc/network/interfaces file.

Option 1: ip command

ip route add default via

Option 2: route command

route add default gw

To delete the default route,

route del default gw

Option 3: Save routing information to a configuration file /etc/network/interfaces

Open /etc/network/interfaces file

nano /etc/network/interfaces

Find network interface and add the following option


Save changes and restart networking

/etc/init.d/networking restart

Other notes

In case you don’t have route command, you can get it via net-tools package.

sudo apt install net-tools

Leave a Reply

Your email address will not be published. Required fields are marked *