MTU Settings, DNS Configuration & Custom /etc/hosts Entries
Tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups.
In plain words
Tune MTU from the path’s real overhead, set DNS resolvers at runtime for controlled environments and reserve extra_hosts for rare immutable aliases.
Think of it like…
MTU is bridge clearance for the largest truck, DNS is a directory and /etc/hosts is a handwritten sticky note.
Where you’ve seen it
In practice, docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test is the concrete move for this job: tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. The release is not accepted until use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db confirms the result.
Words you’ll hear
- MTU
- The implementation control in
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:testfor tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. - DNS Config
- The result to observe with
use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db, rather than infer from a successful command alone. - extra_hosts
- The production boundary exposed when setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
Visual diagram
Theory & deep dive
MTU control path
The concrete mechanism is docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test. The observable result is use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db; if those disagree, inspect the runtime evidence before changing unrelated settings.
Tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. Keep MTU, DNS Config and extra_hosts in the same deployment record so the intent and the observed state cannot drift apart.
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test
use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db, not with command success alone.extra_hosts failure boundary
An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes. The narrow failure to design for is setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
Accept this compromise explicitly: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking. The controlled check-use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db-also identifies the point where a different design is safer.
Exercise this failure safely: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.
- Intent
- MTU
When to use it & trade-offs
What it is
MTU controls maximum packet/frame payload before fragmentation or tunneling. Docker can set network MTU and --dns values; extra_hosts writes a host-to-IP entry in container /etc/hosts. These mechanisms solve different problems and should not be mixed.
Why it matters: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.
When to reach for it
- The fit is strongest for this job: tune MTU, custom DNS, and extra hosts entries for tricky cloud and VPN setups. Pair it with
use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-dbin the runbook. - Production MTU changes should make DNS Config observable through
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test, rather than trusting the runtime default. - Keep a rollback example for the case where setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
When to avoid or be careful
- Do not accept command success while the system can still fail by setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.
- Avoid erasing extra_hosts protection merely to dodge this cost: “Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking”.
- Do not replace the evidence path-
use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db-with a screenshot or a mutable tag.
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test: practical choices
Strengths: MTU controls maximum packet/frame payload before fragmentation or tunneling. Docker can set network MTU and --dns values; extra_hosts writes a host-to-IP entry in container /etc/hosts. These mechanisms solve different problems and should not be mixed.
Watch out: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.
Strengths: It can begin with docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test and fewer surrounding controls.
Watch out: It silently accepts setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it, which makes the result hard to reproduce after promotion.
Strengths: An MTU larger than the VPN/overlay path causes large requests to hang while ping still works. extra_hosts bypasses embedded DNS and becomes stale when a service moves; custom /etc/resolv.conf in an image loses platform-specific changes.
Watch out: The platform adds an ownership and debugging layer; retain use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db as the direct check.
Interview signals & numbers to know
When this topic comes up
- docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test
- use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db
- Failure signature: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it
- Trade-off: Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.
Benchmarks & rules of thumb
- 1450 bytes
- example overlay/VPN-safe MTU
- 28 bytes
- typical IPv4+ICMP overhead used in a do-not-fragment ping calculation
- 1.1.1.1
- public DNS example, not necessarily an approved enterprise resolver
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:testas proof and skippinguse ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db. - Setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it
- Optimizing MTU without accepting that path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking.
Likely interviewer follow-ups
- Why does
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:testaddress MTU here rather than through application code? - How would you distinguish healthy DNS Config from the failure “setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it” using
use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db? - When would this trade-off-“Path-MTU correctness removes mysterious stalls; static hosts entries are easy but lose dynamic service discovery and lifecycle tracking”-justify a different extra_hosts design?
docker network create --opt com.docker.network.driver.mtu=1450 tunnel-net; docker run --dns 1.1.1.1 --add-host legacy-db:10.20.0.4 app:test-and one proof-use ping -M do -s 1422 under a Linux host and compare DNS and getent hosts legacy-db. Then name the boundary: setting MTU to 9000 because the host has jumbo frames, without proving the VPN/overlay path supports it.Knowledge check
Put it into practice
Practice related interview Q&A
Apply MTU Settings, DNS Configuration & Custom /etc/hosts Entries with generative AI interview Q&A and hands-on practice.