Gentoo Archives: gentoo-user

From: "Florian Gamböck" <ml@×××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?
Date: Wed, 19 Apr 2017 10:46:21
Message-Id: 20170419102321.GA2268@furore
In Reply to: Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously? by Mick
1 On 2017-04-18 20:41, Mick wrote:
2 > I can think of at least two ways you can attempt to achieve what you
3 > want.
4 >
5 > 1. Set the Raspi to use DHCP only
6 >
7 > Assuming you have access to your home's router, you can configure on
8 > it a static IP address for the MAC address of the Raspi. The home
9 > router will not allocate any such reserved IP address to any other
10 > device, but reserve it for the Raspi's MAC address.
11 >
12 > At work the Raspi will obtain a random IP address from the work's
13 > router as expected. This is by far the simplest option.
14 >
15 > The line you need in /etc/conf.d/net of the Raspi will look like this:
16 >
17 > config_eth0="dhcp"
18 >
19 > (Change eth0 above for the name of Raspi's wireless interface).
20
21 That's what I've been doing in the past, but my Cisco router had
22 problems with that. It tried to give away addresses I have specifically
23 reserved and it ended up cutting the connections and refusing to let new
24 machines connect as long as there was a conflict.
25
26 Besides, I like having configuration files on my computers, which I can
27 exchange and adjust as I like, without the need to click through heavily
28 overloaded router configuration WebApps.
29
30 > 2. Configure the Raspi to selectively set itself a static IP address
31 >
32 > In this option you will set up in the Raspi's /etc/conf.d/net a static
33 > IP address 192.168.0.10/24, when the gateway matches the wireless MAC
34 > address of the home router. For any other gateway the Raspi will fall
35 > back to using dhcp.
36 >
37 > Something like this should work:
38 >
39 > # Define the gateway you want to configure
40 > gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"
41 >
42 > # Define the default route for gateway 192.168.0.254
43 > routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"
44 >
45 > # Define the IP and netmask when using gateway 192.168.0.254
46 > config_192168000254_AABBCCDDEEFF="192.168.0.10/24"
47 >
48 > # Define the DNS servers to use with gateway
49 > dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"
50 >
51 > # Then you need to add a line for all other routers the Raspi may
52 > connect to: fallback_eth0="dhcp"
53 >
54 >
55 > NOTES
56 > =====
57 > 192168000254 is the syntax used to represent an IP address for the
58 > home router of 192.168.0.254
59 >
60 > AABBCCDDEEFF is the syntax used to represent a MAC address for the
61 > home router of AA:BB:CC:DD:EE:FF
62 >
63 > If your Raspi wireless NIC is not eth0, please adjust the fallback
64 > directive above accordingly.
65 >
66 > You may need to duplicate the above for any other NICs your Raspi may
67 > be end up with, for which you would want to configure a static IP
68 > address.
69
70 Huh, neat. This looks indeed like it could be exactly what I was looking
71 for.
72
73 Thank you very much, I didn't know about this syntax!
74
75 I'll try it the next days and report back afterwards!
76
77 --
78 Kind regards
79
80 Flo

Replies

Subject Author
Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously? Neil Bothwick <neil@××××××××××.uk>
Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously? Mick <michaelkintzios@×××××.com>
Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously? "Florian Gamböck" <ml@×××××.de>