Do you know what's less useful than a screen door on a submarine? A network with no routes. Routing has existed in tandem with networks since the genesis of time, or at least since the 1960's when the concept was invented. Routing as we know it today didn't exist until 1981 when a team of researchers developed the first multiprotocol router. Even though the technology is relatively new, it's highly integrated into our daily lives.
During my time as a support engineer, I found myself troubleshooting network connectivity issues more often than I care to remember. Many times, I would find myself having to engage a senior tech for help because I didn't fully understand the routing from device to device. If only there had been a place where I could get the basics of routing and the commands needed to make changes. Well, you're in luck! I'm going to provide that information here.
There are many ways to do things in Linux, and routing is no different. I want to examine two different commands for displaying and manipulating routing tables: the route command and the ip route command. We are going to look at both commands in some very common use cases to see what each utility can offer.
Displaying existing routes
First things first. You never want to make a change to a route until you verify the existing conditions. To do this, simply run the following:
Display existing routes with route:
[tcarrigan@rhel ~]$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 enp0s3
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
Display existing routes with ip:
[tcarrigan@rhel ~]$ ip route show
default via 10.0.2.2 dev enp0s3 proto dhcp metric 100
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
For a basic listing, I prefer the old school route command, but your mileage may vary.
Adding new routes
At times, you need to add new routes between devices. To do this, use the examples below.
Using route:
[root@rhel ~]# route add -net 10.0.2.0/24 gw 192.168.0.1 enp0s3
Here the syntax is: route add -net <network_address> gw <gatewayaddr> <interfacename>
Using ip:
[root@rhel ~]# ip route add 10.0.2.0/24 via 192.168.0.1 dev enp0s3
The syntax for this command is: ip route add <network you want to connect to> via <ip used to reach the network> dev <interface name>
Removing routes
You can remove routes in a similar fashion.
Using route:
[root@rhel ~]# route del -net 10.0.2.0/24 gw 192.168.0.1 enp0s3
The syntax is the same as the add command, except we are using del instead of add.
Using ip:
[root@rhel ~]# sudo ip route del 10.0.2.0/24 via 192.168.0.1 dev enp0s3
Again, we are only altering the syntax slightly from the add command.
Adding a new default gateway
Another task you may need to accomplish is configuring traffic to flow to a gateway. To accomplish this, use the following commands.
Adding a new gateway with route:
[root@rhel ~]# route add default gw 192.168.0.1
Adding a new gateway with ip:
[root@rhel ~]# ip route add default via 192.168.0.1
To verify that the new gateway is set, use the standard route command or ip route show.
What do you think?
Well, we took a look at some of the most basic functions of these commands. What are your initial impressions? If I am being honest, I prefer the older route command in every instance here. The syntax is easier to understand and remember, and the commands are usually shorter. Hopefully, I won't have to use either of these again anytime soon. However, if I do, I know which one I'll work with!
[ Getting started with networking? Check out the Linux networking cheat sheet. ]
저자 소개
Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.
유사한 검색 결과
Red Hat Ansible Automation Platform: Measuring Business Impact with Dashboard and Analytics
Friday Five — December 5, 2025 | Red Hat
Technically Speaking | Platform engineering for AI agents
Technically Speaking | Driving healthcare discoveries with AI
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래