라우팅 테이블 및 게이트웨이
Linux 라우팅 테이블을 검사하고 조작하여 네트워크 트래픽이 목적지로 전달되는 방식을 제어하는 방법을 학습합니다.
라우팅 테이블 및 게이트웨이은(는) CoddyKit의 무료 Linux Networking & TCP/IP for Developers 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Linux Networking & TCP/IP for Developers 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Linux Networking & TCP/IP for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What are Routing Tables?
Imagine your computer needs to send data to another device on a different network. How does it know which path to take?
That's where the routing table comes in! It's like a map for your operating system, containing rules that tell it where to forward network traffic.
- Each rule specifies a destination network or host.
- It also points to the 'next hop' or interface to use.
Inspecting Your Routing Table
In Linux, the primary command to view the routing table is ip route show (or just ip route). Let's see what it looks like:
ip route showUnderstanding Route Output
When you run ip route show, you'll see entries that typically include:
- Destination: The network or host traffic is headed to.
- via: The gateway (next hop router) to send traffic through.
- dev: The local network interface to use (e.g., eth0, wlan0).
- src: The source IP address your system will use for outgoing packets.
- metric: A preference value; lower is generally preferred.
The Default Gateway
One crucial entry in the routing table is the default route. It's often shown as default via <IP> dev <interface>.
This is your network's 'gateway of last resort'. If no other specific route matches the destination IP, traffic is sent to this default gateway. This is usually your router that connects you to the internet.
ip route show defaultAdding a Static Route
You can manually add routes to the routing table. This is useful for directing traffic to specific networks that aren't reachable via the default route, or for creating isolated network segments.
Use ip route add to add a temporary static route. Remember, sudo is often required.
sudo ip route add 192.168.2.0/24 via 192.168.1.1 dev eth0
# This adds a route for 192.168.2.0/24
# via gateway 192.168.1.1 on eth0Verifying the New Route
After adding a route, it's good practice to verify that it's present in the routing table. Just run ip route show again and look for your newly added entry.
ip route showDeleting a Static Route
Just as you can add routes, you can also remove them. This is useful for correcting mistakes or cleaning up temporary configurations.
Use ip route del with the exact same parameters you used to add the route.
sudo ip route del 192.168.2.0/24 via 192.168.1.1 dev eth0
# Removes the route we just addedGateways: The Next Hop
A gateway is a network node that serves as an access point to another network. It's essentially a router that forwards packets between different networks.
When your computer sends data to a destination outside its immediate local network, it sends the data to its configured gateway, which then handles the forwarding.
Temporary vs. Permanent Routes
Routes added with the ip route command are temporary. This means they will be lost if your network service restarts or if the system reboots.
For permanent routes, you need to configure them in system-specific network configuration files. The exact location depends on your Linux distribution (e.g., files under /etc/netplan/, /etc/network/interfaces, or in network scripts).
Routing Table Challenge
You just learned how to inspect and manipulate routing tables. Let's test your understanding!
Recap: Routing Essentials
Great job! You've learned the basics of Linux routing tables and gateways.
- Routing tables guide network traffic.
- Use
ip route showto inspect them. - The default route is for unknown destinations.
- You can temporarily add and delete routes with
ip route addandip route del. - Gateways are next-hop devices for reaching other networks.
Understanding routing is key to troubleshooting network connectivity!
자주 묻는 질문
“라우팅 테이블 및 게이트웨이” 강의는 무료인가요?
네 — “라우팅 테이블 및 게이트웨이” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Linux Networking & TCP/IP for Developers 강의 전체를 잠금 해제할 수 있습니다. Linux Networking & TCP/IP for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.
“라우팅 테이블 및 게이트웨이”에서 뭘 배우나요?
Linux 라우팅 테이블을 검사하고 조작하여 네트워크 트래픽이 목적지로 전달되는 방식을 제어하는 방법을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Linux Networking & TCP/IP for Developers을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Linux Networking & TCP/IP for Developers을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Linux Networking & TCP/IP for Developers은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“라우팅 테이블 및 게이트웨이” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Linux Networking & TCP/IP for Developers 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Linux Networking & TCP/IP for Developers 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 네트워크 인터페이스 관리
- 라우팅 테이블 및 게이트웨이
- DNS 구성 및 이름 확인
- nftables를 사용한 Linux 방화벽 구성