Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?
Date: Wed, 19 Apr 2017 11:17:59
Message-Id: 2715341.onZc56OmoH@dell_xps
In Reply to: Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously? by "Florian Gamböck"
1 On Wednesday 19 Apr 2017 12:46:09 Florian Gamböck wrote:
2 > On 2017-04-18 20:41, Mick wrote:
3 > > I can think of at least two ways you can attempt to achieve what you
4 > > want.
5 > >
6 > > 1. Set the Raspi to use DHCP only
7 > >
8 > > Assuming you have access to your home's router, you can configure on
9 > > it a static IP address for the MAC address of the Raspi. The home
10 > > router will not allocate any such reserved IP address to any other
11 > > device, but reserve it for the Raspi's MAC address.
12 > >
13 > > At work the Raspi will obtain a random IP address from the work's
14 > > router as expected. This is by far the simplest option.
15 > >
16 > > The line you need in /etc/conf.d/net of the Raspi will look like this:
17 > >
18 > > config_eth0="dhcp"
19 > >
20 > > (Change eth0 above for the name of Raspi's wireless interface).
21 >
22 > That's what I've been doing in the past, but my Cisco router had
23 > problems with that. It tried to give away addresses I have specifically
24 > reserved and it ended up cutting the connections and refusing to let new
25 > machines connect as long as there was a conflict.
26
27 Hmm ... I never had this experience with Cisco IOS. It may be worth updating
28 the router and WAP firmware in case this was due to a bug. The router should
29 never allocate IP addresses from its reserved IP address table, although it
30 will not be able to stop PCs using these addresses themselves if they were
31 manually configured so.
32
33 > Besides, I like having configuration files on my computers, which I can
34 > exchange and adjust as I like, without the need to click through heavily
35 > overloaded router configuration WebApps.
36
37 If it is a Cisco running IOS there should be SSH access to run CLI commands
38 for it. If however it is a Cisco-branded cheap appliance, then it would
39 probably not have any relationship with IOS, but it may be able to run OpenWRT
40 or equivalent on its SoC.
41
42
43 > > 2. Configure the Raspi to selectively set itself a static IP address
44 > >
45 > > In this option you will set up in the Raspi's /etc/conf.d/net a static
46 > > IP address 192.168.0.10/24, when the gateway matches the wireless MAC
47 > > address of the home router. For any other gateway the Raspi will fall
48 > > back to using dhcp.
49 > >
50 > > Something like this should work:
51 > >
52 > > # Define the gateway you want to configure
53 > > gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"
54 > >
55 > > # Define the default route for gateway 192.168.0.254
56 > > routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"
57 > >
58 > > # Define the IP and netmask when using gateway 192.168.0.254
59 > > config_192168000254_AABBCCDDEEFF="192.168.0.10/24"
60 > >
61 > > # Define the DNS servers to use with gateway
62 > > dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"
63 > >
64 > > # Then you need to add a line for all other routers the Raspi may
65 > > connect to: fallback_eth0="dhcp"
66 > >
67 > >
68 > > NOTES
69 > > =====
70 > > 192168000254 is the syntax used to represent an IP address for the
71 > > home router of 192.168.0.254
72 > >
73 > > AABBCCDDEEFF is the syntax used to represent a MAC address for the
74 > > home router of AA:BB:CC:DD:EE:FF
75 > >
76 > > If your Raspi wireless NIC is not eth0, please adjust the fallback
77 > > directive above accordingly.
78 > >
79 > > You may need to duplicate the above for any other NICs your Raspi may
80 > > be end up with, for which you would want to configure a static IP
81 > > address.
82 >
83 > Huh, neat. This looks indeed like it could be exactly what I was looking
84 > for.
85 >
86 > Thank you very much, I didn't know about this syntax!
87
88 Have a look at the documentation provided by netifrc, it is well commented
89 with detailed examples:
90
91 less /usr/share/doc/netifrc-0.5.1/net.example.bz2
92
93
94 > I'll try it the next days and report back afterwards!
95
96 --
97 Regards,
98 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

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