Debian – Add a Default Gateway

Below should the configuration steps for adding a default gateway to Debian.

root@host:~$ route add default gw [ip address] 

Note : Remember to add it (to survive a reboot) to your ‘/etc/network/interfaces’.
Add the following entry to required interface within the interface file – gateway [ip address]

Below is an example :

auto eth0
iface eth0 inet static
address 192.168.1.42
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1 

Rick Donato

Want to become a Linux expert?

Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial