How To Add Or Change The Default Gateway In Linux - WikiHow

Skip to ContentQuizzes
  • Home
  • Random
  • Browse Articles
  • Quizzes & Games
  • All QuizzesHot
  • Love Quizzes
  • Personality Quizzes
  • Fun Games
  • Dating Simulator
  • Learn Something New
  • Forums
  • Courses
  • Happiness Hub
  • Explore More
  • Support wikiHow
  • About wikiHow
  • Log in / Sign up
Terms of Use wikiHow is where trusted research and expert knowledge come together. Learn why people trust wikiHow How to Add or Change the Default Gateway in Linux PDF download Download Article Explore this Article parts 1 Using the Terminal 2 Editing Your Configuration File Other Sections Questions & Answers Video Related Articles References Article Summary Author Info

Last Updated: July 22, 2023

PDF download Download Article X

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 14 people, some anonymous, worked to edit and improve it over time. This article has been viewed 1,168,910 times. Learn more...

If you need to find or change the IP address of your default gateway or router on Linux, you're in luck—it's super easy to do. This wikiHow article will show you how to use the route command to find the default gateway IP address on Linux, and how to set a new default gateway in your /etc/network/interfaces configuration file.

Steps

Part 1 Part 1 of 2:

Using the Terminal

PDF download Download Article
  1. Step 1 Open the Terminal. 1 Open the Terminal. You can open the Terminal from the side bar, or by pressing Ctrl+Alt+T.[1]
  2. Step 2 View your current default gateway. 2 View your current default gateway. You can check what your default gateway is set to by typing route and pressing Enter. The address next to "default" shows your default gateway, and the interface it is assigned to is displayed on the right side of the table. Advertisement
  3. Step 3 Delete your current default gateway. 3 Delete your current default gateway. If you have more than one default gateway set, you'll run into connection conflicts. Delete your existing default gateway if you intend to change it.
    • Type sudo route delete default gw IP Address Adapter. For example, to delete the default gateway 10.0.2.2 on the eth0 adapter, type sudo route delete default gw 10.0.2.2 eth0.
  4. Step 4 Type . 4 Type .sudo route add default gw IP Address Adapter. For example, to change the default gateway of the eth0 adapter to 192.168.1.254, you would type sudo route add default gw 192.168.1.254 eth0.[2] You'll be prompted for your user password in order to complete the command.
  5. Advertisement
Part 2 Part 2 of 2:

Editing Your Configuration File

PDF download Download Article
  1. Step 1 Open the configuration file in an editor. 1 Open the configuration file in an editor. Type sudo nano /etc/network/interfaces to open the file in the nano editor. Editing your configuration file will keep your changes every time the system restarts.[3]
  2. Step 2 Navigate to the correct section. 2 Navigate to the correct section. Find the section for the adapter you want to change the default gateway for. For a wired connection, this is usually eth0.
  3. Step 3 Add . 3 Add .gateway IP Address to the section. For example, type gateway 192.168.1.254 to make the default gateway 192.168.1.254.[4]
  4. Step 4 Save your changes and exit. 4 Save your changes and exit. Press Ctrl+X and then Y to save your changes and exit.
  5. Step 5 Restart your network. 5 Restart your network. Restart your network by typing sudo /etc/init.d/networking restart.[5]
  6. Advertisement

Community Q&A

Search Add New Question
  • Question Will the admins know if I change my IP? Community Answer Community Answer Yes, if they chose to check. Thanks! We're glad this was helpful. Thank you for your feedback. If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow Yes No Not Helpful 3 Helpful 10
Ask a Question 200 characters left Include your email address to get a message when this question is answered. Submit Advertisement

Video

Tips

Submit a Tip All tip submissions are carefully reviewed before being published Name Please provide your name and last initial Submit Thanks for submitting a tip for review!

You Might Also Like

Assign an IP Address on a Linux ComputerHow toAssign an IP Address on a Linux Computer Access a Linksys RouterHow toAccess a Linksys Router Disable Ipv6 on LinuxHow to Disable IPv6 on Linux Configure a Static Internet Protocol (IP) Address on a ComputerHow to Configure a Static Internet Protocol (IP) Address on a Computer Enable IP Routing on CiscoEnable & Configure IP Routing on Cisco Routers & Switches Set up a Network in UbuntuHow toSet up a Network in Ubuntu Set Up Port Forwarding on a RouterHow to Do Port Forwarding on Any Router: Easy Guide Find Your Router's IP AddressHow to Find Your Router's IP Address: Mobile, PC, Mac, Chromebook, & Linux Change MAC Address on UbuntuHow toChange MAC Address on Ubuntu Set up a Wireless Network in LinuxHow to Set Up a Wireless Network in Linux: Terminal & GUI Disable Router FirewallHow toDisable Router Firewall Find Your Subnet MaskHow to Find Your Subnet Mask: The Complete Guide Check the IP Address in LinuxHow toCheck the IP Address in Linux Access a RouterAccess Your Router: Easy Steps to Log In & Change Settings Advertisement

References

  1. https://linuxhint.com/how-to-open-ubuntu-terminal-keyboard-shortcuts/
  2. https://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/
  3. https://help.ubuntu.com/community/NetworkConfigurationCommandLine
  4. https://help.ubuntu.com/community/NetworkConfigurationCommandLine
  5. https://help.ubuntu.com/community/NetworkConfigurationCommandLine

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 14 people, some anonymous, worked to edit and improve it over time. This article has been viewed 1,168,910 times. How helpful is this? Co-authors: 14 Updated: July 22, 2023 Views: 1,168,910 Categories: Linux | Networking Hardware Article SummaryX

1. Open a terminal window. 2. Type "sudo route delete default gw (IP) (Adapter)" and press Enter. 3. Type "sudo route add default gw (IP) (Adapter)" and press Enter. 4. Open /etc/network/interfaces in a text editor. 5. Update the gateway IP address for the adapter. 6. Save your changes and exit the editor. 7. Type "sudo /etc/init.d/networking restart" and press Enter. Did this summary help you?YesNo

In other languages Spanish Portuguese Italian Russian Indonesian Dutch French Chinese Thai Vietnamese German Turkish Korean Hindi Japanese
  • Print
  • Send fan mail to authors
Thanks to all authors for creating a page that has been read 1,168,910 times.

Is this article up to date?

Yes No Advertisement Cookies make wikiHow better. By continuing to use our site, you agree to our cookie policy.

About This Article

Click a star to vote Co-authors: 14 Updated: July 22, 2023 Views: 1,168,910

Quizzes & Games

How Will I Die QuizHow Will I Die QuizTake QuizGuess the Language QuizGuess the Language QuizTake QuizWhat's My Religion QuizWhat's My Religion QuizTake QuizWhat Kind of Minecraft Player Am I QuizWhat Kind of Minecraft Player Am I QuizTake QuizLeetspeak Translator & GeneratorLeetspeak Translator & GeneratorGenerateHow Good Are My Survival Instincts QuizHow Good Are My Survival Instincts QuizTake Quiz

You Might Also Like

Assign an IP Address on a Linux ComputerHow toAssign an IP Address on a Linux ComputerAccess a Linksys RouterHow toAccess a Linksys RouterDisable Ipv6 on LinuxHow to Disable IPv6 on LinuxConfigure a Static Internet Protocol (IP) Address on a ComputerHow to Configure a Static Internet Protocol (IP) Address on a Computer

Featured Articles

Remove Shorts from Search Results on YouTubeHow toRemove Shorts from Search Results on YouTubeWhat Are the Korean Animal Face Types? (And Which Type Do You Have?)What Are the Korean Animal Face Types? (And Which Type Do You Have?)Being the Little Spoon While Cuddling: Is It Better Than the Big Spoon?Being the Little Spoon While Cuddling: Is It Better Than the Big Spoon?115+ Funny “Get Well Soon” Messages to Make Someone Laugh115+ Funny “Get Well Soon” Messages to Make Someone Laugh110+ “Fun Facts” for Interviews, Introductions, & Icebreakers110+ “Fun Facts” for Interviews, Introductions, & IcebreakersHow Long Would You Survive In A Zombie Apocalypse?How Long Would You Survive In A Zombie Apocalypse?

