Skip to content

Commit

Permalink
Update links
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Sep 27, 2021
1 parent 7eb820c commit 9539a19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions _drafts/ip-route-and-ip-rule.md
Expand Up @@ -8,9 +8,9 @@ published: false

In larger organizations and corporations, it's common to have multiple ISPs connected to one datacenter. It's important to provide faster connectivity to users by optimizing for different networks, which is called **routing**. This article explains how a Linux system route network traffic to different networks. I'll start with the basic.

## The main routing table
## The basics: The `main` routing table {#the-basics}

**Routing** is the process of determining where certain traffic should be directed to. On systems with only one network interface, it's as simple as sending all traffic to that sole interface. Still, it's not usually as simple as a single routing rule. There are often two. Say for example, a VM running on my computer is connected to an internal network with an address of 192.168.2.100/24, then it will have the following two routing rules, visible using the command `ip route` (or `ip route show`):
**Routing** is the process of determining where internet traffic should be directed to. On systems with only one network interface, it's as simple as sending all traffic to that sole interface. Bhehin , it's not usually as simple as a single routing rule. There are often two. Say for example, a VM running on my computer is connected to an internal network with an address of 192.168.2.100/24, then it will have the following two routing rules, visible using the command `ip route` (or `ip route show`):

```text
default via 192.168.2.1 dev eth0 src 192.168.2.100
Expand All @@ -26,3 +26,16 @@ Now when I connect the VM to an extra network with IP 192.168.3.100/24, Linux wi
```

Instead of wrongly trying to reach 192.168.3.0/24 via the gateway 192.168.2.1, Linux will now try to reach it directly from interface `eth1`.

Intuitively, if you have another subnet over the router 192.168.**3**.1, you can add another rule to tell Linux to route accordingly:

```shell
ip route add 192.168.4.0/24 via 192.168.3.1 dev eth1
```

For interfaces that don't have a "link layer", like an OpenVPN interface or tunnel, you can omit the `via` part since it has no effect.

```shell
ip route add 1.1.1.1 dev wg0
```

1 change: 1 addition & 0 deletions _home/links.md
Expand Up @@ -8,6 +8,7 @@ share: true

- 《数据库系统及应用》金培权:<http://staff.ustc.edu.cn/~jpq/courses/adb-cs.html>
- 《并行程序设计》郑启龙:<http://staff.ustc.edu.cn/~qlzheng/pp11/>
- 《算法设计与分析》黄刘生、汪炀:<http://home.ustc.edu.cn/~zgma/alg/>

课程主页(2020 年春季学期):

Expand Down

0 comments on commit 9539a19

Please sign in to comment.