易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 701|回复: 2
收起左侧

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

[复制链接]
发表于 2023-6-11 15:59:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
! M( R2 G3 A) b+ B2 c* E0 ]
, q0 K3 c% u7 K* q* Y网卡重启却能ping通外网5 U$ h9 n& b2 G7 w7 I0 b. T: W- I
Error: Conflicting default route declarations for IPv4 (table: main, metric: default)2 I' F* C. s; J/ t2 Q& P3 ~
3 D! _/ ~0 \0 F) V
root@localhost:~# netplan apply
7 A" l# V$ Y, H# \1 s6 _( m# \, R
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
7 m  b9 ~7 A3 MSee the 'Default routes' section of the documentation for more details.
# h4 T+ T- @& l5 T- ~9 D7 U2 K: R; r# N! I9 L% v2 v4 K
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
, q' V4 M* R: _4 ?% B3 }- `See the 'Default routes' section of the documentation for more details.
- d1 Y( q( c: k. D4 l
- y1 i  Q3 B! b* b% E** (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.- d0 t6 k7 R- `/ x) a8 g
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3- B! [; |2 |0 ]  t8 T2 Y- w

% k0 _7 F) I- w- h** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
2 ]  y$ }4 o9 g% n5 m+ V2 ^See the 'Default routes' section of the documentation for more details.! T" f& L4 [* T8 F- e* m2 z8 k
! }7 M# v5 s+ B8 d# u8 @
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
+ S8 C  q) n3 N/ E: ]See the 'Default routes' section of the documentation for more details.# z6 A. Z  j. l; p) s
- e% n* E/ ]# N6 G# t
** (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., n9 N1 H' T& r7 @! T
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
; F8 q4 P2 j3 G
( q+ K2 I- G- u6 M  R** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.. n: i. a; R0 z, C
See the 'Default routes' section of the documentation for more details.
$ P/ x$ X4 }' g
$ u8 a- \0 q/ |& i% s- ?** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
* F. t: E& i8 u6 e* ]See the 'Default routes' section of the documentation for more details.
/ h; h. ~  q) \8 J
3 {2 x- N- |+ t- R% ^8 Z** (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.
) s; t2 N5 e: m5 [* PError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3: `' }$ L  l2 K( F4 K0 I+ v

% c& |( _! z2 o** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
6 E, i& R7 Q! r# h$ V  KSee the 'Default routes' section of the documentation for more details.. _7 F9 A" ^7 |. u" R! Y
$ c! U' p( {& g/ D3 c6 Q) w6 _3 o
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.5 h, q  u: w8 y; h3 J
See the 'Default routes' section of the documentation for more details.
6 s  D7 e5 F9 s/ Z( d- ^
( L6 |0 R5 W/ E$ M% H3 J** (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.
! V6 z9 D8 h7 R9 K+ @8 wError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
, P" ^( Y% F5 F# o( ?' t
4 m2 N3 Q+ Q% l** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.  u2 f2 u* I+ ]6 `
See the 'Default routes' section of the documentation for more details.
' }2 @! t# Q6 e. i( ~2 l% l: a4 \7 u  L8 W
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
- S# U/ P8 ]9 @' X0 kSee the 'Default routes' section of the documentation for more details.: `" w3 t: t" ]6 G/ P
6 H& B0 @* D3 g: V8 d
** (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.  x+ B0 A8 R$ Z" l
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3# V8 ?4 V$ {0 y! \

$ C# ?1 ]: G7 f0 e) }! h  Y
/ \, G2 w% y% p3 x" Y
( O; f8 k) M. b& h! ?% q# A7 ?% m( Q9 l9 B$ l, V. E( O
/ o5 F! S* O# j1 G  e
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错
( p& Q  O2 s. i7 _# B' I2 R
. w! z1 B! z9 v# E- P/ s. T$ z0 B ** (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.
! w# d1 z5 y  ?2 x5 ` Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
  F& X' e) e7 v; h* m% l+ h3 O4 z1 q % P% ~+ x6 L& g2 x0 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.7 O3 b: s6 T6 F' |0 K* X3 g& b9 Y! `
Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3) K. h, A, |7 x0 ^/ e% P- V/ E8 Q

7 }2 b* i, i+ R2 f" Y# t, g
6 w, ]- }; T9 E3 ]# w: t, p$ y$ ip route list8 S; B1 j% O$ @8 o
. W9 N8 l9 v3 c) ?( H7 k/ d# h6 E
default via 192.168.0.1 dev enp0s8 proto static metric 100 8 i0 A% g2 \; E6 N
default via 12.34.56.1 dev enp0s3 proto static metric 100 $ A8 c& E* L% q' @) z
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5 1 B0 A0 N3 C+ H! n7 }
12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78
. {; E! S% {6 X+ e
$ ?" o8 u7 ^' M: N4 ?1 T' X7 f/ j& G- f) n! K
会发现确实出现 2 个 default
) N7 T; N& ^" ^
. u! b* i" B7 \' H) B# I3 F( I  `当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了
/ p, t8 o$ Z% N) }1 h" e" j$ H$ P) H" k4 G6 P( ?& L9 ~5 D
$ sudo ip route del 192.168.0.1
2 L2 g5 B$ z3 @6 ~- |, V2 r  X其实只是改变了 2 个 default 的次序! C( d1 V* X8 k- b- b$ W( j! l
% Y% D9 N& @2 R) i+ K+ M3 X5 R
今天重新思考并测试:
( B# {( N; o% ]既然外网已经有网关,那么,服务器访问外网不会有问题
: n  N6 n- A4 v内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!
7 E  W4 e# H$ B5 p/ Y; C" p3 y) |3 d+ M# T( T5 H
$ cat 00-installer-config.yaml) \1 B1 B+ X9 h' f
修改一下即可3 D3 Q6 F) u) I2 R% T
/ m" `% p& Y! s$ e, P" [
   routes:# l6 r  X: H( b7 {, V) {
     - to: 192.168.0.0/24 # 0.0.0.0/0
, J, g( p3 z( ]9 Y       via: 192.168.0.10 v+ p+ r  a5 A3 M: @% I
       metric: 100
7 b" A7 X# X7 u# n, s1 ]( T* m$ e4 A9 V8 R; w2 h2 Z- I4 H6 K

- k( d0 @2 N  d6 x( Q$ K/ ?再次 $ sudo netplan apply 不再报错和警告
% h/ g& U( c4 e' L  a5 s7 N7 Y# z& [/ L# o* |4 q/ P9 l
$ ip route list, h8 x  N( u. t" a
2 R- m6 E& _3 ^% s  e1 o% S' t
default via 12.34.1 dev enp0s8 proto static metric 100
& v3 b6 S4 F3 c: M/ z 192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5 : ~2 B8 x! Z( @) K4 w. `% i' O
192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100 9 k5 g1 x* u$ i
12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78
3 ]8 {) [2 g3 V
$ {5 I7 }; r  E6 x: b. ^% L$ z/ n& B8 W
现在只有一个 default 了
4 k5 i) H! Z/ n0 y
9 P( [* O! T1 M, x4 f其他
! m+ s/ }9 n- D& b8 x安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!3 @) y# D/ q2 C4 V; W& q
改正过来就好了!
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:
% h4 m+ ]$ [) q+ ~! G- Tnetplan apply会根据gateway4生成默认路由,保留一个gateway4即可
' `# [8 E( n% a7 I7 m% I( Z5 B
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:29 , Processed in 0.050155 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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