I am trying to configure my eth0 interface with a static ip through my dhcp server. The static assignment is working fine, but I can't access the external network because there's no default gateway.
pi@raspberry:~ $ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.30.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0
If I run sudo dhclient
or route add default gw 10.0.30.1
the default route is added and I can hit WAN no problem. But every time I restart the pi it loses this setting. How do I make this stay?
Here's my /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
I looked at
Can't make change to "route" stick and "connect: Network is unreachable" on a working (connected) wlan0 interface and Static local IP/gateway config on startup issues but I didn't see a solution.
EDIT: Adding /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
interface eth0
inform 10.0.30.14
static routers=10.0.30.1
static domain_name_servers=8.8.8.8
static domain_search=8.8.8.4
EDIT 2: Adding ifconfig output
eth0 Link encap:Ethernet HWaddr b8:27:eb:b1:50:55
inet addr:10.0.30.14 Bcast:10.0.30.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:feb1:5055/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1590 errors:0 dropped:0 overruns:0 frame:0
TX packets:361 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:179536 (175.3 KiB) TX bytes:56354 (55.0 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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr b8:27:eb:e4:05:00
inet addr:169.254.127.199 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::d8fc:4221:1b8d:c2c2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:27244 (26.6 KiB)
dhcp
in/etc/network/interfaces
this preventsdhcpcd
from running. I continue to wonder WHY people fiddle with these files. – Milliways Mar 18 '16 at 09:29dhcp
server, that does not appear amongst:# A list of options to request from the DHCP server.
- mind you I think rain is wet so who am I to say...! 8-P – SlySven Mar 18 '16 at 16:46static routers=10.0.30.1
on the RPi in your first Edit - is that overriding anything your dchp server is telling you? – SlySven Mar 18 '16 at 17:36