0

I'm using raspbian (kernel 4.1.19+): I want to setup the same network card on the latter to have two IPs (namely 192.168.1.9 and 10.0.0.1 on wlan0).

My /etc/network/interfaces has sections:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

auto wlan0:0
iface wlan0:0 inet static
address 10.0.0.1
netmask 255.255.255.255
gateway 192.168.1.1

and ifconfig looks like:

wlan0     Link encap:Ethernet  HWaddr ec:1a:59:0f:39:81  
          inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2236 errors:0 dropped:6 overruns:0 frame:0
          TX packets:1776 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:411452 (401.8 KiB)  TX bytes:417709 (407.9 KiB)

wlan0:0   Link encap:Ethernet  HWaddr ec:1a:59:0f:39:81  
          inet addr:10.0.0.1  Bcast:10.0.0.1  Mask:255.255.255.255
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

Should I keep on using alias or not?

I'm asking because I’ve read that those are apparently obsolete but I don't know if my wlan0 would support those (it's a Belkin Components F7D2102 802.11n N300 Micro Wireless Adapter v3000 [Realtek RTL8192CU] on USB).

If I was to remove the alias, should I type same commands but drop the :0 at the end of the interface?

9
  • 1) Using two IP addresses on a single adapter will cause you a lot of headaches unless all applications involved can bind on a particalar address. 2) Using two distinct prefixes (192.168.* and 10.0.*) on the same broadcast domain will cause you even more headaches, and worse ones. This really sounds like an XY problem. So what is the actual problem you are trying to solve? Maybe using a VLAN is the better solution?
    – dirkt
    Feb 3, 2018 at 10:25
  • The solution to your problem is really simple: Disable DHCP on the Netgear router and let Pi-Hole take care of that. Don’t touch your router’s DNS settings. Do not route all your traffic through the Pi, it will most likely severely limit your Internet speed.
    – Daniel B
    Feb 3, 2018 at 13:28
  • I thought about the same - though I'm not routing the traffic through the PI-Hole host...
    – Emanuele
    Feb 3, 2018 at 13:38
  • I’m not quite sure if you’re not accidentally doing it anyway, seeing how you now have two different subnets, if I understood correctly.
    – Daniel B
    Feb 3, 2018 at 16:11

2 Answers 2

2

They wlan0:0 etc. aliases are obsolete because they were a workaround on old Linux kernels, where it was only possible to assign a single IP address to an interface. More modern kernels allow to assign multiple IPv4 to each interface (and that as actually a requirement for IPv6).

This is an issue of the kernel; the actual WLAN driver has nothing do to with it.

So just use the modern replacement ip instead of the old ifconfig, and as mentioned in the other answer, just add a second IP to the interace stanza instead of using wlan0:0.

As long as your only purpose is to use Pi-Hole with your Neatgear N600, and you are fine with a custom routing on the Neatgear, and none of the programs you currently run on the RaspPi has any issue, it should work. BTW, you are seeing the DNS requests with a source IP from the Netgear because the Netgear itself runs a DNS proxy (to cache DNS requests, making lookup faster), just like Pi-Hole consists of a custom proxy.

If you ever run into trouble, an alternative is to make an additional network namespace on the RaspPi, but Pi-Hole into that namespace, and route from your main namespace into that namespace and back. This way you can cleanly separate the Pi-Hole and other RaspPi applications.

3
  • I really don't like Netgear policy of routing all DNS request through the gateway... anyhow... it's working for now... but may have to switch DHCP and use one only local network...
    – Emanuele
    Feb 3, 2018 at 13:41
  • Netgear doesn't "route" the request through the gatway; the Netgear runs a DNS proxy, as I said. So your machines query the DNS proxy on the Netgear, and if it hasn't cached the answer, the Netgear does a DNS query itself. That's pretty standard, many routers do that. Of course you can disable the Netgear DHCP and use your own DHCP server (e.g. on the RaspPi), but currently I don't see what advantage you get from this, except that your machines would query the Pi-Hole directly, and not indirectly (which shouldn't matter).
    – dirkt
    Feb 3, 2018 at 15:00
  • It matters in terms of logging the requests...
    – Emanuele
    Feb 3, 2018 at 15:39
1

You could simply sudo ifconfig wlan0:0 down, get rid of the auto wlan0:0 section in interfaces, and add inet 10.0.0.1 255.xxx.xxx.xxx in your ifup script.

Personally if it's working fine, I don't think it will be dropped from kernel anytime soon so I would just leave it as it's working, and I don't know what routes/forwarding rules/etc I might have added using the dev alias, also I don't know if the interface supports multiple ip addresses, etc...

But if you want to be proactive, try adding a second ip to the real interface (you may have to bring it down/down), for example, sudo ifconfig wlan0 inet 128.66.1.1 255.255.0.0 and check to see if everything works. If you have any kinks, you can iron them out now, it would save you from the trouble of troubleshooting when you happen to update a couple years later and alias turns out not to be supported anymore.

Up to you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .