找回密码
 注册
查看: 731|回复: 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
9 }8 x- d$ {, @  {5 x9 I( `  Q0 b- J) M; E
网卡重启却能ping通外网& r5 \8 M- B, W
Error: Conflicting default route declarations for IPv4 (table: main, metric: default)
$ F9 m# ^- t' x9 a
, J, T( {) K; lroot@localhost:~# netplan apply
8 `2 L: P# ?+ w- r% `3 L: U. S' G9 y- Y; Y1 |  q
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead., i, L' x3 a$ [5 b1 P  k) q
See the 'Default routes' section of the documentation for more details.
5 y) b6 ^" q* c
7 ?" T9 ^1 w0 |+ X9 P  y- ^6 p** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.# a+ C, j. t6 u5 ~8 y* A4 q( ]/ a
See the 'Default routes' section of the documentation for more details.# e# {! y6 |! v: _3 F6 S# ~

# d) F1 z% G  B  K- P( r** (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.- b( h( p2 T$ T9 ~0 v2 `
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
, s- q6 k+ ]; O& f5 `& V! Y! P' ]) ]( D6 [4 L
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.
" |% ~( ?" W" L+ J8 TSee the 'Default routes' section of the documentation for more details.
' l$ u0 n- j6 N9 A) P6 c" d; s% @9 V# J' O( z/ K
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.- Z, M0 c' L2 @( _: ?# F* s
See the 'Default routes' section of the documentation for more details.
/ K5 S$ p& o3 G3 a. n3 q4 t, ~: h* S  p# D
** (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# {- |) c: F, I6 k9 _! L
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
' d4 F; I5 T# A! I# }
/ }3 ?- g9 T2 a** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.9 A0 {9 ~- O! Q# p' u) }% p
See the 'Default routes' section of the documentation for more details.9 q7 H* B0 U1 k+ s
: T8 A$ R, m5 }4 X. B. M/ _
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
4 r4 |  a8 M; ~; `3 \See the 'Default routes' section of the documentation for more details.
$ r5 V. z9 }* u' S6 R1 M. h4 G$ a+ n: {" S6 D1 b( ~
** (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 z& n0 S% x4 Y2 x, o& ?# Z% X' gError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
0 @/ J% A' c  _4 ]' A$ Q! A) W1 M  q& W) a
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.9 a) o; B: S$ E3 S* q, v& A
See the 'Default routes' section of the documentation for more details.$ _3 ?% w# K8 A* z& o; M1 K

  G9 ~8 r7 E! R  `$ P3 l** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.- R! E: k9 m- e. d8 _3 h
See the 'Default routes' section of the documentation for more details.
: v- {# F( I4 c$ m8 K( I( n0 f
0 m. |) d' g- B" q# e% b** (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.' R! L; O) w4 A% \
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
5 r: N4 H) w6 U. x- R3 t- h2 N  [  h- Z- ~
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
  F& e$ j  G* |$ mSee the 'Default routes' section of the documentation for more details.
- ~* T; ?5 j4 H! }5 P/ {
1 x' a; ~; Z) i4 V9 O  N! N** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
5 M$ |, c7 a# h$ F8 `+ VSee the 'Default routes' section of the documentation for more details.
$ r0 }% r- V/ N( G- x# r! f. H3 x9 @  Z
** (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.% l5 Z) A$ N$ g6 {1 S, ?8 R" A
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
6 u1 v! X! _3 F) ~1 x3 @5 t$ z. M3 p7 ]$ `+ o# i3 p
1 ~$ o! I7 H. g4 }6 v& q6 ?7 h1 Y( l

/ J& |0 w; M4 W
* j+ Y4 _7 S' v' ]& w; }
- [7 ^9 i5 e9 b6 U* ^

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错" }/ C, I9 ?; M9 F0 Y& V& k" j$ A

7 G6 E* r: w5 j: Y3 _  A ** (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 p. P1 Z% r! ~* z7 c Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
- T! m& z8 R% y# c1 X' o. a& \. q2 q
5 V' n1 U' c6 Q: W5 W ** (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.
$ _3 p7 E' c- ~ Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
  x. z6 B* Y: U( a' n, J% s  X% D, }& G& Y3 Y* t" c: T
' b2 W, v* n- w" x
$ ip route list
  G! s( m! E( J8 e0 H& y+ U* O  ~! p8 h0 g, N6 \+ i4 o
default via 192.168.0.1 dev enp0s8 proto static metric 100
% n# v( L+ P& y( T default via 12.34.56.1 dev enp0s3 proto static metric 100 ; d9 O3 y+ i: {8 H% w# {
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5 # e8 [! Q. [4 U$ b1 `
12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78
- a# ~1 s' L9 s5 h1 q. d4 y2 w6 g& _) J; d
! m# Z( ]0 a" r1 ^, F- Z
会发现确实出现 2 个 default8 i% s) g) d: p) S" X6 e6 g

0 _, M5 S  G9 G当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了/ I: {1 i" h3 d9 W( C8 z6 i) l5 y: d6 |

2 Z' F. d% \- m: K$ sudo ip route del 192.168.0.1
2 c: o  y1 E1 ~2 f9 S其实只是改变了 2 个 default 的次序
" M* y# Q7 g! `; I2 \9 ~4 ~: Q6 r8 {8 `- @/ c
今天重新思考并测试:7 f  ]. @4 R3 |5 {9 u- V5 q% O
既然外网已经有网关,那么,服务器访问外网不会有问题
+ t/ _; P( j1 J- |: X( c内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!. B4 h9 O; `* O/ s6 i* I

; P6 S" h  V# W2 `/ A1 ?; A  R$ P$ cat 00-installer-config.yaml
( J; I. [$ \# _& ?- D9 L修改一下即可2 e- s. I7 l! O
) d; g  p/ Y' `3 x
   routes:$ q3 ^, _5 \! o3 G! I, r# P: H- ~
     - to: 192.168.0.0/24 # 0.0.0.0/0
) G* ]9 d1 v6 q2 K' N. W       via: 192.168.0.1
: a9 t$ }8 F' q" s- W. \       metric: 100
. w7 ]5 w# O6 U8 d4 p9 i
: z$ w5 z1 R7 c8 ^, s
# n6 W% {% |4 v, y2 H; i! ~( c2 X再次 $ sudo netplan apply 不再报错和警告
0 A0 T0 B# J7 L! x  ^- p
2 J" N1 {1 y: R9 C. g$ ip route list
- x# I: J% x, Z! N
0 p. M# Q$ V' p9 w default via 12.34.1 dev enp0s8 proto static metric 100 / E! ^) Z! q# O( x+ Q% }
192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5 / h5 C% ^! ?. G6 h7 F+ n2 [
192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100 4 J! y8 _- |2 P$ N
12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78 % h) g* }+ ~- Q* M4 ]" Y
5 Y) l6 c9 L8 _- p' j! U
; A: [  [6 Q4 R0 F
现在只有一个 default 了
5 B0 O' a+ e# R) K0 u
8 H4 H) e/ ?+ E; L其他
0 Z* J& k+ i) m/ J安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!1 E/ |% O5 q7 L* G& `
改正过来就好了!

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:
# W8 s& p3 L  |1 anetplan apply会根据gateway4生成默认路由,保留一个gateway4即可/ j; W$ R7 u4 g  o4 h
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 01:46 , Processed in 0.020321 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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