Trending Articles

Am I Chopped QuizAm I Chopped QuizCrush Calculator: Does Your Crush Like You Back?Crush Calculator: Does Your Crush Like You Back?What Does “Eat Zucchini” From KATSEYE Mean?What Does “Eat Zucchini” From KATSEYE Mean?How Rare Is My Birthday QuizHow Rare Is My Birthday QuizAm I a Pick Me Girl QuizAm I a Pick Me Girl QuizWhat Is the I Found a Leaf Relationship Test on TikTok?What Is the I Found a Leaf Relationship Test on TikTok?

Featured Articles

 Roast Someone in a Rap Battle (Plus the Best Bars of All Time)How to Roast Someone in a Rap Battle (Plus the Best Bars of All Time)What Turns a Girl On? 31 Things to Try on Your PartnerWhat Turns a Girl On? 31 Things to Try on Your PartnerLove AnalyzerLove AnalyzerSending Your Sweetie a Love Note? Here are 200+ Romantic IdeasSending Your Sweetie a Love Note? Here are 200+ Romantic IdeasExercise Your BrainHow toExercise Your BrainBe a Fun Person to Hang out WithHow toBe a Fun Person to Hang out With

Featured Articles

What Does Your Morning Routine Say About You?What Does Your Morning Routine Say About You?Develop Productive HabitsHow toDevelop Productive HabitsPractice Self CareHow toPractice Self CareWhat Song Matches Your Life Right Now?What Song Matches Your Life Right Now?Will 2026 Be Your Year? Reveal Your FutureWill 2026 Be Your Year? Reveal Your FutureUnderstanding the Most Attractive Face Shapes (& Determining Your Own)Understanding the Most Attractive Face Shapes (& Determining Your Own)

Watch Articles

Iron PantsHow toIron PantsCut LimesHow toCut Limes Make Your Own Comforting Cinnamon TeaHow to Make Your Own Comforting Cinnamon TeaDraw 3D ShapesHow toDraw 3D ShapesMake a Sugar ScrubHow toMake a Sugar Scrub Wear a Scarf: 19 Different StylesHow to Wear a Scarf: 19 Different Styles

Trending Articles

Rank My Attractiveness QuizRank My Attractiveness QuizChildhood Trauma TestChildhood Trauma TestAm I Neurotypical or Neurodivergent QuizAm I Neurotypical or Neurodivergent QuizGuess My Deepest Secret QuizGuess My Deepest Secret QuizWhat's My Personality Based on My Song Choices QuizWhat's My Personality Based on My Song Choices QuizGuess My Age QuizGuess My Age Quiz

Quizzes & Games

Religious Values TestReligious Values TestTake QuizWhat Is My Numerology Number QuizWhat Is My Numerology Number QuizTake QuizWhat Does My Soul Look Like QuizWhat Does My Soul Look Like QuizTake QuizWhat wikiHow Course Is Right For Me QuizWhat wikiHow Course Is Right For Me QuizTake QuizWorld History Trivia QuizWorld History Trivia QuizTake QuizWhich Murder Drones Character Am I QuizWhich Murder Drones Character Am I QuizTake Quiz wikiHow
  • Categories
  • Computers and Electronics
  • Computer Networking
  • Networking Hardware
wikiHow Newsletter You're all set! Helpful how-tos delivered toyour inbox every week! Sign me up! By signing up you are agreeing to receive emails according to our privacy policy.
  • Home
  • About wikiHow
  • Experts
  • Jobs
  • Contact Us
  • Site Map
  • Terms of Use
  • Privacy Policy
  • Do Not Sell or Share My Info
  • Not Selling Info
  • Contribute

Follow Us

×

wikiHow Tech Help Pro:

Level up your tech skills and stay ahead of the curve

Let's go! X --493

Từ khóa » Xóa Route Trong Cmd