vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Setting up DHCP/static IP address

Tue Mar 22, 2016 8:25 am

Hi guys,

I've read around on how to setup the internet on my Pi 2 (basically just to go to Google.com!) and there are so many different guides. Following this http://www.noveldevices.co.uk/rp-dhcp-server didn't solve my connection.

May I just have a step-by-step tutorial link which is up to date with the Pi 2?

I'm using the Raspbian OS by the way.

Thanks!

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Tue Mar 22, 2016 6:05 pm

vizier87 wrote:how to setup the internet on my Pi 2
What do you wish to set up?
Do you just want to surf the web using an Ethernet or WiFi connection?
The first line of the guide you referenced says:
Setting Up A Raspberry Pi As A DHCP Server
which is an entirely different thing.
vizier87 wrote:I'm using the Raspbian OS by the way.
Are you using Raspbian Wheezy or Jessie? The command:

Code: Select all

cat /etc/os-release
will tell you.

Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Fri Mar 25, 2016 8:11 am

Hi Dave,

Thanks a lot for the reply. I don't know how many times this has happened to me: asking a problem online and suddenly things work out shortly after (They should have a name for thing kinda thing I suppose). The problem has been solved - setting my static IP using iface eth0 inet static worked out after all.

Vizier87

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: Setting up DHCP/static IP address

Fri Mar 25, 2016 10:24 am

vizier87 wrote:The problem has been solved - setting my static IP using iface eth0 inet static worked out after all.

Vizier87
Be aware that if you are now using, or will in future, use Raspbian Jessie you should do the configuration in /etc/dhcpcd.conf. Most info on the net is out of date regarding that. (And do not confuse dhcpd.conf with dhcpcd.conf.)

cjdawson
Posts: 10
Joined: Fri Mar 25, 2016 6:15 pm

Re: Setting up DHCP/static IP address

Fri Mar 25, 2016 6:33 pm

For anyone following up. I've created a post on setting up a DHCP server using Raspbian Jessie.

http://blog.cjdawson.com/?p=402

Actually, it's part of a series of posts where I'm setting up a PI3 to do DHCP, DNS, OpenVPN, NTP and active directory. I've got everything working apart from the active directory bit. That's turning out to be more involved that I thought.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Tue Jul 19, 2016 7:55 am

Hi guys,

Old problem cropped. By the way, the title was wrong. I was confused.

Dgordon42, I just wanted to establish a connection to surf the web and to be able to update my firmware.

So, I have done step 3 in http://www.noveldevices.co.uk/rp-dhcp-server

But do I need to complete Step 4 as well? And thanks CJDawson, I'll bear that in mind. So it'll be sudo nano /etc/dhcpcd.conf, yes?

Thanks guys. Hope you don't mind my noob questions.

Vizier87

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Tue Jul 19, 2016 11:30 am

vizier87 wrote:Dgordon42, I just wanted to establish a connection to surf the web and to be able to update my firmware.
Then start by telling us what OS you are using as requested here:
dgordon42 wrote:Are you using Raspbian Wheezy or Jessie? The command:

Code: Select all
cat /etc/os-release

will tell you.
It would also help to know if you are using Ethernet or WiFi.

I suspect that any changes you made following the web sites you have referenced are not helping.

Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Wed Jul 20, 2016 3:00 am

Oh I forgot to include that. I use Jessie and Ethernet connection.

I've been looking around with keywords like "setting up internet with ethernet/cable" and this was the closest I came to. It worked mysteriously for a while and now I'm back to square one.

Thanks for your time Dave!

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Wed Jul 20, 2016 10:14 am

Ethernet on the Pi should "just work". There is no need to follow tutorials on the internet or change configuration files, just plug it in to your router.

Restore your '/etc/network/interfaces', and your '/etc/dhcpcd.conf' back to their default states.
I don't have a Pi 2, there are copies of my files on a Pi 3B running Jessie, they should work for you:

Code: Select all

flash@RaspberryThree ~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    wireless-power off

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    wireless-power off


