ubuntu添加默认网关_如何在Ubuntu,Linux中添加或更改默认路由或默认网关?

ubuntu添加默认网关

ubuntu添加默认网关

Systems connected to the network will generally access to the internet. In order to access to the internet they need some network configuration like gateway or default gateway. In this tutorial we will examine how to add or change default gateway in Ubuntu, Debian, CentOS, Fedora, Mint, Kali operating systems.

连接到网络的系统通常可以访问Internet。 为了访问Internet,他们需要一些网络配置,例如网关或默认网关。 在本教程中,我们将研究如何在Ubuntu,Debian,CentOS,Fedora,Mint,Kali操作系统中添加或更改默认网关。

列出路由表 (List Routing Table)

Routing table is used to route IP network communication. Hosts generally uses default route to send packages which will redirect them accordingly to transmit destination. We will start by listing current routing table. We will use ip route show command like below.

路由表用于路由IP网络通信。 主机通常使用默认路由发送包,该包将相应地将其重定向到传输目标。 我们将从列出当前路由表开始。 我们将使用如下所示的ip route show命令。

$ ip route show
List Routing Table
List Routing Table
列出路由表

Our default gateway line is

我们的默认网关行是

default via 192.168.122.1 dev ens3
  • default means this line is default gateway

    default表示此行是默认网关

  • via 192.168.122.1 specifies next hop which is default gateway IP address

    通过192.168.122.1指定下一跳,这是默认网关IP地址

  • dev ens3 is the interface we want use to access default gateway

    dev ens3是我们要用来访问默认网关的接口

删除现有的默认网关(Remove Existing Default Gateway)

Removing default gateway is easy if we list routing table because routing table line is used with del command like below. But keep in mind if you are connecting system remotely from different network which means if you are using default route you connection will be lost.

如果我们列出路由表,则删除默认网关很容易,因为路由表行与del命令一起使用,如下所示。 但是请记住,如果要从其他网络远程连接系统,这意味着如果使用默认路由,则连接将会丢失。

$ ip route del default via 192.168.122.1 dev ens3
  • ip route del is our key line which deletes specified default gateway

    ip route del是我们的关键行,它删除指定的默认网关

  • default via 192.168.122.1 dev ens3 is the same as routing table

    通过192.168.122.1 dev ens3的默认值与路由表相同

添加新的默认网关(Add New Default Gateway)

As stated previously default gateway is used to send packages in order to transmit to the destination. We can add new default gateway with the ip route add command like below.

如前所述,默认网关用于发送数据包以传输到目的地。 我们可以使用如下所示的ip route add命令添加新的默认网关。

$ ip route add default via 192.168.1.1 dev ens3
  • ip route add will add provided default gateway

    ip route add将添加提供的默认网关

  • default means target network is all which is default

    default表示目标网络全部为default

  • via 192.168.1.1 is our default gateway network address

    通过192.168.1.1是我们的默认网关网络地址

  • dev ens3 is network interface for default gateway

    dev ens3是默认网关的网络接口

LEARN MORE  How To Download, Install, and Run Packet Tracer In Windows?
了解更多如何在Windows中下载,安装和运行Packet Tracer?

检查一下 (Check)

List routing table again and ping some of remote networks will give the status of default gateway

再次列出路由表并ping某些远程网络将给出默认网关的状态

$ ip route show 
default via 192.168.1.1 dev ens3  
10.0.3.0/24 dev lxcbr0  proto kernel  scope link  src 10.0.3.1  
192.168.122.0/24 dev ens3  proto kernel  scope link  src 192.168.122.211

如何在Ubuntu,Linux中添加或更改默认路由或默认网关? 信息移植 (How To Add or Change Default Route or Default Gateway in Ubuntu, Linux? Infografic)

How To Add or Change Default Route or Default Gateway in Ubuntu, Linux? Infografic
How To Add or Change Default Route or Default Gateway in Ubuntu, Linux? Infografic
如何在Ubuntu,Linux中添加或更改默认路由或默认网关? 信息移植

翻译自: https://www.poftut.com/add-change-default-route-default-gateway-ubuntu-lnux/

ubuntu添加默认网关

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值