1

I'm using a BT Homehub 3 and trying to set up my PI using raspbian with a static local IP.

Before any changes, using dhcp, the output of $ netstat -nr is

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

The dhcp normally starts at 192.168.1.64 but I've changed this to 192.168.1.66. My windows server uses 192.168.1.64 and I want the Pi to use 192.168.1.65. The following shows changes I've made (commented out line 5,6 added line 8-14) to config in /etc/networking/interfaces:

auto lo

iface lo inet loopback

#auto eth0
#iface eth0 inet dhcp

auto eth0
iface eth0 inet static
address 192.168.1.65
netmask 255.255.255.0
network 192.168.1.254
broadcast 192.168.100.255
gateway 192.168.100.254

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

The config changes result in the local IP for the Pi changing but the output of $ netstat -nr is now the below and whilst I can access the Pi from the network on 192.168.1.65, I cannot access the internet from the Pi. I can see the problem, no gateway but as this is configured in the interfaces file above I'm stuck as to how to fix it.

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

$ sudo /sbin/route add -net 0.0.0.0 gw 192.168.1.254 eth0 at this point adds the requisite gateway and all works as required but I want this to be done automatically on startup.

Any help? Thank you.

Richard
  • 13
  • 1
  • 1
  • 4

2 Answers2

0

Your configuration has the broadcast and gateway on a different network I think you meant this:

broadcast 192.168.1.255
gateway 192.168.1.254

(instead of 192.168.100.x)

Craig
  • 2,994
  • 12
  • 15
0

When you execute the following command on the shell, you are giving a Gateway IP Address that falls in the range of your Subnet Mask (255.255.255.0)

$ sudo /sbin/route add -net 0.0.0.0 gw 192.168.1.254 eth0

But in your /etc/networking/interfaces file, the gateway that you are giving is 192.168.100.254, which is not in the range of the subnet mask, hence possibly the problem.

I personally dont give the Gateway Address in the interfaces file, and it still works for me, when I use Static IP. (I never connect it to the internet though).

Jay K
  • 248
  • 2
  • 8