找回密码
 注册
查看: 732|回复: 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$ t" {: f' M" q2 O, W

/ k2 |- F- S* ]2 p; t) }/ K% u( g网卡重启却能ping通外网% k9 y3 X" A* @, P
Error: Conflicting default route declarations for IPv4 (table: main, metric: default)# |. p1 Z* {% ]" i) R+ M

. j; d$ h% V% _9 Y/ A  yroot@localhost:~# netplan apply
/ M  h0 A; g8 q0 |# p0 h
7 i) t2 N" O' ~** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.7 c# M. X" H2 @( j
See the 'Default routes' section of the documentation for more details.
/ ^  i7 s( ^# T6 B$ j' [; j
/ S3 a! Q  w1 I) J  y** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
; {/ m1 Y# p0 x( i# Z4 E/ Q, zSee the 'Default routes' section of the documentation for more details.
/ F+ w" w, |1 D. D/ w) L; I) _) [8 T8 c% m* U( G8 k
** (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.
! u8 B+ R5 K8 W* x+ ^Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan38 {4 H4 D5 g6 t7 _

  [) y  A3 n  ?3 b** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
, |" C; K0 c* L7 V+ R* ?  nSee the 'Default routes' section of the documentation for more details./ B, u+ ^) u" p% E1 e* e; W% p' @1 M
1 p/ H  v1 k. I. r+ D6 C
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
  F" {- i9 l6 n/ GSee the 'Default routes' section of the documentation for more details.
/ ~: E0 R# O: C: A' _+ S8 E/ s
3 `& f# i  A9 S* {: @** (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.: T( L+ d2 I- ^
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan32 p* ~, v( P0 M% [3 ]' F/ ]# s

; N, z  N( ?& e3 T/ e( r6 m$ y** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
& I7 o/ A7 {2 m* f, A/ A% m! lSee the 'Default routes' section of the documentation for more details.
3 G. b" d* F/ g7 T2 c  x, w# F1 l3 f
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.$ m$ ]0 n  ^5 L  z/ U8 p5 a$ K
See the 'Default routes' section of the documentation for more details.. `0 w. m& U( z: m" K, ^

+ }5 \, x' @8 k9 _% U** (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.! I! j3 @6 o7 k9 a( u2 k
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan39 f- x6 @% f8 E) f
* _$ m: i/ e% E0 t4 T, T
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
: B( g7 h1 C& [1 Y: ASee the 'Default routes' section of the documentation for more details.
) ^+ P) H' x/ x# S0 k- ]! X
) _! Y* W! @; D* |0 b** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
. i5 x7 W2 p( v9 }See the 'Default routes' section of the documentation for more details.
& @5 d% R9 [5 d# C6 Q+ T: A- R# ]8 a3 f" h- k9 u6 m! H: b$ f
** (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.
1 C3 o8 S2 t2 {5 SError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3& Q! b( z4 ~9 o
% g1 j! s  Y' ?7 T7 T7 D1 I* m6 e; p
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.: j# I; A' n" u4 M
See the 'Default routes' section of the documentation for more details.. O: ^; O7 L$ p, W$ ?' y
% Y. \, Z/ h* e# D# v+ A
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.$ O3 K" P" J) M; _% I% O8 T$ {' p
See the 'Default routes' section of the documentation for more details.
- ?9 X/ n; z% L* K6 q$ T8 A7 J: K% T' M/ q2 O
** (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.1 P( f" q3 l9 {  {7 O- U* Y
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
- A' E' R' r# Q3 G' M: N" e; L* W: a2 w# T# G* z0 e
$ a3 |, q7 q# C8 J6 B- r" a: T2 f
( z/ O/ I& h8 p( R8 }4 v
+ Z+ a# z9 L7 K# L
! A: I6 I% Q* l- T8 O

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错
0 P! r. j3 d# e; W7 n, I: k3 N% ]4 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.0 D! h  `1 G  b# p' j, J
Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
: @1 I! t+ h/ q5 t/ b  E- Y' v2 `
5 o) {! X4 z1 d ** (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.
- M% ?9 h- U0 Z; i4 Z3 X Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s35 E1 c1 m$ P+ X! z
5 _  ]( q! X% V5 d4 W8 w
0 |) z' r4 Q. W, z" V
$ ip route list- O) Q( v- Y2 j+ Y  _3 @$ J
) l: Q: d* j5 Z* V
default via 192.168.0.1 dev enp0s8 proto static metric 100
$ L% m  a2 {, [ default via 12.34.56.1 dev enp0s3 proto static metric 100 4 m- X8 ?" R" X# H4 K, x
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5
, D/ l: a* j9 V" T; q$ X 12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78 2 s5 c9 Z  U/ g& r& A" r
  y" @6 o' H& D+ a( J  h2 o* G- n
: B6 @" W4 C3 n- G1 G
会发现确实出现 2 个 default7 T8 u: {+ R: U" f+ j7 i
, S% S* @+ H1 ?, F7 M* H6 T0 ?6 I8 Q# ~
当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了
8 c3 @+ f: A) X/ o! Z, q: z+ Y8 T4 y9 k3 `" [
$ sudo ip route del 192.168.0.1  o$ x: @: y* f$ _+ [2 ^
其实只是改变了 2 个 default 的次序
% n; E/ }+ l9 E; i: `& n
7 k8 r0 |7 R" [$ Q" W今天重新思考并测试:
' J( |; J5 F: I: g' {$ `: E% [既然外网已经有网关,那么,服务器访问外网不会有问题
2 q3 `& z; u" S" L$ {$ u1 N3 b内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!5 {" C( |/ o2 b" @( u
9 ^5 u4 ~) \' P3 R
$ cat 00-installer-config.yaml
8 Q+ _" d8 r5 n3 z修改一下即可- X5 s% @9 l6 w+ |3 B+ }

7 ?& Q* g! t; G9 |   routes:9 o/ O* Y# K4 Y: d
     - to: 192.168.0.0/24 # 0.0.0.0/0
  S( s( m, b. ?$ B' R/ y       via: 192.168.0.12 _5 x: X$ D# N
       metric: 100
/ w* a1 K/ m& Y6 g6 P# O- R& \" H2 m7 J" U$ d" M. O
2 G5 k: s1 d1 A( x4 V# W' R$ H
再次 $ sudo netplan apply 不再报错和警告
& _8 m9 W; e/ B# o6 [; _- f
- d  Z2 y0 I# Z) e$ ip route list, x6 i3 l# C  L( X" n! W
7 `, k: u8 A' ^4 C, d) G4 P
default via 12.34.1 dev enp0s8 proto static metric 100
1 M" o# Z! X5 b, R" ? 192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5
5 T% N6 r  P, R: r6 w# x0 |8 h# I 192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100
. f- e- W5 u; i# Y7 C5 F" s! n) P/ O6 i 12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78 3 Y& B- {2 F& k5 p2 T$ p

7 _2 A+ M. Z' V' g+ k
( Y1 X2 r+ m* R现在只有一个 default 了7 s, O: l! _) s2 j4 g
& i4 S8 `  j4 J/ `" c
其他
: f$ v3 V% u: ^) C7 ~2 ~安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!' x: r4 t6 p; s" V' I2 i3 Y
改正过来就好了!

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:
# R4 X! B, u! i: u/ Y. W: L+ h0 ^netplan apply会根据gateway4生成默认路由,保留一个gateway4即可# E& @! U1 N" T; @9 r
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 03:05 , Processed in 0.025203 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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