Score:0

Force DHCP client to use only IPv4

ng flag

I have Linux client (running systemd-networkd, version 244), and I want to configure it's network only with IPv4. However, the DHCP server offers both v4 and v6. Is it possible to limit the client to only take the IPv4 configuration?

I configured the DHCP client to ipv4. The network configuration file looks like this:

~# cat /etc/systemd/network/80-wlp10s0.network 

[DHCPv4]
UseRoutes=false

[Link]
MTUBytes=1500
Unmanaged=no

[Match]
Name=wlp10s0

[Network]
DHCP=ipv4
IPForward=no

[Route]
Destination=192.168.1.0/24
Gateway=192.168.2.34
GatewayOnLink=yes

And yet, I get both ipv4 and ipv6 addresses configured:

~# ifconfig wlp10s0   
wlp10s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.2.136  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::6f0:21ff:fe5a:ee8  prefixlen 64  scopeid 0x20<link>
        ether 04:f0:21:5a:0e:e8  txqueuelen 1000  (Ethernet)
        RX packets 33043  bytes 22019800 (20.9 MiB)
        RX errors 0  dropped 2913  overruns 0  frame 0
        TX packets 20144  bytes 11873580 (11.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

PS. I do want to disable IPv6 entirely. A different network interface can be configured to use IPv6.

vidarlo avatar
ar flag
Does this answer your question? [How to disable ipv6 support in Linux entirely?](https://serverfault.com/questions/660979/how-to-disable-ipv6-support-in-linux-entirely)
user951769 avatar
ng flag
No. A different network interface can be configured to use IPv6, therefore removing IPv6 entirely is not a good solution. This would be a very radical fix for a configuration option.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.