找回密码
 注册
查看: 728|回复: 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
* X" M5 e* O7 l9 x) y! u" C* Q0 w9 W5 M( y
网卡重启却能ping通外网
" B  p3 d# o1 U& M' B, |Error: Conflicting default route declarations for IPv4 (table: main, metric: default)
& A) |. P4 H$ M
' {! i1 p' Q( h+ ^1 }- _root@localhost:~# netplan apply
3 ^1 W* V0 `+ Z+ R% j9 ~4 S, k9 G" H: `$ z8 g( `
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.( v; {) q! F$ X
See the 'Default routes' section of the documentation for more details." M+ F! z; E( h  w. d+ i
, n* u/ e+ }1 d: J3 \. k
** (generate:62439): WARNING **: 07:58:24.498: `gateway4` has been deprecated, use default routes instead.  u# n/ a" a  [0 s
See the 'Default routes' section of the documentation for more details." ?3 \- L+ C2 G- ?+ f) f
6 u0 G5 B; ^# s. y' B. b
** (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.
/ r/ n. U3 \: r/ T8 b) q  m5 OError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3& g. Y7 q6 \% U8 J& p/ w5 b. g
+ \) h0 T' S* |
** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead." n8 ]" o& [" s8 Y$ C
See the 'Default routes' section of the documentation for more details.) a( c3 X7 {8 {* }6 a2 h& ]

% U, x0 d8 h! {2 G9 V* x! C** (process:62437): WARNING **: 07:58:24.812: `gateway4` has been deprecated, use default routes instead.% ]1 T* [8 C1 S3 U8 ?) Q2 y
See the 'Default routes' section of the documentation for more details.. b& m' f: \4 D4 h
* q, C6 e. f) w  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.2 Q2 b' t; h4 g) L$ g- s- w8 q" M
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
5 L& ~% E1 z3 l+ \2 Z9 c+ m% I
2 C+ g+ S2 n! B, H# v4 C2 E( N** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.
4 i# ]& Q; e# w) p: ASee the 'Default routes' section of the documentation for more details.$ \" |. e% b3 P: j- m. f

1 k0 B5 q5 Y& j+ J. B: A9 P( G4 |** (process:62437): WARNING **: 07:58:24.822: `gateway4` has been deprecated, use default routes instead.) M, I5 _" C1 E
See the 'Default routes' section of the documentation for more details.
* R5 v( t4 D7 t$ l5 J
- k5 u/ k: l. R' z" j** (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.; N& c2 C( ^0 q# U5 e) o
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3- i5 ~8 H9 D. h8 q: {( X. t; P
' c' i9 e: L9 ?. d8 p
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.- j% U( `( h$ P, ^
See the 'Default routes' section of the documentation for more details.
- I- Z7 i% a( ]) p* J& H: X: b$ o. B$ }
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
& k& w1 e6 h3 ^4 _See the 'Default routes' section of the documentation for more details.
% m, E0 k. V5 ^- f8 \, Z% \' }5 ^( r
3 W7 [2 [8 g2 `2 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.
  h5 |% j1 R( \/ Q) pError: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3
, Z2 s6 M! |* ^  [
8 }; C! I" k- ?- D. A5 l** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.0 X+ p0 P$ w) s1 K+ d/ d
See the 'Default routes' section of the documentation for more details.4 O6 O1 ~: N8 U- t6 M/ {- W4 }
+ I( K+ y6 c: `. V' {2 d- B
** (process:62437): WARNING **: 07:58:25.134: `gateway4` has been deprecated, use default routes instead.
2 o) n# l" H* I2 O; g: V7 oSee the 'Default routes' section of the documentation for more details.  Z% ]: l1 h3 V& O

2 ~3 e& v: W3 N/ a1 ~** (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.
8 S' g! f" h( o% }7 ~Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in enp9s0 but also in vlan3! V+ f, Q) t* r% c/ y2 I

- ^; P* C& i, |. u: g9 P) Z1 w, X# R& j$ j7 s; H# w# h

$ m9 ^: u& O; N- O
' k: J# K: H( w
  }, ]# h0 ]3 ?: {

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:20:38 | 显示全部楼层
但是 $ sudo netplan apply 出现警告和报错
( R; u& g! T5 F2 B  ?' ^; `7 T* U. X0 |* T
** (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.
. e3 p" |6 _' r9 Z9 D! N Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s3
) a% {+ ]; u! m( `. H# I/ B
/ g9 m, d" D) 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.
" c4 z8 ~. G7 G& C6 I% b! X Error: Conflicting default route declarations for IPv4 (table: main, metric: 100), first declared in enp0s8 but also in enp0s37 ?5 r6 _1 e! }: s+ R, s
. F% g5 t7 P" p8 _- b- c
" ]  K  A+ a( t: y3 Y0 \
$ ip route list' }% |" M; N0 `9 T

/ n3 I! d! f3 N0 C- j0 ?2 |+ Y default via 192.168.0.1 dev enp0s8 proto static metric 100
) j0 S9 I! H: z6 N default via 12.34.56.1 dev enp0s3 proto static metric 100 - Q  H7 {8 p: [: q' G3 a& n
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.5
9 O! \# ~# \) B# _ 12.34.560/28 dev enp0s3 proto kernel scope link src 12.34.56.78
* a( B$ }$ \6 D6 o. ?( a4 @+ Z+ q! I" b/ r5 O/ F
2 m* H6 X* E+ O) o. q6 B, Q
会发现确实出现 2 个 default( o2 `, n5 R9 Y0 S- X* x

  U" `: G( c3 d5 a) u0 h8 x* s# r当时在实际环境,着急使用,所以,简单删除了内网的route,可以正常使用了# }0 |3 O: F3 D- m: d' U( o: J) \" j

6 f1 S. k6 P9 _' j$ sudo ip route del 192.168.0.1
, R5 c8 X$ W2 {& r8 p8 a其实只是改变了 2 个 default 的次序
$ j# F2 B5 [5 Y7 C) ^
/ h# H& i8 p: b, Z: g/ m今天重新思考并测试:# ~3 \# e5 U# Z; z( h
既然外网已经有网关,那么,服务器访问外网不会有问题
: {; R8 o: }) J$ M( E内网访问其他资源,应该仅限于内网区域,所以,修改他的 to 就应该可以了!, C; e7 Q  i* K9 y* ?

( J5 X# s  S0 Z- ~$ cat 00-installer-config.yaml5 q1 M' |, [& _+ P) L
修改一下即可9 p& x/ N% c  G1 s  Q

! U  G1 @% I; c6 j2 T; G& `   routes:
2 t- o' L7 R: F/ p4 h     - to: 192.168.0.0/24 # 0.0.0.0/0) r! E/ U  D# {. G. T, T
       via: 192.168.0.1+ G- @! \9 P6 F3 ?, b
       metric: 100
/ y, |) C' J. P  Z/ s! [
0 G7 I6 {( C3 r2 {4 t* `  q
9 `2 W- s( C& S4 s0 }/ p  J* e6 J再次 $ sudo netplan apply 不再报错和警告
6 b  R$ S' X0 f5 y! X; U# r$ ~
% u, p" K. ^* V* u! ?8 |$ ip route list
( M) }* h) g9 o- b! s/ m6 I% \# U- v/ s( f
default via 12.34.1 dev enp0s8 proto static metric 100
# t* g; U4 y1 G5 L 192.168.0.0/24 dev enp0s3 proto kernel scope link src 192.168.0.5   z/ m$ u' g% b- V. `6 k; }
192.168.0.0/24 via 192.168.0.81 dev enp0s3 proto static metric 100
4 i  S. Q$ u" d& z) h4 i4 X) E 12.34.56.0/28 dev enp0s8 proto kernel scope link src 12.34.56.78
& X) l- I% k7 w* J5 D
9 c$ b0 p# o8 @& k, |: T6 a; M: }5 I# I6 w4 s
现在只有一个 default 了) D4 G: B( i4 q
' X; C7 e: g3 {2 P, ]& t0 J; ~* S7 y  L
其他  J" c) R- U' E3 X( ]/ z
安装设置虚拟机时,特意将外网卡放在前面,但是,不知道为什么,他竟然网卡名字对应反了,结果,apt update 时报错,ping 外网死活不通!& `, c5 }4 k8 p3 J) N& s
改正过来就好了!

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-6-11 16:44:07 | 显示全部楼层
解决方法:
0 w! y; H0 m7 Nnetplan apply会根据gateway4生成默认路由,保留一个gateway4即可9 ^6 S3 e9 p8 c' l
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 00:48 , Processed in 0.106355 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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