russg
Posts: 12
Joined: Tue Dec 30, 2014 10:55 am

Trouble getting internet connection

Tue Dec 30, 2014 11:11 am

Hi, this is my first post on here, so please bare with me.

I spent most of the day yesterday trying to change the ip address of my Pi so I could connect it to my router via a ethernet cable and update some software on it so I can program a thermal printer. After lot's of messing around I've managed to change my ip address to something similar to my router 192.168.1.55. I believe my router is 192.168.1.254. My laptop is something similar and I have that connected to the router with ethernet too.

So I know this little network I have is working because I can ping the Pi from my laptop and can ping my laptop and router from the Pi. I also have Putty working and Xming so I can control and display my Pi from the laptop, so I'm sure I've got the ip addresses working ok.

The only settings I'm unsure about are the gateway and the DNS server. When I type: netstat -nr my gate says it is 0.0.0.0 yet my laptop says this is 192.168.1.254 - the ip of the router.... also the DNS is set to the router address on my laptop. internet is working fine on the laptop.

I've tried to set a static address through: sudo nano /etc/network/interfaces but the gateway stays the same and actually the ip address stays the same unless I change it using other methods. I'm struggling to find the DNS address on the raspberry pi.

I'm using the raspbian os and have had the internet on it once briefly, but unsure what I did to get it working.

Any help would be greatly appreciated.

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Trouble getting internet connection

Tue Dec 30, 2014 2:43 pm

The gateway should be the IP address of the router. You can add it temporarily with the ip or route commands, or code it into your /etc/network/interfaces file.

But your router should be handling all this for you if you have the interface set to the default of dhcp.

russg
Posts: 12
Joined: Tue Dec 30, 2014 10:55 am

Re: Trouble getting internet connection

Tue Dec 30, 2014 4:18 pm

Thanks for your reply. Actually by the time my post got verified I'd manged to solve it. For some reason when I set it with static in /etc/network/interfaces it doesn't change. But I've temporarily changed it with sudo route add default gw 192.168.1.1 and it has given me access to the internet. My next problem is how I keep it that way?

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Trouble getting internet connection

Tue Dec 30, 2014 5:30 pm

You should be able to set the gateway with "gateway 192.168.1.254" (no quotes) in the right section of /etc/network/interfaces. Then it should pick it up on reboot. If it doesn't, post your entire interfaces file here.

russg
Posts: 12
Joined: Tue Dec 30, 2014 10:55 am

Re: Trouble getting internet connection

Tue Dec 30, 2014 8:01 pm

It's already set to that.
Here is my interfaces file:

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.55
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

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

russg
Posts: 12
Joined: Tue Dec 30, 2014 10:55 am

Re: Trouble getting internet connection

Tue Dec 30, 2014 8:08 pm

My ip address seems to be set on boot up at /boot/cmdline.txt

the last part of the line in that file says ip=192.168.1.55

I had to change this to get it to stay at the address I wanted. I have a feeling a could maybe delete this though?

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

Re: Trouble getting internet connection

Tue Dec 30, 2014 8:11 pm

/etc/network/resolv.conf should contain the line

nameserver 192.168.1.254
Quis custodiet ipsos custodes?

User avatar
DougieLawson
Posts: 39304
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Trouble getting internet connection

Tue Dec 30, 2014 8:48 pm

Get rid of "network" and "broadcast" from the interfaces file (they aren't needed). Get rid of "ip=..." from /boot/cmdline.txt then reboot.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

russg
Posts: 12
Joined: Tue Dec 30, 2014 10:55 am

Re: Trouble getting internet connection

Tue Dec 30, 2014 10:38 pm

DougieLawson wrote:Get rid of "network" and "broadcast" from the interfaces file (they aren't needed). Get rid of "ip=..." from /boot/cmdline.txt then reboot.
Great, thank you. That is working well now.

Return to “Troubleshooting”