问题:如何配置默认路由?

问题:如何配置默认路由?

我有一个问题,您将使用什么命令来配置默认路由?我的意思是,我已经尝试过: ping 192.168.3.50 PING 192.168.3.50 (192.168.3.50) 56(84) bytes of data. 64 bytes from 192.168.3.50: icmp_seq=1 ttl=64 time=0.058 ms 64 bytes from 192.168.3.50: icmp_seq=2 ttl=64 time=0.030 ms 64 bytes from 192.168.3.50: icmp_seq=3 ttl=64 time=0.030 ms

然后尝试配置默认网关:

ip route add default via eth3 peer gw 10.0.3.142 dev eth0

但没有用。 :(

这是我的网络配置:

[root@host-0-0 /]# ifconfig -a ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.3.137 netmask 255.255.255.248 broadcast 10.0.3.143 inet6 fe80::19f6:e3d9:7122:9ccb prefixlen 64 scopeid 0x20<link> ether 00:0c:89:00:03:90 txqueuelen 1000 (Ethernet) RX packets 1069 bytes 121480 (118.6 KiB) RX errors 25 dropped 0 overruns 0 frame 25 TX packets 869 bytes 123920 (121.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.254 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::8d3:43ff:fe9c:e9c2 prefixlen 64 scopeid 0x20<link> ether 0a:d3:43:9c:e9:c2 txqueuelen 1000 (Ethernet) RX packets 13 bytes 1026 (1.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 24 bytes 3797 (3.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.62 netmask 255.255.255.240 broadcast 192.168.3.63 inet6 fe80::af:97ff:fed7:9170 prefixlen 64 scopeid 0x20<link> ether 02:af:97:d7:91:70 txqueuelen 1000 (Ethernet) RX packets 20 bytes 1600 (1.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 32 bytes 4419 (4.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 6 bytes 480 (480.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6 bytes 480 (480.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:fb:c1:2c txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0-nic: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 52:54:00:fb:c1:2c txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

答案1

要使其成为系统默认路由,只需执行以下操作:

ip route add default via 10.0.3.1

,如果您已经有另一个默认网关,只需执行以下操作:

ip route replace default via 10.0.3.1

来替换它。

相关内容