易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 700|回复: 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
2 i. S3 F" L+ v) N0 U: E) H: \& s- w8 F1 b- H9 G' S$ Y$ q& D
网卡重启却能ping通外网
8 }1 {" ]4 T- cError: Conflicting default route declarations for IPv4 (table: main, metric: default)
6 X8 U! f/ }. Q% a# p# L8 D1 J3 l) L9 b9 ^, v' H3 x/ U3 o
root@localhost:~# netplan apply
6 T. Q5 F5 i; G1 C9 X* ]
" \( R  w- ^' p! r! V- D** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.' d, Q& e$ t2 w. L) Q  K
See the 'Default routes' section of the documentation for more details.6 S8 C$ o2 z! K. g' x  w

. z! F' `. F: Y; S8 A** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
2 e/ r+ n4 M/ C& RSee the 'Default routes' section of the documentation for more details.
1 M! c7 q5 e7 j& m% s3 d8 r8 J" h6 J% G. _
** (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.
3 k6 o( o' r$ cError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3; ^! D7 s: b  z% P/ ]
  Y! F- x* t+ n) r! B, P2 R/ ?
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
- G+ g/ T0 o4 L: KSee the 'Default routes' section of the documentation for more details./ K3 J+ m& a6 P2 B3 x, I

" l) A; Y+ a/ ^7 w$ i** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
% Z7 r. n; w) |- vSee the 'Default routes' section of the documentation for more details.& V& O% q) Y( d6 {. j

8 ^. A0 b! \- e** (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.. o* r7 w% t: D: h& g, ~' t3 A
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
  e  n6 D7 `( V! `/ v% ~2 B; n( M
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
, A, [. `, q! U. ySee the 'Default routes' section of the documentation for more details.
, |" J6 f+ o( h% c  U
0 ]6 i" R! r* V9 h, [** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
& r3 t( a; S4 {0 N6 a) o/ OSee the 'Default routes' section of the documentation for more details.) k- u8 n9 b7 p8 k% u

: Q+ A6 e+ o3 `4 ?. O8 ^" J  E& {** (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.
+ C  ]& }; {" C1 P- xError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan38 p; F8 _0 G5 X# S6 p
5 D( s- {& j0 D; l  [4 H1 S2 ?5 h
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.& G% v# [. X' s7 K% k( s
See the 'Default routes' section of the documentation for more details.
" R! C7 U+ U+ _# k. p. y- Q0 N% u1 x* q4 G; ]
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.8 l' D5 Y9 K$ @. C. I% H4 J$ I
See the 'Default routes' section of the documentation for more details.. }% R# }% ]  s! a' d4 t* d6 [

% `/ S: ~. t. `/ C7 h** (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 e: T& e* @5 c  PError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
, j. P- a3 c! a
; T; f' M$ T' N** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.7 o6 `% I( e* W1 B, E: I- M
See the 'Default routes' section of the documentation for more details.
0 Y0 T( o1 V6 `* j+ o3 I; Z
% u) K4 z8 B* H% R* B/ F. F! N5 H8 P** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.+ w4 g9 O. l) H1 m" O, T* z
See the 'Default routes' section of the documentation for more details.: Z: Y6 D) w' [& J

, E7 n: m$ F) d% V6 L7 t& n** (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.; A5 [- p6 b/ v& k
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
6 H( s4 }0 z; K0 X( S$ P. h- i& C3 m( F$ O
% j% K2 e9 A$ e; H) J& Q2 `

) ~$ ~- c+ A4 Z7 r$ k. H7 O! _* `
2 P( @; E: B: ^7 W3 O
' m/ b# E) ]; ?
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错
7 ]9 c0 G: _5 z+ W* Y; `1 k. I4 a2 Y3 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.0 N' g2 N7 }7 w' {. b. D
Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3& O9 E% f0 N! w4 Y- O* p1 X. O+ ~

% V4 {8 |8 n* m0 |, i5 N8 Y ** (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.
: t% o7 t, A: t0 \ Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
) ~' S& o9 w# a
/ D5 `! ~7 s  I
% m3 ]' T1 @3 f, f$ ip route list! R1 I& F3 ?2 M9 X5 w

4 x  }. y. p# a, U default via 192.168.0.1 dev enp0s8 proto static metric 100 4 F# D+ I1 K, H2 }" D
default via 12.34.56.1 dev enp0s3 proto static metric 100
: U7 A! E7 `- [  G# }) U1 j: r 192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5
) r7 f' _: i' A8 A; i# F  j! }) P5 d 12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78 % O, U" X8 j( r* x: z% S

/ S+ t# ~  b2 ^2 b+ J
! c! x+ x: y3 A# F% S1 i9 l4 X会发现确实出现 2 个 default% i9 Z! e' S: @/ @3 s$ `

7 u; }6 s# S% d5 `当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了
4 c# s* @4 d3 }- `# ^  d5 C
9 x5 B+ \8 u) q- L: _/ o$ sudo ip route del 192.168.0.1. A1 ~5 L0 B! V7 E6 o! {
其实只是改变了 2 个 default 的次序
8 x0 c; p1 K: k5 T& s- R! W' L" t7 @1 A1 e4 Z4 I) d: l5 w; o; ^
今天重新思考并测试:) T. ^; b3 h* }8 f
既然外网已经有网关,那么,服务器访问外网不会有问题/ G* ~# R7 z6 }( h  U$ @
内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!
( W$ m6 Y2 V; F4 z/ k/ Z" B! {/ E: Y, j8 x, Q1 n) A% p$ M
$ cat 00-installer-config.yaml' E7 U* p! H) q3 [; @9 O
修改一下即可
2 u0 ~' E4 A8 i: W
9 q2 g# Y6 t& }' `$ H+ q* o- u   routes:
% @0 v6 z* h. m0 z0 B5 c     - to: 192.168.0.0/24 # 0.0.0.0/0" t) `0 x" k( ?' ?
       via: 192.168.0.13 Q. b  A/ G3 k7 Q7 R9 A; Z9 a
       metric: 100. O7 Z* c4 K" ?  {) ^
# P/ A8 p3 c  W+ T# T% b- a6 |

1 ]( {4 @5 n" M" f) \再次 $ sudo netplan apply 不再报错和警告
& p4 c! ~. p1 {9 t& t3 `% t( u) b0 h# m# ^: m- H
$ ip route list) q' r* g* Q5 W" ]
& l/ r+ m& ]/ n5 M& T6 |( S
default via 12.34.1 dev enp0s8 proto static metric 100
% S* n, \, t( B' _, g: v4 [: ?5 q 192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5 ' Q. r9 C1 h; O/ s
192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100
8 i  Y$ W9 w! f( _) @ 12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78
% }  }" J$ b9 B5 w' d/ o5 v- M; y: q1 x7 t2 B, e0 [. ^2 O

1 B0 A) m% k8 u6 F6 v现在只有一个 default 了
0 _4 R: Z4 U: `# W7 e& J" N1 Z0 d- m7 Q9 e
其他
' i: v  @( ?) E+ w  [安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!2 m# g; D  K1 L' j0 T
改正过来就好了!
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:
+ V% |" C& b! V0 D' lnetplan apply会根据gateway4生成默认路由,保留一个gateway4即可3 Z) s# d& G: d
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 20:17 , Processed in 0.050411 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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