Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-22 Thread Peter Humphrey
On Saturday 22 Apr 2017 00:45:31 Mick wrote:
> On Saturday 22 Apr 2017 00:08:25 Peter Humphrey wrote:
> > On Friday 21 Apr 2017 13:39:52 Neil Bothwick wrote:
> > > I was referring to the situation where you use the DHCP server to give
> > > out pseudo-static addresses. I have always used addresses outside of,
> > > but
> > > in the same subnet as, the reserved range. The reserved range just
> > > tells
> > > the DHCP server which addresses to use in the absence of any other
> > > specifications.
> > 
> > Eh? How do you do that? You tell the router what range of addresses it
> > can use, then you tell it to use one outside that range? Can't be done
> > - if I've understood you.
> 
> I understood Neil to mean:
> 
> You pre-allocate IP addresses to specific MAC addresses for a range of
> e.g. 192.168.0.1 to 192.168.0.10.  Any new comers with MAC addresses not
> in the DHCP address allocation table will then obtain IP addresses
> outside this defined range.  Some routers also allow you to specify the
> range within which DHCP addresses will be allocated.  So you can set
> static address allocation outside said range.

Ah. Then he's describing a setup much like my own. I just didn't read it 
right the first time.

-- 
Regards
Peter




Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Mick
On Saturday 22 Apr 2017 00:08:25 Peter Humphrey wrote:
> On Friday 21 Apr 2017 13:39:52 Neil Bothwick wrote:
> > I was referring to the situation where you use the DHCP server to give
> > out pseudo-static addresses. I have always used addresses outside of, but
> > in the same subnet as, the reserved range. The reserved range just tells
> > the DHCP server which addresses to use in the absence of any other
> > specifications.
> 
> Eh? How do you do that? You tell the router what range of addresses it can
> use, then you tell it to use one outside that range? Can't be done - if I've
> understood you.

I understood Neil to mean:

You pre-allocate IP addresses to specific MAC addresses for a range of e.g. 
192.168.0.1 to 192.168.0.10.  Any new comers with MAC addresses not in the 
DHCP address allocation table will then obtain IP addresses outside this 
defined range.  Some routers also allow you to specify the range within which 
DHCP addresses will be allocated.  So you can set static address allocation 
outside said range.
-- 
Regards,
Mick

signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Peter Humphrey
On Friday 21 Apr 2017 13:39:52 Neil Bothwick wrote:

> I was referring to the situation where you use the DHCP server to give
> out pseudo-static addresses. I have always used addresses outside of, but
> in the same subnet as, the reserved range. The reserved range just tells
> the DHCP server which addresses to use in the absence of any other
> specifications.

Eh? How do you do that? You tell the router what range of addresses it can 
use, then you tell it to use one outside that range? Can't be done - if I've 
understood you.

-- 
Regards
Peter




Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Florian Gamböck

Hi Peter!

On 2017-04-21 13:53, Peter Humphrey wrote:
Have you considered spending a little money, ditching the router and 
substituting one that you can control? Reasonably capable routers 
aren't expensive.


Yes, I have considered this. But this is a router by my internet 
provider, especially configured to work at my place. It uses optical 
fibers instead of RJ11. I don't even have dial-in or log-in data, since 
it was already pre-configured.


I guess I cannot simply "ditch" the router. But yes, if I am out of 
options, I could always buy another router, connect it to my main router 
and just use this new one for connecting my devices.


But I also want to think about situations, where I need static IP 
addresses and I cannot access the router configuration. For example, if 
I need to configure a certain embedded device, which is only accessible 
via an IP in another subnet, then I could dedicate a NIC for the sole 
purpose to receive a static IP in this particular subnet, but only if I 
am connected in my home network.


I prefer general solutions over quickfixes which just work for one 
particular case.


But nevertheless, thanks for your suggestion!

--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Florian Gamböck

On 2017-04-21 13:39, Neil Bothwick wrote:
I was referring to the situation where you use the DHCP server to give 
out pseudo-static addresses. I have always used addresses outside of, 
but in the same subnet as, the reserved range. The reserved range just 
tells the DHCP server which addresses to use in the absence of any 
other specifications.