flash@RaspberryThree ~ $ cat /etc/dhcpcd.conf
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname
Reboot after making changes.

Hope this helps,
Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Thu Jul 21, 2016 3:34 am

Hi Dave,

That didn't work. It didn't work the first time too. What shall I do next? And yes, the eth0 is configured as shown if I hover the cursor over the network icon beside the clock.

Thanks for your help.

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Thu Jul 21, 2016 9:34 am

Report the status of the two LED's on the Pi's ethernet connector.

Post the output of:

Code: Select all

ifconfig
route -n
Report the make and model of your router.

Thanks,
Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Fri Jul 22, 2016 3:21 am

Hi Dave, as requested:
dgordon42 wrote:Report the status of the two LED's on the Pi's ethernet connector.

Post the output of:

Code: Select all

ifconfig
route -n
Report the make and model of your router.

Thanks,
Dave.
The red one is always on. The yellow occasionally blinks but there's no rhythm to it.

ifconfig:

Code: Select all

eth0      Link encap:Ethernet  HWaddr b8:27:eb:ca:97:8e  
          inet addr:10.100.56.23  Bcast:10.100.56.255  Mask:255.255.255.0
          inet6 addr: fe80::94c3:ad28:8af8:282a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:152658 errors:0 dropped:1724 overruns:0 frame:0
          TX packets:1572 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10975359 (10.4 MiB)  TX bytes:307145 (299.9 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:200 errors:0 dropped:0 overruns:0 frame:0
          TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:16656 (16.2 KiB)  TX bytes:16656 (16.2 KiB)
route -n:

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.100.56.254   0.0.0.0         UG    202    0        0 eth0
10.100.56.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
Make and Model:
Raspberry Pi 2, Model B v1.1

Thanks Dave.

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Fri Jul 22, 2016 10:12 am

vizier87 wrote:Make and Model:
Raspberry Pi 2, Model B v1.1
I was looking for the make and model of your router.

Your Pi appears to have successfully connected to your router.
Next, post the results of:

Code: Select all

ping -c3 10.100.56.254
ping -c3 8.8.8.8
ping -c3 google.com
date

Thanks,
Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Sat Jul 23, 2016 3:33 am

Hi Dave,

Here's the following:

Code: Select all

ping -c3 10.100.56.254
PING 10.100.56.254 (10.100.56.254) 56(84) bytes of data.
64 bytes from 10.100.56.254: icmp_seq=1 ttl=64 time=1.08 ms
64 bytes from 10.100.56.254: icmp_seq=2 ttl=64 time=1.04 ms
64 bytes from 10.100.56.254: icmp_seq=3 ttl=64 time=1.11 ms

--- 10.100.56.254 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.049/1.082/1.111/0.037 ms

Code: Select all

ping -c3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2005ms
And finally

Code: Select all

ping -c3 google.com
PING google.com (202.75.147.32) 56(84) bytes of data.

--- google.com ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2002ms
Does it only show that the connection is too weak?

PS on the model and make, how do I do it from the terminal? So far I can't access the Default Gateway from my browser using my Windows PC, by looking into this walkthrough: http://smallbusiness.chron.com/check-ro ... 63422.html. Sorry for my inexperience.

Thanks.
Vizier87

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: Setting up DHCP/static IP address

Sat Jul 23, 2016 8:35 am

Your RPi is reaching the router OK but not onwards to the internet.

The IP addresses and your problem with reporting the router make and model suggest that you are not a typical home user with a home router. Are you trying to connect to a corporate network, one in an academic institution etc? Those often have additional security measures in place (access only granted to registered MAC addresses, proxy server to access internet etc). If so you will need the assistance of the network management people.

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Sat Jul 23, 2016 10:10 am

From reviewing the results of your last 2 posts:
1. Your Pi is correctly configured to access the internet over an ethernet connection
2. Your Pi has successfully connected to a router at 10.100.56.254
3. That router has supplied the Pi with an IP address of 10.100.56.23 using DHCP. (This address may change over time, or if you reboot or reconnect)
4. That router is supplying a DNS service to your Pi.
There is nothing more you can do to your Pi to get it to connect to the internet, as the connection is broken either inside the router (firewall, security, authorization, etc.), or the router is not connected to the internet. I suspect the former to be the case.
vizier87 wrote:Does it only show that the connection is too weak?
The connection is working OK.
vizier87 wrote:PS on the model and make, how do I do it from the terminal? So far I can't access the Default Gateway from my browser using my Windows PC, by looking into this walkthrough: http://smallbusiness.chron.com/check-ro ... 63422.html.
You cannot access your router through that internet tutorial because you are connected to some kind of corporate or large scale network, and not a home router as would be typical of a Pi user. I was expecting you to get the make and model of your router by picking it up and reading the label on the bottom!

The only way you will get your Pi on the internet using your ethernet connection is to talk to the network's owner/administrator.
Do you have any other devices, such as your Windows PC, which can connect to the internet using your ethernet connection?

This is basically a longer version of @drgeoff's post above.

Hope this helps,
Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Sun Jul 24, 2016 4:28 am

dgordon42 wrote:From reviewing the results of your last 2 posts:
1. Your Pi is correctly configured to access the internet over an ethernet connection
2. Your Pi has successfully connected to a router at 10.100.56.254
3. That router has supplied the Pi with an IP address of 10.100.56.23 using DHCP. (This address may change over time, or if you reboot or reconnect)
4. That router is supplying a DNS service to your Pi.
There is nothing more you can do to your Pi to get it to connect to the internet, as the connection is broken either inside the router (firewall, security, authorization, etc.), or the router is not connected to the internet. I suspect the former to be the case.
vizier87 wrote:Does it only show that the connection is too weak?
The connection is working OK.
vizier87 wrote:PS on the model and make, how do I do it from the terminal? So far I can't access the Default Gateway from my browser using my Windows PC, by looking into this walkthrough: http://smallbusiness.chron.com/check-ro ... 63422.html.
You cannot access your router through that internet tutorial because you are connected to some kind of corporate or large scale network, and not a home router as would be typical of a Pi user. I was expecting you to get the make and model of your router by picking it up and reading the label on the bottom!

The only way you will get your Pi on the internet using your ethernet connection is to talk to the network's owner/administrator.
Do you have any other devices, such as your Windows PC, which can connect to the internet using your ethernet connection?

This is basically a longer version of @drgeoff's post above.

Hope this helps,
Dave.

Yeah, I am using a university connection. My Windows PC, however, is connected to the ethernet and it works fine. I suppose your guess is correct. There is probably some sort of proxy/firewall issue. What should I ask the admin for access then?

Thanks.
Vizier87

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: Setting up DHCP/static IP address

Sun Jul 24, 2016 7:25 am

Show the admin this thread?

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Sun Jul 24, 2016 9:20 am

I don't know what information your network administrators will require to allow your Pi onto the network, but it would be good to know the following when you talk to them:
The Pi's MAC (hardware) address, from the first line of the output of the 'ifconfig' command. (Yours appears to be "b8:27:eb:ca:97:8e")
The Pi's operating system, get it with 'cat /etc/os-release'.
The Pi's Linux kernel, get it with 'uname -a' command.
The Pi's host-name, get it with the 'hostname' command. (They may want you to change this)

There should be no big deal in getting your Pi onto the network.

Good Luck,
Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Wed Jul 27, 2016 8:37 am

Hi guys,

Ok before I go to the admin, better get it done for both Wifi and Ethernet.

I decided to buy a Wifi dongle and see if it'll bypass this issue. However, the Wifi is also provided by the university, where they'll allow access by using the student username and password. So... will the issue still be the same?

PS Dave, I have changed the /etc/network/interfaces into this for the wireless (according to http://www.savagehomeautomation.com/pro ... dapte.html):

Code: Select all

flash@RaspberryThree ~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual
auto wlan0
allow-hotplug wlan0
wpa roam /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    wireless-power off

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    wireless-power off
Am I on the right track? Because sudo ifup wlan0 mentioned:

Code: Select all

sudo ifup wlan0
/etc/network/interfaces:2: misplaced option
ifup: couldn't read interfaces file "/etc/network/interfaces"

Additional info:
USB Wireless device detected using lsusb = positive
iwconfig = wlan0 is detected
Now on the configuration part.

Thanks for your patience. I really appreciate it.

drgeoff
Posts: 9803
Joined: Wed Jan 25, 2012 6:39 pm

Re: Setting up DHCP/static IP address

Wed Jul 27, 2016 10:20 am

No, do not use instructions from a page which gives the date of the latest Raspbian as 4 years ago.

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Wed Jul 27, 2016 10:45 am

vizier87 wrote:I have changed the /etc/network/interfaces into this for the wireless (according to http://www.savagehomeautomation.com/pro ... dapte.html)
You really need to carefully read these internet "tutorials" you are finding before blindly following them. That one is dated Saturday, October 20, 2012 at 5:23PM right at the top of the page, and further down it says:
The latest Raspian distribution (Raspbian “wheezy” 2012-09-18)
You already said that you are running Raspbian Jessie, and this is 2016, and there have been changes.
You have not said which model WiFi dongle you bought, should we just guess that it is an Edimax 7811Un?
No mater what configuration changes you make, WiFi will not work without the correct network SSID and Password, so why not just go to the network administrator and get yourself registered?
If, having done that, you still have problems, we can try to help.

Dave.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Thu Jul 28, 2016 3:13 am

Oh man. That was embarassing. I should look a lot closer next time.

I used a WiPi. And access to the WiFi (which I do have) uses our own username and password where the login browser will redirect me first to the login page. I'm not sure the Pi handles the browser login automatically?

In the meanwhile. I'll look around for the latest tutorials on this. I'll update later.

vizier87
Posts: 17
Joined: Mon Mar 07, 2016 5:57 am

Re: Setting up DHCP/static IP address

Wed Aug 03, 2016 8:33 am

Hey it's me again.

I've been trying to bypass this problem by using Wi-Pi but the tutorials online are scarce regarding this specific problem I'm having. The good news is that the WiFi network in my university (and yes, I do have access on the WiFi network as a student in my PC) is not proxy-type. Now here's a few stuff that I can supply:

lsusb returned (among others but this should reflect the WiPi):

Code: Select all

Ralink technology corp. rt5370 wireless adapter
ifconfig:

Code: Select all

wlan0     Link encap:Ethernet  HWaddr 40:a5:ef:0f:49:7f  
          inet6 addr: fe80::733d:59b3:b4cd:a9e5/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
However, when I hover my cursor on the "network" icon on the desktop toolbar, eth0 was configured but wlan0: Not associated.

And all four USB ports are connected but it was able to read the flash drive nicely so I assume the power drainage issue is not there?

And as for /etc/network/interfaces:

Code: Select all

auto wlan0
iface wlan0 inet dhcp
wpa-ssid <bla bla bla>
identity <bla bla bla>
wpa-psk <bla bla bla>
I know I missed something since the webpage which appears when I log into my WiFi looks like the attached picture.

The third option is a combobox, where you select whether you are "Student" or "Staff".

So... can you guys help me out on this?

Thanks.. I really don't know where else I could search anyone with the same predicament online.

Vizier87
Attachments
Untitled.png
Untitled.png (48.3 KiB) Viewed 2640 times

dgordon42
Posts: 764
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Setting up DHCP/static IP address

Wed Aug 03, 2016 10:19 am

What happens if you use the '/etc/network/interfaces' and '/etc/dhcpcd.conf' files I posted for you to use back on July 20 here?

Post the output of:

Code: Select all

sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
Post ALL the output of these commands:

Code: Select all

lsmod
lsusb
route -n
ifconfig
iwconfig
Dave.

Return to “Networking and servers”