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.