I guess my router doesn't work this way. If I want to reserve an address 
outside the DHCP range, then it says "Cannot reserve address outside of 
DHCP range".


--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Peter Humphrey
On Friday 21 Apr 2017 14:20:06 Florian Gamböck wrote:

> I got this pre-configured router from my internet provider and I have
> *very* limited access to the configuration. I have no telnet and no ssh,
> as far as I can tell. For example, when I want to change my wifi
> configuration, I have to do that online on my provider's website, which
> obviously triggers some kind of over-the-air update to my router. After
> an automatic restart, the new (readonly) configuration shows up on my
> router.

Have you considered spending a little money, ditching the router and 
substituting one that you can control? Reasonably capable routers aren't 
expensive.

-- 
Regards
Peter




Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Neil Bothwick
On Fri, 21 Apr 2017 14:20:07 +0200, Florian Gamböck wrote:

> > You should allocate static addresses from outside of the DHCP
> > reserved range. For example, set the DHCP range to 192.168.1.100-200
> > then allocate static addresses from below there.  
> 
> That's what I've been doing until now, which is why I originally
> started this thread.
> 
> What Mick meant was configuring the router, so it reserves IP addresses 
> for specified MAC addresses. These "almost" static addresses have to be 
> taken from within the DHCP range, because it is actually the DHCP
> server that provides them. I used routers in the past which worked
> perfectly with this setup, but somehow the machines I have to use
> nowadays don't like anything wich is not plain old DHCP.

I was referring to the situation where you use the DHCP server to give
out pseudo-static addresses. I have always used addresses outside of, but
in the same subnet as, the reserved range. The reserved range just tells
the DHCP server which addresses to use in the absence of any other
specifications.


-- 
Neil Bothwick

You can't teach a new mouse old clicks.


pgpgSl8pyVLTv.pgp
Description: OpenPGP digital signature


Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Florian Gamböck

On 2017-04-19 12:17, Mick wrote:

On Wednesday 19 Apr 2017 12:46:09 Florian Gamböck wrote:

On 2017-04-18 20:41, Mick wrote:
Assuming you have access to your home's router, you can configure on 
it a static IP address for the MAC address of the Raspi.


That's what I've been doing in the past, but my Cisco router had 
problems with that. It tried to give away addresses I have 
specifically reserved and it ended up cutting the connections and 
refusing to let new machines connect as long as there was a conflict.


Hmm ... I never had this experience with Cisco IOS.  It may be worth 
updating the router and WAP firmware in case this was due to a bug. 
The router should never allocate IP addresses from its reserved IP 
address table, although it will not be able to stop PCs using these 
addresses themselves if they were manually configured so.


I got this pre-configured router from my internet provider and I have 
*very* limited access to the configuration. I have no telnet and no ssh, 
as far as I can tell. For example, when I want to change my wifi 
configuration, I have to do that online on my provider's website, which 
obviously triggers some kind of over-the-air update to my router. After 
an automatic restart, the new (readonly) configuration shows up on my 
router.


However, I *do* have access to the LAN configuration, including DHCP 
range and the like. And yes, you are right, if I reserve addresses, the 
router *should* not give these addresses away to other machines. I 
shouted at the router and telling her that, but she wouldn't listen.


And if it is really a problem with the clients, then multiple Linux 
machines, multiple Android devices, Sony's PlayStation 4, and a lonely 
Windows laptop all share the same bug, namely wanting to have the same 
IP address via DHCP and failing to obtain another one.


If I don't reserve addresses from DHCP range and use statically 
configured addresses outside the range with some computers, then there 
is no problem with DHCP and the other machines that connect.


So I take this fact as my baseline and work from there.

Besides, I like having configuration files on my computers, which I 
can exchange and adjust as I like, without the need to click through 
heavily overloaded router configuration WebApps.


If it is a Cisco running IOS there should be SSH access to run CLI 
commands for it.  If however it is a Cisco-branded cheap appliance, 
then it would probably not have any relationship with IOS, but it may 
be able to run OpenWRT or equivalent on its SoC.


No SSH, no possibility to replace the firmware, no other way to connect 
to the internet. Sorry.


Have a look at the documentation provided by netifrc, it is well 
commented with detailed examples:


