welw | About_me Blog WebAssembly

Help me make my ipv4 network ipv6:

dhcp-host=5c:f9:dd:45:b8:fb,latitude,172.30.0.4,set:gw2

Answer

To transition your IPv4 network to IPv6 using dnsmasq, you need to configure both the range of IPv6 addresses to hand out and the router advertising settings. Here's an updated configuration with IPv6 enabled:

```conf dhcp-host=5c:f9:dd:45:b8:fb,latitude,[fe80::4],set:gw2

Set the default gateway for IPv6

dhcp-option=tag:gw2,option6:router,[fe80::2]

Enable IPv6 ranges for DHCPv6 and RA

dhcp-range=tag:gw1,[2001:db8:1::100],[2001:db8:1::200],64,12h dhcp-range=tag:gw2,[2001:db8:1::201],[2001:db8:1::202],64,12h

Use IPv6 servers instead of IPv4

server=[2001:4860:4860::8888] server=[2001:4860:4860::8844] server=/localdomain/[10:0:0:2::] addn-hosts=/etc/hosts

```

Notes: - Replace 2001:db8:1::/64 with an actual IPv6 prefix allocated to you. - The commented-out fe80::/64 IPs are link-local addresses and are typically auto-assigned. - The servers are transitioned to IPv6 versions; replace them if needed. - Router Advertisement (enable-ra) will automatically send prefixes to clients.

After updating this, restart dnsmasq for changes to take effect: sudo systemctl restart dnsmasq.

What if I would like to keep my ipv4 addresses and assign both v4 and v6?

```conf dhcp-host=5c:f9:dd:45:b8:fb,latitude,172.30.0.4,[2001:db8:1::4],set:gw2

DHCPv4 options

dhcp-option=tag:gw1,option:router,172.30.0.1 dhcp-option=tag:gw2,option:router,172.30.0.2

DHCPv6 options

dhcp-option=tag:gw2,option6:router,[2001:db8:1::2]

DHCPv4 and DHCPv6 ranges

dhcp-range=tag:gw1,172.30.0.3,172.30.0.100,255.255.255.0,12h dhcp-range=tag:gw1,[2001:db8:1::100],[2001:db8:1::200],64,12h

dhcp-range=tag:gw2,172.30.0.101,172.30.0.102,255.255.255.0,12h dhcp-range=tag:gw2,[2001:db8:1::201],[2001:db8:1::202],64,12h

Use IPv6 servers instead of IPv4

server=[2001:4860:4860::8888] server=[2001:4860:4860::8844] server=172.30.0.2 # Keep IPv4 server if necessary server=8.8.8.8 # Keep IPv4 server if necessary server=1.1.1.1 # Keep IPv4 server if necessary

addn-hosts=/etc/hosts

```

Key Changes:

  1. IPv6 Addresses: Added IPv6 static addresses next to IPv4 static addresses in the dhcp-host lines.
  2. DHCPv6 Ranges: Configured dhcp-range for both IPv4 and IPv6.
  3. Router Advertising: Already enabled with enable-ra which handles IPv6 routing.
  4. DNS Servers: Included both IPv4 and IPv6 DNS servers.

Instructions:

This setup will ensure that devices get both IPv4 and IPv6 addresses.