找回密码
 注册
查看: 727|回复: 2

Error: Conflicting default route declarations for IPv4 (table: main, metric: def

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2023-6-11 15:59:08 | 显示全部楼层 |阅读模式
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3, E9 w. ?+ P; X: P. p
+ _& Z5 b9 I. U$ `! `3 z. p5 P
网卡重启却能ping通外网9 U* o( _9 W- s& t8 a
Error: Conflicting default route declarations for IPv4 (table: main, metric: default)
; w, C. K( t" R1 l$ [& W3 \
* ]" z) ]) A2 v$ n+ Q, t8 Xroot@localhost:~# netplan apply
; |1 D% Q( G& {2 h5 S: F2 T. z
4 J. c+ c( {2 @& O) K** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
" V2 G! q: T. d# h9 _See the 'Default routes' section of the documentation for more details.0 S' G. X6 L  a2 M* M
, f2 O: w8 z$ F" U
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
1 T% O# q/ i$ K* |5 VSee the 'Default routes' section of the documentation for more details.
6 m# X8 f' ]0 X$ i
" R- o7 A* h! e( I1 L$ t** (generate:62439): WARNING **: 07:58:24.498: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
. C! z' X6 L/ H. TError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
3 r) e0 |; V" I/ T6 ~6 h3 i' {4 O7 G6 _$ [, t5 V; ], U7 V
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
( \' R1 o, D% {$ K  nSee the 'Default routes' section of the documentation for more details.( l: N! |% l0 C9 M+ y  ^/ g
! x% Q( l+ b& |* f! C8 \  S' b
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.4 G) Y1 ~' U9 ~( F+ ^/ S
See the 'Default routes' section of the documentation for more details.
9 Q& u3 A0 z7 A. f/ B9 _! m: {/ w) M; R8 _. F. }6 Z' Z
** (process:62437): WARNING **: 07:58:24.812: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.: s; z7 K- l$ o+ l4 F6 O
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
" W; n0 |& S9 J
+ F9 R, [! ?, e3 Q$ o+ I7 Q8 }& Z** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
8 E  O& q5 ~6 j" ]See the 'Default routes' section of the documentation for more details., m5 o1 _; ?$ I7 S5 r
) Z0 X- n8 K% g0 U2 p
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
6 b' U: L& X- `+ \See the 'Default routes' section of the documentation for more details.; ]  V9 L4 y% T5 d' C' |4 ~5 l
* K2 y6 T3 A0 _# p6 f5 W
** (process:62437): WARNING **: 07:58:24.822: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
3 Y+ q$ i' p0 q! @Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan35 D1 h7 ]; Z$ ]( i. Q9 L
2 U* Y5 {9 A8 d/ m, n5 k$ _
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.1 k- p5 Q* [; [5 X
See the 'Default routes' section of the documentation for more details.$ y& ?, n: d- X2 g
/ `5 t# N0 ~! F" o5 Q( c* W* K
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.) f1 e; B. E  ?6 b
See the 'Default routes' section of the documentation for more details.
! i: d1 p; L" S" x& O1 K8 `* Z$ K1 I, I" V4 k4 D: s1 G
** (process:62437): WARNING **: 07:58:25.134: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.7 |5 Z' n# h: `5 I  X
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
+ ^9 u" y+ K5 t& U) G& {/ e( @+ S$ l4 j
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.9 q3 {1 E  C3 Q
See the 'Default routes' section of the documentation for more details.
/ v  D7 b6 b3 q4 x4 w0 V& ?* H( U, K! }9 G- v# e& J& z* T# e0 n- Z& J
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.8 O+ \. {; h3 N: r& m5 h, {
See the 'Default routes' section of the documentation for more details.* X+ e% f/ n6 L2 P# `6 D, [% n
' v4 c; t( q- B- k2 |
** (process:62437): WARNING **: 07:58:25.135: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
+ O2 M2 a7 E; TError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
& R. Z! ^" ]5 E3 q( k( T" S  y7 [0 H$ U
/ N" b; e2 d, S8 y  q
3 x4 h6 @5 D, o/ A) Z
* H2 U6 l/ t* D: f
  h& V$ n, i$ d! L: w" E# k

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错( M6 C  G" F! u1 p# Y+ \! @" V: A' p

% p; |* i/ [9 j2 s; \ ** (generate:2624): WARNING **: 02:29:33.628: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
9 f/ Q* X* j% p$ q. N1 R  X Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s34 m! Q! T; p3 }; t; j  \

- r( ]+ Y: @( W1 k ** (process:2622): WARNING **: 02:29:34.210: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
( [& ~6 s# n* r* G- S Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s36 W, T4 T9 s7 K& o  m  g. Q

9 R" Q( g6 W6 v* @$ q. j7 b! B1 [
$ ip route list
* X( C! d, o- E6 N, F* L5 R. ]; |8 a* ^0 G1 M+ Q4 i6 g
default via 192.168.0.1 dev enp0s8 proto static metric 100
0 `6 @% W- |# }- r9 V8 E default via 12.34.56.1 dev enp0s3 proto static metric 100
" m$ v0 C) a9 ?: W 192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5 ! |+ D; o  J! O& q
12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78
' G3 [% ^8 [2 x% t) u5 W& e* D- {5 @4 l5 I3 Z4 s5 k

% s! _$ f! d4 F会发现确实出现 2 个 default! v- b) H* R+ H3 p
7 W( Y- a6 |. [) [
当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了
0 j/ [+ X; Q, X# w( F/ P8 J- X9 y% a, c) I
$ sudo ip route del 192.168.0.1+ {3 o+ J1 |: v6 `8 r
其实只是改变了 2 个 default 的次序4 y6 l  p7 S8 `) A+ q5 @. n. {

3 r1 s! @0 ], p! P今天重新思考并测试:- R+ o7 `6 \) s' ?/ ]0 Z
既然外网已经有网关,那么,服务器访问外网不会有问题
( `' c: S  T5 }: W& z. N' a内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!
8 X# z; y& N9 G' ^
; b( R0 z; Q( `5 P1 O$ cat 00-installer-config.yaml
; B" C4 \7 W; _8 a+ @- [修改一下即可# U/ W+ t1 S6 Z$ b/ t* n+ ]! \6 ~
1 W/ N' S3 r3 W
   routes:
$ b& p5 ~; P& G* s7 T4 r1 Q' `* X     - to: 192.168.0.0/24 # 0.0.0.0/0
; b! J4 b1 c3 [8 i% Q" z/ Y       via: 192.168.0.1
0 x, n1 b3 c$ J       metric: 100
$ v- V1 U2 Z7 n- R8 D; O1 S. l$ c8 q

, B4 V: `: u8 r) R! G再次 $ sudo netplan apply 不再报错和警告
) G/ F! Q0 n6 B& @4 m8 o) v* ~& c# }2 S
$ ip route list
9 j7 P# _( I1 Z0 I* S9 @
$ i2 w6 u7 E. t0 Z default via 12.34.1 dev enp0s8 proto static metric 100 ) _( k" o+ Y2 e" u
192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5 : ?7 [) z( {! Y8 a5 L
192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100
! B+ J! X# |0 v. n8 g/ k( K" c+ ]+ | 12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78 & Y" s2 X2 {+ C0 k' L" ?; i
" K" s# w" c: U8 c) l

( E8 ]9 x+ |, G5 U! v: Q1 q现在只有一个 default 了
. @$ Q' q6 H1 h0 H: H/ x0 u7 B1 L. {5 N/ ?2 m# g
其他1 y  c% j; d$ M' Q, O
安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!
0 B  ?4 s# r( t5 g$ w! L! D7 t改正过来就好了!

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:# b. P7 u# |2 V
netplan apply会根据gateway4生成默认路由,保留一个gateway4即可
/ U0 ]; y& w% C
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:42 , Processed in 0.016041 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表