less /usr/share/doc/netifrc-0.5.1/net.example.bz2


I did multiple times, but obviously this specific syntax didn't reach my 
mind. Thanks again!


--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Florian Gamböck

Hi Neil!

On 2017-04-19 12:00, Neil Bothwick wrote:

On Wed, 19 Apr 2017 12:46:09 +0200, Florian Gamböck wrote:

On 2017-04-18 20:41, Mick wrote:
Assuming you have access to your home's router, you can configure on 
it a static IP address for the MAC address of the Raspi.  The home 
router will not allocate any such reserved IP address to any other 
device, but reserve it for the Raspi's MAC address.


That's what I've been doing in the past, but my Cisco router had 
problems with that. It tried to give away addresses I have 
specifically reserved and it ended up cutting the connections and 
refusing to let new machines connect as long as there was a conflict.


You should allocate static addresses from outside of the DHCP reserved 
range. For example, set the DHCP range to 192.168.1.100-200 then 
allocate static addresses from below there.


That's what I've been doing until now, which is why I originally started 
this thread.


What Mick meant was configuring the router, so it reserves IP addresses 
for specified MAC addresses. These "almost" static addresses have to be 
taken from within the DHCP range, because it is actually the DHCP server 
that provides them. I used routers in the past which worked perfectly 
with this setup, but somehow the machines I have to use nowadays don't 
like anything wich is not plain old DHCP.


Besides, I like having configuration files on my computers, which I 
can exchange and adjust as I like, without the need to click through 
heavily overloaded router configuration WebApps.


If you have an always on computer on your network, I would recommend 
trying dnsmasq. It has a DHCP server and means you can do all your 
network configuration in the one place, with simple text config files.


This sounds really promising, thank you for this tip! And also thank you 
Peter and Paul for your feedback!


I will put it on my ToDo list and consider it the next time I'm about to 
kick my router! ;-)


--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-21 Thread Florian Gamböck

On 2017-04-19 12:46, Florian Gamböck wrote:

On 2017-04-18 20:41, Mick wrote:

(...)

Something like this should work:

# Define the gateway you want to configure 
gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"


# Define the default route for gateway 192.168.0.254 
routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"


# Define the IP and netmask when using gateway 192.168.0.254 
config_192168000254_AABBCCDDEEFF="192.168.0.10/24"


# Define the DNS servers to use with gateway 
dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"


# Then you need to add a line for all other routers the Raspi may 
connect to: fallback_eth0="dhcp"


(...)


(...)

I'll try it the next days and report back afterwards!


That was really a great advice, a big thank you again! It works as 
expected.


Just a few notes for future reference:

config_eth0="arping" was necessary for this module to load and for the 
gateways_* variables to be parsed.


I needed to emerge net-misc/iputils with "arping" USE flag. The 
net-analyzer/arping package is *not* sufficient, because it doesn't work 
with the spoofing address in the gateway variable.


Another side-note: If I am connected to another network, so DHCP is 
used, and I change networks, as in "lose connection from the network and 
re-connecting with my home network", then the above configs are *not* 
used, DHCP is used. But this might be a bug in netifrc or a missing hook 
in my configs. I'll look more into it and start another thread or even a 
bug report if I'm not able to solve it.


--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-20 Thread Paul Klos



Op 20-4-2017 om 01:16 schreef Peter Humphrey:

On Wednesday 19 Apr 2017 12:00:50 Neil Bothwick wrote:


If you have an always on computer on your network, I would recommend
trying dnsmasq. It has a DHCP server and means you can do all your
network configuration in the one place, with simple text config files.

+1. I've been using it for some years. Nice.

I installed DD-WRT on my router some time ago, and have dnsmasq running 
on that. Works like a charm.




Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-19 Thread Peter Humphrey
On Wednesday 19 Apr 2017 12:00:50 Neil Bothwick wrote:

> If you have an always on computer on your network, I would recommend
> trying dnsmasq. It has a DHCP server and means you can do all your
> network configuration in the one place, with simple text config files.

+1. I've been using it for some years. Nice.

