如何在Linux EC2上设置路由

huangapple go评论62阅读模式
英文:

How to set routes on a linux EC2

问题

如何在Linux中设置以下数值?

我可以设置目的地和网关,但在文档中找不到有关传递genmask、flags、metric、ref、use或Iface标志的任何信息。

有人可以提供要传递的值吗?我已经能够构建以下命令:

```bash
sudo route add -net 0.0.0.0 gw 192.168.96.0 tun0

但我需要添加以下完整命令:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.96.0    0.0.0.0         UG    0      0        0 eth0

谢谢


<details>
<summary>英文:</summary>

how do I set the below values in linux?

I&#39;m able to set destination and gateway, but I can&#39;t find anything in the docs RE passing a flag for genmask, flags, metric, ref, use or Iface.

Can anyone provide the value to pass? I&#39;ve been able to construct the below

sudo route add -net 0.0.0.0 gw 192.168.96.0 tun0

But I need the full command to add the below;

Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.96.0 0.0.0.0 UG 0 0 0 eth0


Thanks

</details>


# 答案1
**得分**: 1

在这种情况下,我建议使用 `ip route` 命令。这是在Linux上管理路由的一种更现代的方式。

例如:
`sudo ip route add default via 192.168.96.0 dev eth0 metric 0`

标志(Flags)、参考数(Ref)和使用数(Use)会自动确定,手动设置它们意义不大。

<details>
<summary>英文:</summary>

In this case, I&#39;d suggest using the `ip route` command. It&#39;s a more modern way of managing routes on Linux.

e.g.,:
`sudo ip route add default via 192.168.96.0 dev eth0 metric 0`

Flags, Ref and Use are automatically determined and setting them manually makes little sense.


</details>



huangapple
  • 本文由 发表于 2023年4月4日 16:31:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75927161.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定