Ok, so i might have messed up a bit my system and now i am unable to set a static ip through /etc/dhcpcd.conf
I'm running raspbian stretch on pi zero w
here is what i have done: I followed this link https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md to set pi as access point then it turned out not exactly what i want as i only need to have DHCP server running on the pi, so i attempted to undo the changes I made I did
sudo apt-get remove hostapd dnsmasq
, however if i run
sudo systemctl status hostapd
i see its still active!
basically i have undone every step i made in that tutorial except these two which i couldn't figure out how to undo that or reset to default so not sure if its source of problem here..
Add a masquerade for outbound traffic on eth0:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Save the iptables rule.
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
my /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.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#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. This is applied to DHCP routes.
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
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
output of ifconfig:
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 370 bytes 34870 (34.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 370 bytes 34870 (34.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.51.119 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::ede7:ac03:2417:f53d prefixlen 64 scopeid 0x20<link>
ether 86:03:1c:a1:7e:d9 txqueuelen 1000 (Ethernet)
RX packets 1616 bytes 149330 (145.8 KiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 1722 bytes 269309 (262.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:e9:6f:91 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I don't know why it is not setting the static ip address 192.168.4.1 on interface wlan0?!
update1:
outpu of systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/dhcpcd.service.d
└─wait.conf
Active: active (running) since Tue 2019-02-12 08:33:46 UTC; 4min 1s ago
Process: 241 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=0/SUCCESS)
Main PID: 398 (dhcpcd)
CGroup: /system.slice/dhcpcd.service
├─345 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext
└─398 /sbin/dhcpcd -q -w
Feb 12 08:33:39 raspi-goggles dhcpcd[241]: wlan0: probing address 192.168.6.1/24
Feb 12 08:33:39 raspi-goggles dhcpcd[241]: wlan0: carrier lost
Feb 12 08:33:39 raspi-goggles dhcpcd[241]: wlan0: deleting address fe80::987c:c17a:851a:c67c
Feb 12 08:33:40 raspi-goggles dhcpcd[241]: usb0: probing for an IPv4LL address
Feb 12 08:33:46 raspi-goggles dhcpcd[241]: usb0: using IPv4LL address 169.254.100.26
Feb 12 08:33:46 raspi-goggles dhcpcd[241]: usb0: adding route to 169.254.0.0/16
Feb 12 08:33:46 raspi-goggles dhcpcd[241]: usb0: adding default route
Feb 12 08:33:46 raspi-goggles dhcpcd[241]: forked to background, child pid 398
Feb 12 08:33:46 raspi-goggles systemd[1]: Started dhcpcd on all interfaces.
Feb 12 08:33:49 raspi-goggles dhcpcd[398]: usb0: no IPv6 Routers available
Warning: dhcpcd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
update 2: I found out something that might be interesting:
if I add valid network credentials to /etc/wpa_supplicant/wpa_supplicant.conf such as:
network={
ssid="valid_ssid"
psk="valid_passphrase"
key_mgmt=WPA-PSK
}
the static ip in /etc/dhcpcd.conf works however, if i put wrong values for network t doesn't. I don't really understand why is that, but I don't want to use vlaid credentials because I am not expecting the Pi to be connected to another LAN, I only want to give it a static ip and run a dhcp server on it and enable wifi p2p where other devices can connect to it.