-- 
Regards
Peter




Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-19 Thread Mick
On Wednesday 19 Apr 2017 12:46:09 Florian Gamböck wrote:
> On 2017-04-18 20:41, Mick wrote:
> > I can think of at least two ways you can attempt to achieve what you
> > want.
> > 
> > 1. Set the Raspi to use DHCP only
> > 
> > Assuming you have access to your home's router, you can configure on
> > it a static IP address for the MAC address of the Raspi.  The home
> > router will not allocate any such reserved IP address to any other
> > device, but reserve it for the Raspi's MAC address.
> > 
> > At work the Raspi will obtain a random IP address from the work's
> > router as expected.  This is by far the simplest option.
> > 
> > The line you need in /etc/conf.d/net of the Raspi will look like this:
> > 
> > config_eth0="dhcp"
> > 
> > (Change eth0 above for the name of Raspi's wireless interface).
> 
> That's what I've been doing in the past, but my Cisco router had
> problems with that. It tried to give away addresses I have specifically
> reserved and it ended up cutting the connections and refusing to let new
> machines connect as long as there was a conflict.

Hmm ... I never had this experience with Cisco IOS.  It may be worth updating 
the router and WAP firmware in case this was due to a bug.  The router should 
never allocate IP addresses from its reserved IP address table, although it 
will not be able to stop PCs using these addresses themselves if they were 
manually configured so.

> Besides, I like having configuration files on my computers, which I can
> exchange and adjust as I like, without the need to click through heavily
> overloaded router configuration WebApps.

If it is a Cisco running IOS there should be SSH access to run CLI commands 
for it.  If however it is a Cisco-branded cheap appliance, then it would 
probably not have any relationship with IOS, but it may be able to run OpenWRT 
or equivalent on its SoC.


> > 2. Configure the Raspi to selectively set itself a static IP address
> > 
> > In this option you will set up in the Raspi's /etc/conf.d/net a static
> > IP address 192.168.0.10/24, when the gateway matches the wireless MAC
> > address of the home router.  For any other gateway the Raspi will fall
> > back to using dhcp.
> > 
> > Something like this should work:
> > 
> > # Define the gateway you want to configure
> > gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"
> > 
> > # Define the default route for gateway 192.168.0.254
> > routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"
> > 
> > # Define the IP and netmask when using gateway 192.168.0.254
> > config_192168000254_AABBCCDDEEFF="192.168.0.10/24"
> > 
> > # Define the DNS servers to use with gateway
> > dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"
> > 
> > # Then you need to add a line for all other routers the Raspi may
> > connect to: fallback_eth0="dhcp"
> > 
> > 
> > NOTES
> > =
> > 192168000254 is the syntax used to represent an IP address for the
> > home router of 192.168.0.254
> > 
> > AABBCCDDEEFF is the syntax used to represent a MAC address for the
> > home router of AA:BB:CC:DD:EE:FF
> > 
> > If your Raspi wireless NIC is not eth0, please adjust the fallback
> > directive above accordingly.
> > 
> > You may need to duplicate the above for any other NICs your Raspi may
> > be end up with, for which you would want to configure a static IP
> > address.
> 
> Huh, neat. This looks indeed like it could be exactly what I was looking
> for.
> 
> Thank you very much, I didn't know about this syntax!

Have a look at the documentation provided by netifrc, it is well commented 
with detailed examples:

less /usr/share/doc/netifrc-0.5.1/net.example.bz2


> I'll try it the next days and report back afterwards!

-- 
Regards,
Mick

signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-19 Thread Neil Bothwick
On Wed, 19 Apr 2017 12:46:09 +0200, Florian Gamböck wrote:

> On 2017-04-18 20:41, Mick wrote:

> > Assuming you have access to your home's router, you can configure on 
> > it a static IP address for the MAC address of the Raspi.  The home 
> > router will not allocate any such reserved IP address to any other 
> > device, but reserve it for the Raspi's MAC address.

> That's what I've been doing in the past, but my Cisco router had 
> problems with that. It tried to give away addresses I have specifically 
> reserved and it ended up cutting the connections and refusing to let
> new machines connect as long as there was a conflict.

You should allocate static addresses from outside of the DHCP reserved
range. For example, set the DHCP range to 192.168.1.100-200 then allocate
static addresses from below there.

> Besides, I like having configuration files on my computers, which I can 
> exchange and adjust as I like, without the need to click through
> heavily overloaded router configuration WebApps.

If you have an always on computer on your network, I would recommend
trying dnsmasq. It has a DHCP server and means you can do all your
network configuration in the one place, with simple text config files.


-- 
Neil Bothwick

Do you realize how many holes there could be if people would just take
the time to take the dirt out of them?


pgpRd5DmWy8Tz.pgp
Description: OpenPGP digital signature


Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-19 Thread Florian Gamböck

On 2017-04-18 20:41, Mick wrote:
I can think of at least two ways you can attempt to achieve what you 
want.


1. Set the Raspi to use DHCP only

Assuming you have access to your home's router, you can configure on 
it a static IP address for the MAC address of the Raspi.  The home 
router will not allocate any such reserved IP address to any other 
device, but reserve it for the Raspi's MAC address.


At work the Raspi will obtain a random IP address from the work's 
router as expected.  This is by far the simplest option.


The line you need in /etc/conf.d/net of the Raspi will look like this:

config_eth0="dhcp"

(Change eth0 above for the name of Raspi's wireless interface).


That's what I've been doing in the past, but my Cisco router had 
problems with that. It tried to give away addresses I have specifically 
reserved and it ended up cutting the connections and refusing to let new 
machines connect as long as there was a conflict.


Besides, I like having configuration files on my computers, which I can 
exchange and adjust as I like, without the need to click through heavily 
overloaded router configuration WebApps.



2. Configure the Raspi to selectively set itself a static IP address

In this option you will set up in the Raspi's /etc/conf.d/net a static 
IP address 192.168.0.10/24, when the gateway matches the wireless MAC 
address of the home router.  For any other gateway the Raspi will fall 
back to using dhcp.


Something like this should work:

# Define the gateway you want to configure 
gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"


# Define the default route for gateway 192.168.0.254 
routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"


# Define the IP and netmask when using gateway 192.168.0.254 
config_192168000254_AABBCCDDEEFF="192.168.0.10/24"


# Define the DNS servers to use with gateway 
dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"


# Then you need to add a line for all other routers the Raspi may 
connect to: fallback_eth0="dhcp"



NOTES
=
192168000254 is the syntax used to represent an IP address for the 
home router of 192.168.0.254


AABBCCDDEEFF is the syntax used to represent a MAC address for the 
home router of AA:BB:CC:DD:EE:FF


If your Raspi wireless NIC is not eth0, please adjust the fallback 
directive above accordingly.


You may need to duplicate the above for any other NICs your Raspi may 
be end up with, for which you would want to configure a static IP 
address.


Huh, neat. This looks indeed like it could be exactly what I was looking 
for.


Thank you very much, I didn't know about this syntax!

I'll try it the next days and report back afterwards!

--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-18 Thread Mick
On Tuesday 18 Apr 2017 20:41:54 Florian Gamböck wrote:
> Hi Mick,
> 
> thank you for your response!
> 
> On 2017-04-18 16:41, Mick wrote:
> > I had to read this message twice and I am not yet sure I understand
> > correctly what it is you are trying to achieve.
> > 
> > Do you want whichever NIC of your PC connects first to a specific SSID
> > to always obtain IP 192.168.0.10/24 and any NIC which connects second
> > to use DHCP?
> 
> Not necessarily the first NIC, but the NIC with a specific MAC address,
> say 001122334455.
> 
> But now that you mention it, as long as one NIC gets the static IP (but
> only for the specified SSID) and all the others will be handled by DHCP,
> I don't care which one of the NICs is statically addressed.
> 
> Sorry for not being able to describe it well.
> 
> What I am trying to achieve: I have a Raspberry Pi as a server, without
> monitor, without keyboard. Just a Raspi and a Wifi stick. I want the
> Raspi to use DHCP when I take it with me and power it on at my
> workplace. Thanks to Avahi I don't need to know the IP address it gets
> at my workplace.
> 
> When I am at home, there are reasons why I can't rely on Avahi (Android
> Phones for example that do not have the possibility to resolve
> raspi.local). So I want it to have a static IP at home. Now, if for
> whatever reason I lose the connection to Raspi -- for example once my
> router at home freaked out and wouldn't let Raspi connect with a static
> IP -- I want to have the possibility to plug another Wifi stick into
> Raspi which then gets connected via DHCP, so I can at least connect to
> it.
> 
> As I see it, I can't use config_001122334455, because I would not be
> able to connect at my workplace anymore (different network properties).
> I now use config_MySSID to get a static address at home, but what about
> a second Wifi stick being connected? It would use the same config and
> end up getting the same IP address that didn't work with the first
> stick.
> 
> In general, it would be intersting to logically combine the
> configuration via SSID with the configuration via MAC. I can also think
> of a scenario where I have two wifi networks and two wifi sticks, each
> one getting a static IP on their connected network. But if I take the
> Raspi into another network, I would want NIC_1 to be DHCPed and NIC_2 to
> be nulled.
> 
> I hope I could help you to better understand what I am trying to achieve
> and what my current problem is. If possible I want to solve it via pure
> netifrc, but I would also be happy if someone said that it isn't
> possible at all via netifrc, so I can stop researching in this direction
> and think of something different.

I can think of at least two ways you can attempt to achieve what you want. 

1. Set the Raspi to use DHCP only

Assuming you have access to your home's router, you can configure on it a 
static IP address for the MAC address of the Raspi.  The home router will not 
allocate any such reserved IP address to any other device, but reserve it for 
the Raspi's MAC address.

At work the Raspi will obtain a random IP address from the work's router as 
expected.  This is by far the simplest option.

The line you need in /etc/conf.d/net of the Raspi will look like this:

config_eth0="dhcp"

(Change eth0 above for the name of Raspi's wireless interface).


2. Configure the Raspi to selectively set itself a static IP address

In this option you will set up in the Raspi's /etc/conf.d/net a static IP 
address 192.168.0.10/24, when the gateway matches the wireless MAC address of 
the home router.  For any other gateway the Raspi will fall back to using 
dhcp.

Something like this should work:

# Define the gateway you want to configure
gateways_eth0="192.168.0.254,AA:BB:CC:DD:EE:FF,192.168.0.10"

# Define the default route for gateway 192.168.0.254
routes_192168000254_AABBCCDDEEFF="default via 192.168.0.254"

# Define the IP and netmask when using gateway 192.168.0.254
config_192168000254_AABBCCDDEEFF="192.168.0.10/24"

# Define the DNS servers to use with gateway
dns_servers_192168000254_AABBCCDDEEFF="192.168.0.254"

# Then you need to add a line for all other routers the Raspi may connect to:
fallback_eth0="dhcp"


NOTES
=
192168000254 is the syntax used to represent an IP address for the home router 
of 192.168.0.254

AABBCCDDEEFF is the syntax used to represent a MAC address for the home router 
of AA:BB:CC:DD:EE:FF

If your Raspi wireless NIC is not eth0, please adjust the fallback directive 
above accordingly.

You may need to duplicate the above for any other NICs your Raspi may be end 
up with, for which you would want to configure a static IP address.

-- 
Regards,
Mick

signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-18 Thread Florian Gamböck

Hi Mick,

thank you for your response!

On 2017-04-18 16:41, Mick wrote:
I had to read this message twice and I am not yet sure I understand 
correctly what it is you are trying to achieve.


Do you want whichever NIC of your PC connects first to a specific SSID 
to always obtain IP 192.168.0.10/24 and any NIC which connects second 
to use DHCP?


Not necessarily the first NIC, but the NIC with a specific MAC address, 
say 001122334455.


But now that you mention it, as long as one NIC gets the static IP (but 
only for the specified SSID) and all the others will be handled by DHCP, 
I don't care which one of the NICs is statically addressed.


Sorry for not being able to describe it well.

What I am trying to achieve: I have a Raspberry Pi as a server, without 
monitor, without keyboard. Just a Raspi and a Wifi stick. I want the 
Raspi to use DHCP when I take it with me and power it on at my 
workplace. Thanks to Avahi I don't need to know the IP address it gets 
at my workplace.


When I am at home, there are reasons why I can't rely on Avahi (Android 
Phones for example that do not have the possibility to resolve 
raspi.local). So I want it to have a static IP at home. Now, if for 
whatever reason I lose the connection to Raspi -- for example once my 
router at home freaked out and wouldn't let Raspi connect with a static 
IP -- I want to have the possibility to plug another Wifi stick into 
Raspi which then gets connected via DHCP, so I can at least connect to 
it.


As I see it, I can't use config_001122334455, because I would not be 
able to connect at my workplace anymore (different network properties). 
I now use config_MySSID to get a static address at home, but what about 
a second Wifi stick being connected? It would use the same config and 
end up getting the same IP address that didn't work with the first 
stick.


In general, it would be intersting to logically combine the 
configuration via SSID with the configuration via MAC. I can also think 
of a scenario where I have two wifi networks and two wifi sticks, each 
one getting a static IP on their connected network. But if I take the 
Raspi into another network, I would want NIC_1 to be DHCPed and NIC_2 to 
be nulled.


I hope I could help you to better understand what I am trying to achieve 
and what my current problem is. If possible I want to solve it via pure 
netifrc, but I would also be happy if someone said that it isn't 
possible at all via netifrc, so I can stop researching in this direction 
and think of something different.


--
Kind regards

Flo



Re: [gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-18 Thread Mick
On Tuesday 18 Apr 2017 16:03:25 Florian Gamböck wrote:
> Hello!
> 
> In my wireless home network I use a static IP for my machine. The
> regarding line in /etc/conf.d/net reads as follows (let's assume that my
> SSID is in fact "MySSID"):
> 
> config_MySSID="192.168.0.10/24"
> 
> Is there a possibility to configure this IP not only for this specific
> SSID, but also for a specific MAC address of my wireless card? I only
> want my "main" wireless card to have this static IP, if another card
> goes up and connects with the same SSID, it should be configured via
> DHCP.
> 
> I tried the following:
> 
> config_MySSID="dhcp"
> config_001122334455="192.168.0.10/24"
> 
> I also changed the order of those two lines, but the SSID based config
> seems to "win" regardless. Also, if this config would actually work,
> then I would have this static IP in every network I change (this is not
> desireable). So I need a logical AND with those two variables, like so:
> 
> config_MySSID="dhcp"
> config_001122334455_MySSID="192.168.0.10/24"
> 
> This would mean the following: Connect to MySSID via DHCP, except when
> using the interface with the MAC address 001122334455, which should get
> a static IP.
> 
> Not to mention that I indeed tried this last one, but it didn't work
> either.
> 
> So, what are your thoughts? Is this possible via netifrc?

I had to read this message twice and I am not yet sure I understand correctly 
what it is you are trying to achieve.

Do you want whichever NIC of your PC connects first to a specific SSID to 
always obtain IP 192.168.0.10/24 and any NIC which connects second to use 
DHCP?
-- 
Regards,
Mick

signature.asc
Description: This is a digitally signed message part.


[gentoo-user] netifrc, configure by SSID and MAC simultaneously?

2017-04-18 Thread Florian Gamböck

Hello!

In my wireless home network I use a static IP for my machine. The 
regarding line in /etc/conf.d/net reads as follows (let's assume that my 
SSID is in fact "MySSID"):


   config_MySSID="192.168.0.10/24"

Is there a possibility to configure this IP not only for this specific 
SSID, but also for a specific MAC address of my wireless card? I only 
want my "main" wireless card to have this static IP, if another card 
goes up and connects with the same SSID, it should be configured via 
DHCP.


I tried the following:

   config_MySSID="dhcp"
   config_001122334455="192.168.0.10/24"

I also changed the order of those two lines, but the SSID based config 
seems to "win" regardless. Also, if this config would actually work, 
then I would have this static IP in every network I change (this is not 
desireable). So I need a logical AND with those two variables, like so:


   config_MySSID="dhcp"
   config_001122334455_MySSID="192.168.0.10/24"

This would mean the following: Connect to MySSID via DHCP, except when 
using the interface with the MAC address 001122334455, which should get 
a static IP.


Not to mention that I indeed tried this last one, but it didn't work 
either.


So, what are your thoughts? Is this possible via netifrc?

--
Kind regards

Flo