找回密码
 注册
查看: 734|回复: 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
" h. @5 }! }8 i0 j. i
+ ~- w" r6 @4 e* p8 t! c网卡重启却能ping通外网2 @7 |, `8 v  u# G
Error: Conflicting default route declarations for IPv4 (table: main, metric: default)
: D# Q, L& ?  J/ {( \8 H0 u
# O6 P. N$ S) Xroot@localhost:~# netplan apply
5 u- b6 E- H. b
& z$ K3 ~4 V! i6 M6 B, z& a# L& V** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.) o9 o* }/ Q* b& ^. N( V
See the 'Default routes' section of the documentation for more details.
4 c( C& P+ z0 a' v4 X( z9 o
5 d2 v1 y/ \$ X: W2 ~; \** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.
5 N, p6 M# z7 eSee the 'Default routes' section of the documentation for more details.
4 n# H+ p: t3 f$ A3 N% n5 ^  s  F' o9 K0 `
** (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.# _, _" ]+ }) Z$ R) B
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan34 l5 U4 N7 h1 [( ?
! {- X3 ?- j4 G" Y/ Q2 E3 g
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.% I& A( i* s* |( X' a$ |  A
See the 'Default routes' section of the documentation for more details.* }5 s4 T1 k2 u' Q5 h& N/ Y: x

2 J: f. }  N* {' [5 z** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.! Z: n1 L4 Y; z* y  P3 I. T
See the 'Default routes' section of the documentation for more details.; y$ J7 m2 l+ D) a  V9 p1 Y. @2 u
6 n& s7 m" E) |8 C" D" c7 J+ F
** (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.
1 i( S2 g5 {# F# h5 {$ c, u, q. IError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
& h2 z  \9 H5 Q5 h* \, O) P5 }( D( o# E% _/ f3 g% \: v
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
4 z! x9 I; a7 X$ [' k8 N# CSee the 'Default routes' section of the documentation for more details.
. L& `$ a" A* R1 I/ w7 Z* c8 d7 I# u# p3 X" i0 i# I  V, X
** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
7 @  h% r; z4 E' y" f; V7 f6 ZSee the 'Default routes' section of the documentation for more details.  _+ @3 F8 M& s  _: r5 N  ^+ N
4 l- `5 O/ J' x" Z0 J) V2 {
** (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.
( E& o" A! B/ x7 N  g5 w8 k. tError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
+ ]- j3 j8 g, Z3 I4 o: U+ i* x' v) v* K; O/ G7 q6 |
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.# P" |6 s6 I  }7 F  ]. W
See the 'Default routes' section of the documentation for more details.
5 C. p, |/ l# ]4 h+ w# O; _7 ]& m7 k9 V9 w, o( t* \1 U
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
' k. r- }% `2 o8 ?$ s' ~" XSee the 'Default routes' section of the documentation for more details.
8 L( ~1 p) w! [0 |5 r8 q7 M
) e; u  K! }8 @$ g& N( W** (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.- t% R0 h3 u2 v+ b  V
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan39 b# j) O- a" Y, ^

: b: d" d% A8 G2 v6 x( P7 w** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.' x" P8 ]' E" ^/ h, e
See the 'Default routes' section of the documentation for more details.
8 ^2 A  S1 g9 a; c4 D
7 ^  z- m3 ]% ~0 E& C1 |4 V** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.' g1 \% V7 @7 v$ M2 T
See the 'Default routes' section of the documentation for more details.
, j0 ?+ g- f/ ~! u4 A
/ A! V, y2 _2 M( W  s* B** (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.
. p. K2 @* H1 K% i. Z. }7 fError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3% m' @9 U* S$ g: A( s1 E3 Q

9 F5 S8 V0 }; \# C' C. w- L
" X( U/ L% \* G( j0 I9 q. h$ h) I# V* M* s; o1 r
7 @0 }( J1 p7 i5 Y) Z3 o0 L3 \5 ]* l
3 `9 t& {! o, U% H) Z- P/ ?9 S

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错3 [+ i$ {6 R" }; u' g9 \

8 Z* c! ^# I$ G( P, W! l3 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.0 D! F7 w& H2 S- v+ a- y
Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
. K9 v, a8 o. m ; V# e- Y# E8 p4 Q7 c
** (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.5 g2 V5 f& E) l$ Z, {; y7 g
Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s30 L! F& d+ d. q3 `8 _# s, {

/ x+ X, M$ J; N& H$ h; }. M
, O, f/ z! X+ k, ?$ ip route list  m7 I6 B- d5 i. ]3 d/ T+ p

7 |( b. M& E& C$ @$ ?- w8 g9 @8 ?( ] default via 192.168.0.1 dev enp0s8 proto static metric 100 * j& S5 s5 _: d* `7 E
default via 12.34.56.1 dev enp0s3 proto static metric 100
5 {/ H* ?8 `% n! G- E/ Z$ P4 h) ~ 192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5 . }- G& ?( ~+ o, S. d- R& l
12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78
4 p6 I* i6 O4 z  M8 _; u. G2 H, D1 e3 ^- R6 l! e! A$ I' D; d! L. U3 ]+ T+ M
; G& {$ I9 ?+ I( t# J' ?4 P0 ]
会发现确实出现 2 个 default
, b" e, o. [6 ?8 y( J
* m- @( e$ h0 P! M( S% Z  l当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了
; a4 P' E4 L  D: j0 a' u
+ m0 b( j) r" P$ sudo ip route del 192.168.0.1
8 A5 a* \' n+ K" Q4 T* M其实只是改变了 2 个 default 的次序
! B% ^9 ]+ X5 N( S9 R
* _5 M$ w+ K  A今天重新思考并测试:
4 N( W* ]) r- `* R; o3 a/ c' i既然外网已经有网关,那么,服务器访问外网不会有问题
, }" t+ ]$ m; J% j& e* g6 F内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!
) m+ v. w; v9 I. s3 w9 C* p/ q& P" c% j) }- h" j
$ cat 00-installer-config.yaml, H% f+ q( h$ }8 |: F2 n
修改一下即可( r0 y5 B! w- ^4 d0 z) ?* n8 |1 C; }

4 [/ f1 O- `! ?) N7 G" u, w   routes:. I2 e; o, v' c+ \9 R- W
     - to: 192.168.0.0/24 # 0.0.0.0/04 F4 F! o7 |$ z; Q9 A' V$ N
       via: 192.168.0.1% T. H2 c% I& Q5 j
       metric: 100
- Q  B: B- k8 w9 m: U# m$ h% ]$ A* }) R5 e4 W+ V& t4 J

6 z$ o) @* Z4 e5 q$ s5 ^再次 $ sudo netplan apply 不再报错和警告7 ]- {3 U3 P1 A) F7 `

" F5 j: r3 {& D8 a$ ip route list! C  `! ~& l- y  _7 J  |
: h3 v/ K4 R5 D6 i$ l
default via 12.34.1 dev enp0s8 proto static metric 100
' W; n) n! l) e) a0 C7 ?0 z 192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5
) u" h" h4 j+ h 192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100
- g9 s  Q1 |0 T6 k6 f1 a) J+ q- J: E% \ 12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78
* C/ [' x0 x. f! Z" B  X* S- b$ G) L$ J3 w: ^
* T" }" K; H( P, X! c, h
现在只有一个 default 了  A' ]/ Q* h! Q) j; l0 ^4 d4 Z

* ?/ }, L1 G6 H, t/ b其他
# W; a; H$ `* V5 }2 A安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!- q2 z3 @: @2 D7 X1 q" T7 C3 L* ]
改正过来就好了!

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:, b% X; R4 |7 M9 j" C! o
netplan apply会根据gateway4生成默认路由,保留一个gateway4即可
, c8 d7 ?5 K3 q1 H
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 04:28 , Processed in 0.015865 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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