TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

DHCP is not blocked by ufw/iptables

182 pointsby timostalmost 2 years ago

13 comments

SamuelAdamsalmost 2 years ago
Wait until they learn about Docker ignoring iptable rules.<p><a href="https:&#x2F;&#x2F;www.baeldung.com&#x2F;linux&#x2F;docker-container-published-port-ignoring-ufw-rules" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.baeldung.com&#x2F;linux&#x2F;docker-container-published-po...</a>
评论 #36897154 未加载
评论 #36900156 未加载
评论 #36896415 未加载
评论 #36899410 未加载
评论 #36898898 未加载
评论 #36901416 未加载
评论 #36898904 未加载
评论 #36901681 未加载
评论 #36900115 未加载
yomlica8almost 2 years ago
Can anyone recommend a decent book on linux firewalls, iptables and the like? Every time I wade into this I feel I&#x27;m missing to much base knowledge to make good decisions.
评论 #36896815 未加载
评论 #36898213 未加载
评论 #36896501 未加载
评论 #36898597 未加载
评论 #36913360 未加载
tambourine_manalmost 2 years ago
It’s these kinds of things that makes me realize I don’t really know what I’m doing regarding networks. I would never have imagined.<p>Even FreeBSD’s stack, which was always much more straightforward to me, behaves like this, it seems. There’s no hope.
评论 #36900850 未加载
binkHNalmost 2 years ago
FWIW, this is the same behavior on OpenBSD—DHCP listens directly on bpf, which sees traffic before the packet filter.
le-markalmost 2 years ago
That is a surprising revalation; that iptables filters traffic depending on Linux implementations details. One could imagine the outcry if firewall vendor X suffered a similar “feature”. Or is this well known for Linux iptable users?
评论 #36896455 未加载
评论 #36897762 未加载
评论 #36896550 未加载
评论 #36901138 未加载
评论 #36897221 未加载
allanrboalmost 2 years ago
Even within iptables &#x2F; nftables &#x2F; nft there&#x27;s a ton of places to hook in. I always need to take a long hard look at this diagram to get it right: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Iptables#&#x2F;media&#x2F;File:Netfilter-packet-flow.svg" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Iptables#&#x2F;media&#x2F;File:Netfilter...</a>
Joel_Mckayalmost 2 years ago
if you have systemd&#x2F;Netplan&#x2F;docker, than expect chaotic firewall states.<p>Each can drop some nasty use-case specific assumptions that cause odd issues in other areas.<p>Happy computing =)
评论 #36899601 未加载
josephcsiblealmost 2 years ago
For people who wish this weren&#x27;t the case, would you want tools like tcpdump and Wireshark to also only see packets that the firewall allows? If not, then what change would you propose exactly that changes the former without breaking the latter?
评论 #36898806 未加载
1vuio0pswjnm7almost 2 years ago
But could it be blocked using eBPF<p><a href="https:&#x2F;&#x2F;docs.kernel.org&#x2F;networking&#x2F;filter.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;docs.kernel.org&#x2F;networking&#x2F;filter.html</a>
m463almost 2 years ago
I&#x27;ve just disabled those exceptional rules when dhcp isn&#x27;t required.<p>I&#x27;m wondering if this is:<p>- a default configuration situation (which I think I rectified)<p>- DHCP exception hardcoded in the firewall binaries
anfractuosityalmost 2 years ago
Intriguing, so there&#x27;s no way to block DHCP from Linux at all as all firewalls such as ufw&#x2F;nftables&#x2F;iptables, would use netfilter behind the scenes?
评论 #36899572 未加载
评论 #36898746 未加载
评论 #36899762 未加载
评论 #36900444 未加载
评论 #36900895 未加载
jas-almost 2 years ago
ARP? Don’t you need arptables for this? OSI model 101
pseudosavantalmost 2 years ago
Had an interesting exchange with chatgpt&#x2F;gpt4 about this. Initially gets it wrong, but then explains it really well after being corrected with this link. Apparently Windows has similar default behavior too.<p>Me: Is DHCP affected by iptables firewall rules on Linux?<p>GPT: Yes, DHCP (Dynamic Host Configuration Protocol) traffic can be affected by iptables firewall rules on a Linux system.<p>iptables can be used to filter network traffic, and it does this by checking each network packet against a set of rules. If a rule matches the packet, a specific action is taken (such as allowing the packet through, dropping it, or logging it).<p>For DHCP, which uses UDP, the communication usually happens over port 67 for the DHCP server and port 68 for the DHCP client. If there are iptables rules that block these ports, it could prevent the DHCP from functioning correctly.<p>For instance, if you want to allow DHCP traffic, you might need to include rules such as these in your iptables configuration:<p>``` iptables -A INPUT -p udp --dport 67:68 --sport 67:68 -j ACCEPT iptables -A OUTPUT -p udp --dport 67:68 --sport 67:68 -j ACCEPT ```<p>The exact rules you need will depend on your specific setup and requirements. Always remember to test your configuration thoroughly to ensure it&#x27;s working as expected.<p>Me: This suggests that answer is incorrect. <a href="https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;447440&#x2F;ufw-iptables-not-blocking-dhcp-udp-port-67#447524" rel="nofollow noreferrer">https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;447440&#x2F;ufw-iptables...</a><p>GPT: I apologize for the confusion. The interaction between DHCP and iptables is indeed more nuanced than my previous message indicated.<p>When a machine requests an IP address using DHCP, it doesn&#x27;t have an IP yet, so the DHCP server sends the reply to the broadcast IP, which is typically 255.255.255.255. Linux has a kernel parameter called `rp_filter` (Reverse Path Filtering), which by default allows these broadcast packets through, bypassing any iptables rules. This is because the kernel recognizes that these packets are part of a legitimate IP address assignment process, so it allows them in despite any firewall rules.<p>So in practice, while DHCP does technically use ports that could be blocked by iptables, the Linux kernel generally ensures that DHCP traffic is allowed through anyway. This behavior is fundamental to the operation of DHCP, and trying to change it could break your system&#x27;s ability to obtain an IP address.<p>Me: How does the Windows firewall handle DHCP filtering, or not?<p>GPT: The Windows Firewall handles DHCP traffic similarly to other traffic, but with some built-in allowances because of how critical DHCP is for network connectivity.<p>By default, Windows Firewall has predefined rules to allow DHCP traffic. DHCP uses UDP port 67 for servers and UDP port 68 for clients. The firewall rules permit these inbound and outbound connections so that a DHCP client can obtain an IP address from a DHCP server.<p>However, unlike typical firewall rules, the rules for DHCP are handled a bit differently because, at the time of the DHCP process, the client does not yet have an IP address. For this reason, the DHCP process cannot be subject to standard IP address-based filtering rules.<p>In the default configuration, Windows Firewall will not block DHCP traffic because this would disrupt network connectivity. But a user could technically create custom rules to block DHCP; this would likely cause significant network problems, and therefore it&#x27;s not recommended.<p>As a reminder, DHCP is a fundamental protocol for IP networks, enabling devices to request and receive an IP address and thus communicate on the network. Blocking DHCP traffic would typically prevent a device from obtaining an IP address, thereby blocking network access.<p><a href="https:&#x2F;&#x2F;chat.openai.com&#x2F;share&#x2F;6e02686c-a330-4efe-b261-1e0d09ac54ed" rel="nofollow noreferrer">https:&#x2F;&#x2F;chat.openai.com&#x2F;share&#x2F;6e02686c-a330-4efe-b261-1e0d09...</a>