|
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | +<HTML> |
| 3 | + <HEAD> |
| 4 | + <TITLE> [squid-users] Running squid in a network namespace |
| 5 | + </TITLE> |
| 6 | + <LINK REL="Index" HREF="index.html" > |
| 7 | + <LINK REL="made" HREF="mailto:squid-users%40lists.squid-cache.org?Subject=Re%3A%20%5Bsquid-users%5D%20Running%20squid%20in%20a%20network%20namespace&In-Reply-To=%3CCACnYWRfDjcXkbFq6VvsWCDv87-Ju4-36cJRZG1MSXtYPHhz-jQ%40mail.gmail.com%3E"> |
| 8 | + <META NAME="robots" CONTENT="index,nofollow"> |
| 9 | + <style type="text/css"> |
| 10 | + pre { |
| 11 | + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ |
| 12 | + } |
| 13 | + </style> |
| 14 | + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
| 15 | + |
| 16 | + |
| 17 | + </HEAD> |
| 18 | + <BODY BGCOLOR="#ffffff"> |
| 19 | + <H1>[squid-users] Running squid in a network namespace</H1> |
| 20 | + <B>Ruben Di Battista</B> |
| 21 | + <A HREF="mailto:squid-users%40lists.squid-cache.org?Subject=Re%3A%20%5Bsquid-users%5D%20Running%20squid%20in%20a%20network%20namespace&In-Reply-To=%3CCACnYWRfDjcXkbFq6VvsWCDv87-Ju4-36cJRZG1MSXtYPHhz-jQ%40mail.gmail.com%3E" |
| 22 | + TITLE="[squid-users] Running squid in a network namespace">rubendibattista at gmail.com |
| 23 | + </A><BR> |
| 24 | + <I>Sun Jan 4 01:35:40 UTC 2026</I> |
| 25 | + <P><UL> |
| 26 | + |
| 27 | + |
| 28 | + <LI> <B>Messages sorted by:</B> |
| 29 | + <a href="date.html#27733">[ date ]</a> |
| 30 | + <a href="thread.html#27733">[ thread ]</a> |
| 31 | + <a href="subject.html#27733">[ subject ]</a> |
| 32 | + <a href="author.html#27733">[ author ]</a> |
| 33 | + </LI> |
| 34 | + </UL> |
| 35 | + <HR> |
| 36 | +<!--beginarticle--> |
| 37 | +<PRE>Hello, |
| 38 | + |
| 39 | +I have a network namespace which runs a Wireguard VPN (only). |
| 40 | + |
| 41 | +`` |
| 42 | +❯ ip l |
| 43 | +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode |
| 44 | +DEFAULT group default qlen 1000 |
| 45 | + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 |
| 46 | +3: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state |
| 47 | +UNKNOWN mode DEFAULT group default qlen 1000 |
| 48 | + link/none` |
| 49 | +``` |
| 50 | + |
| 51 | +I'd like to run squid inside this network namespace. I normally do this |
| 52 | +using a systemd unit, for example for tinyproxy: |
| 53 | + |
| 54 | +``` |
| 55 | +❯ systemctl cat tinyproxy |
| 56 | +# /usr/lib/systemd/system/tinyproxy.service |
| 57 | +[Unit] |
| 58 | +Description=Tinyproxy Web Proxy Server |
| 59 | +After=network.target |
| 60 | + |
| 61 | +[Service] |
| 62 | +Type=forking |
| 63 | +ExecStart=/usr/bin/tinyproxy -c /etc/tinyproxy/tinyproxy.conf |
| 64 | +ExecReload=/usr/bin/kill -USR1 $MAINPID |
| 65 | +PIDFile=/run/tinyproxy/tinyproxy.pid |
| 66 | +PrivateDevices=yes |
| 67 | + |
| 68 | +[Install] |
| 69 | +WantedBy=multi-user.target |
| 70 | + |
| 71 | +# /etc/systemd/system/tinyproxy.service.d/override.conf |
| 72 | + |
| 73 | +[Service] |
| 74 | +NetworkNamespacePath=/run/netns/vpn |
| 75 | +BindReadOnlyPaths=/etc/netns/vpn/resolv.conf:/etc/resolv.conf:norbind |
| 76 | + |
| 77 | +[Unit] |
| 78 | +After=vpn.service |
| 79 | +BindsTo=vpn.service |
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +But if I do the same with the systemd unit of squid, it doesn't work. The |
| 84 | +proxy process still runs within the standard namespace (if I curl using the |
| 85 | +proxy, the IP is the one of the standard namespace) |
| 86 | + |
| 87 | +Anyone got any ideas? |
| 88 | + |
| 89 | + |
| 90 | +-- |
| 91 | + .. |
| 92 | + /**\ |
| 93 | + /****\ |
| 94 | + /\****/\ |
| 95 | + / \**/ \ |
| 96 | + / \/ \ |
| 97 | + / /\ /\ |
| 98 | + / \ / \ / \ |
| 99 | + / \ / \/ \ |
| 100 | + \ /\ /\ / |
| 101 | + \ / \ / \ / |
| 102 | + \/ \/ \/ |
| 103 | + /\ |
| 104 | + / +\ |
| 105 | + \+ / |
| 106 | + \/ |
| 107 | + rdb.is |
| 108 | + Book a meeting with me: |
| 109 | + <A HREF="https://calendly.com/rdbisme">https://calendly.com/rdbisme</A> |
| 110 | +-------------- next part -------------- |
| 111 | +An HTML attachment was scrubbed... |
| 112 | +URL: <<A HREF="http://lists.squid-cache.org/pipermail/squid-users/attachments/20260104/6eba12cc/attachment.htm">http://lists.squid-cache.org/pipermail/squid-users/attachments/20260104/6eba12cc/attachment.htm</A>> |
| 113 | +</PRE> |
| 114 | + |
| 115 | +<!--endarticle--> |
| 116 | + <HR> |
| 117 | + <P><UL> |
| 118 | + <!--threads--> |
| 119 | + |
| 120 | + |
| 121 | + <LI> <B>Messages sorted by:</B> |
| 122 | + <a href="date.html#27733">[ date ]</a> |
| 123 | + <a href="thread.html#27733">[ thread ]</a> |
| 124 | + <a href="subject.html#27733">[ subject ]</a> |
| 125 | + <a href="author.html#27733">[ author ]</a> |
| 126 | + </LI> |
| 127 | + </UL> |
| 128 | + |
| 129 | +<hr> |
| 130 | +<a href="https://lists.squid-cache.org/listinfo/squid-users">More information about the squid-users |
| 131 | +mailing list</a><br> |
| 132 | +</body></html> |
0 commit comments