Skip to content

Commit f72115e

Browse files
committed
Configure only a single gateway if there are multiple interfaces.
1 parent cad00de commit f72115e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Containerization/LinuxContainer.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ extension LinuxContainer {
500500
// For every interface asked for:
501501
// 1. Add the address requested
502502
// 2. Online the adapter
503-
// 3. Add the gateway address
504503
for (index, i) in self.interfaces.enumerated() {
505504
let name = "eth\(index)"
506505
try await agent.addressAdd(name: name, address: i.address)
507506
try await agent.up(name: name)
508-
try await agent.routeAddDefault(name: name, gateway: i.gateway)
507+
}
508+
// Configure the gateway only on the first interface
509+
if !self.interfaces.isEmpty {
510+
try await agent.routeAddDefault(name: "eth0", gateway: self.interfaces[0].gateway)
509511
}
510512
if let dns = self.dns {
511513
try await agent.configureDNS(config: dns, location: rootfs.destination)

0 commit comments

Comments
 (0)