markjd
Posts: 2
Joined: Sun Dec 07, 2014 8:17 pm

ip address

Sun Dec 07, 2014 8:37 pm

This might be a question without a real answer:

I have a USB WiFi adaptor and by connecting my pi to my TV know the IP address of my pi and can connect to it from my laptop with putty using the typical address 192.168.0.39 which I found by connecting the pi to my TV and then using the GUI.

However, the WiFi connection is not that stable and so I have tried connecting my pi to my router with an ethernet cable. Once my pi is connected to the ethernet cable, the address 192.168.0.39 does not work on putty.

Does anyone know why?

Cheers - Mark

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: ip address

Sun Dec 07, 2014 9:04 pm

Sounds like "ifplugd" at work. IOW it's a feature - actually, a very bad mis-feature.

The solution is:

apt-get purge ifplugd

then reboot.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

Bosse_B
Posts: 757
Joined: Thu Jan 30, 2014 9:53 am

Re: ip address

Sun Dec 07, 2014 9:51 pm

markjd,
every network adapter has its own unique hardware address, the MAC address. It is globally unique, too.
Whenever a router is connected to by a network adapter and asked to supply an IP address via DHCP it will note the MAC address in its database together with the IP address it supplies to the adapter.
This is in order for it to normally supply the same IP address the next time the same adapter connects.

Now, in your case you have two different network adapters, the WiFi and the Ethernet adapters and they have different MAC addresses. So the router will always supply different IP addresses to them. This is built into the networking system.

In fact the handing out of the same IP address every time an adapter connects is NOT certain, it depends on the router make for how long it will keep the old address memorized, so you might not even get the same address for the WiFi adapter every time.

This can be solved on the router by making what is called a "reservation" in the DHCP server section. A reservation ties together an IP address and a MAC address permanently and is therefore what you should do in your situation to ensure future address changes will not happen.
But WiFi and Ethernet will always get different addresses.
Bo Berglund
Sweden

User avatar
billybangleballs
Posts: 142
Joined: Fri May 18, 2012 11:28 pm

Re: ip address

Sun Dec 07, 2014 9:53 pm

I would edit /etc/network/interfaces and tell it what ip address to use.

Code: Select all

auto lo

iface lo inet loopback
iface eth0 inet static
	address 192.168.0.33
	netmask 255.255.255.0
	gateway 192.168.0.1

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

That's what mine looks like and it's always at 192.168.0.33 when connected by wired lan.

Bosse_B
Posts: 757
Joined: Thu Jan 30, 2014 9:53 am

Re: ip address

Sun Dec 07, 2014 9:58 pm

But then the IP address selected MUST be outside of the DHCP address range used by the router!
Otherwise there may be an address conflict on the network at a later time and the connectivity is broken....
Bo Berglund
Sweden

User avatar
billybangleballs
Posts: 142
Joined: Fri May 18, 2012 11:28 pm

Re: ip address

Sun Dec 07, 2014 10:06 pm

I agree to a point Bosse_B.
I've never had dhcp give out an ip that was already active on the network but it may well be that I've just been lucky all my life.
But to be on the safe side, as you say, choose an address in the same subnet that is outside the pool used by dhcpd and that you are sure is not being used by anything else.

Bosse_B
Posts: 757
Joined: Thu Jan 30, 2014 9:53 am

Re: ip address

Sun Dec 07, 2014 11:03 pm

On my routers I set aside about 80 addresses for DHCP hand-out.
My servers have static addresses in the low address range.
And then I have the odd extra unit, which connects through WiFi or Ethernet, where the address is set static too on the unit.
Of course one has to keep a separate book of these because they will not show up in the router's list of connections.
Example:
DHCP range: 192.168.116.131-210
Servers (static): 192.168.116.10, 11,12, 13, ...
WiFi gadgets (static): 192.168.116.65-89
Ethernet gadgets (static): 192.168.116.90-125
Extra space still available...

This works just fine but one has to keep tabs on what is going on.
Note:
I use a high 3rd address octet like 116 because I don't want to get address conflicts if I should connect back home via VPN from a WiFi network that uses the "default settings" present in many routers (192.168.0.x or 192.168.1.x).
Bo Berglund
Sweden

markjd
Posts: 2
Joined: Sun Dec 07, 2014 8:17 pm

Re: ip address

Mon Dec 08, 2014 11:45 am

Thanks for all the advice. I'll give it a go tonight.

Return to “General discussion”