Raspberry Pi Zero W Honeypot (similar to Wireless AP) - raspberry-pi

I want to access a server on the Raspberry Pi Zero via WiFi.
YouTube Video describing the Problem
I am following the tutorial on this Blog for the Raspberry Pi .
Accessing the server with another laptop doesn't work. It says that it is not connected.
When I run on the Raspi
sudo cat /var/log/dnsmasq.log
I get at the end this error:
May 9 09:59:28 dnsmasq-dhcp[513]: no address range available for DHCP request via wlan0
But I am not sure if this has to do anything with the problem at all.
How can I make the Raspi Zero W http-Server (the http server is a server on the raspi) connectable over WiFi?
Here are the relevant parts of the files.
File: /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
broadcast 255.0.0.0
pre-up iptables-restore < /etc/iptables.rules
File: /etc/dnsmasq.conf
#...
#at the end of the file
log-facility=/var/log/dnsmasq.log
address=/#/10.0.0.1
interface=wlan0
dhcp-range=10.0.0.10,10.0.0.250,12h
no-resolv
log-queries
File: /etc/dhcp/dhclient.conf
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
File: /etc/dhcpcd.conf
# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# 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
# 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

I have read the blog and i successfully implemented the server following all the steps.It is possible that you have misconfigured something. My bets are on the /etc/network/interfaces file or on the /etc/dnsmasq.conf.
Also, check if you don't have another dhcp server on. Maybe the internal /etc/dhcp/dhcpd.conf is overwritting your ip pool.
Post the relevant part of all those files to see if there is any error.

Simple solution, plug in a HDMI monitor and keyboard and use the desktop network GUI to set up the Wifi (click on the WiFi logo, top right).
A longer winded option would be to use one of the hundreds of how to articles out there, for Raspberry Pis (regardless of Pi zero to Pi3 they are the same).
A quick Google search found this: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis
Or even (for those with shorter attention spans): https://www.google.co.uk/search?q=raspberry+pi+configure+wifi&oq=raspberry+pi+configure+wifi&aqs=chrome..69i57j0l5.6863j0j7&sourceid=chrome&ie=UTF-8#q=raspberry+pi+configure+wifi&tbm=vid
Good luck and don't be afraid to Google for these things.

If you run ifconfig -a, does your wlan0 interface have the proper IP address, 10.0.0.1? Mine did not. In /etc/network/interfaces I added the line
allow-hotplug wlan0
above the iface wlan0 line. That seemed to fix the address problem and the same error, "no address range available for DHCP request via wlan0" you are getting.
You have a problem with web pages then as nginx looks for pages in /var/www/html.
Use this line ...
sudo echo "<h1>hello<h1>" > /var/www/html/index.html
Note removal of "!" and different destination folder
I had the exact same problems you had and this got mine working for the most part.

Related

Networking not initialized with cloud-init on some Centos 7 images

I'm trying to create KVM VMs of Centos 7 with cloud-init. I am using the images found at https://cloud.centos.org/centos/7/images/ .
In the meta-data file I put the following content:
network-interfaces: |
iface eth0 inet static
address 10.0.0.10
network 10.0.0.0
netmask 255.255.255.0
broadcast 10.0.0.255
gateway 10.0.0.1
bootcmd:
- ifdown eth0
- ifup eth0
However I don't get the same behaviour depending on the image used (I tried a few):
Centos-7, Centos-7-2009: The VM doesn't use the static IP given (the link is down)
Centos-7-1805: The VM uses the static IP but SSH connection initialisation is very slow (a minute or two)
Centos-7-1607: The VM uses the static IP, SSH works correctly, but the Ansible playbook I tried with an ordinary Centos-7 image (installed from an iso file) doesn't work perfectly on this image (issue with some packages missing), I would like to not change my playbook.
Is there a reason there are so much differences between the different images ? Am I doing something wrong ?
Thank you

Static IP Address of eth0 is not showing on my Raspberry Pi

I am using a Raspberry Pi 3 B with Raspbian Buster. I connected it with Wifi and it is working without any issues. I would like to enable the interface eth0 in order to use my Raspbi with Profinet (an industrial protocol).
So, I modified the file /etc/dhcpcd.conf/:
/etc/dhcpcd.conf/.
But the output of "ifconfig" is:
eth0
And the output of "route -v" is:
route
I would like to have the ip address of the interface "eth0" static and appearing and also able to be pinged. I tried a lot of stuffs on other forums like this one: modifying the file /etc/network/interfaces. But this didn't work. I also set the eth0 interface up with "sudo ifconfig eth0 [ipadress] netmask 255.255.255.0 up". Ma wifi crashed after this... Can someone please help me? I'm stuck with this since a couple of weeks already. Thanks a lot. If you have any questions I can provide some screenshots.
Cheers
The file /etc/dhcpcd.conf is used since Raspbian Stretch instead of instead of /etc/network/interfaces.
Using your editor of choice, edit /etc/dhcpcd.conf, scroll down to the example configuration, like below from mi Pi3B+, uncomment the lines and configure the parameters as per your needs.
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=xxxx:xxxx:xxxx:xxxx::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 xxxx:xxxx:xxxx:xxxx::1
update /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.10/24
restart dhcp service
sudo service dhcpcd restart
and do not forget to inform a dhcp lease to your router if you want that this one does not allocate this ip to another material, that will avoid instability
Also calling ethtool eth0 gives as output:
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: Unknown!
Duplex: Unknown! (255)
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
drv probe link
Link detected: no
Here some more details about my problem. I will be very grateful for help

Raspberry Wifi looses connection when lan cable unplugged

Using latest Buster release, I can set up my wifi and lan and it works fine. However, if I remove the lan cable, then there is no connectivity through the wifi. The Pi cannot even be pinged. I am using a dhcpcd.conf file that is the same as another Raspberry that works when the lan cable is unplugged. What am I missing?
This is the dhcpcd.conf file
# 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
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Most distributions have NTP support.
#option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
interface eth0
static ip_address=192.168.0.22/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.18 8.8.8.8
static domain_search=
interface wlan0
inform 192.168.0.23
static routers=192.168.0.1
static domain_name_servers=192.168.0.18 8.8.8.8
I found a way to make this work but I don't understand why I had to do this. I changed the metric value for each and made the wifi a higher priority, (a lower number). That seems to make it work.

Problems setting up HostAPD on Pi 3 Jessie Lite

I'm following this Adafruit tutorial with the end goal of setting up a portable Tor routed WiFi access point. I did this entire tutorial start to finish yesterday on the same Pi 3 running Raspbian Jessie, and it worked perfectly.
However, due to SD card size restrictions (I'm on a tight budget and I need to make quite a few) and the fact that I don't want a GUI, I decided to start again but with Raspbian Jessie Lite (using the last Jessie release before Stretch), and now I can't seem to get past the HostAPD setup when I'm following the tutorial line for line and using the same Pi 3!
THE PROBLEM:
When I get to the "First Test" part of the tutorial and run HostAPD for the first time I should get an output something like this:
But instead I get this:
user0#raspberrypi:~ $ sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:41:64:5e and ssid "Extrea-Special-Wifi"
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED
The tutorial (and multiple other sources) says that if I'm using the built-in Wi-Fi module, I don't need to specify a driver for it (It worked yesterday without a driver specified too) but something is not working this time and the only thing I've changed is the OS from Jessie to Jessie Lite.
My laptop and other devices can see and connect to the network but there is no internet. Of course I can ping the Gateway IP but not the DNS 8.8.8.8.
My HostAPD config file is the same as the tutorial's and is as follows:
interface=wlan0
#driver=rtl871xdrv
ssid=Extrea-Special-Wifi
country_code=GB
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Password123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1
note: Password123 is not a password that I use and it will be changed!
My /etc/network/interface file is not quite the same as the tutorial but worked yesterday like this:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
I realise that the this file says:
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
But it worked fine on the full version of Jessie (Latest release too)
and if this is the cause of the problem I'm really not sure how to make this tutorial work with the /etc/dhcpd.conf file.
My /etc/sysctl.conf is set up as follows:
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
##############################################################3
# Functions previously found in netbase
#
# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1
# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1
# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
# Uncomment the next line to enable packet forwarding for IPv6
# Enabling this option disables Stateless Address Autoconfiguration
# based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1
###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#
net.ipv4.ip_forward=1
The bottom of this file seems to be missing 2 lines that are visible in the screenshot from the tutorial however I didn't add them yesterday because the tutorial doesn't even mention them (as I said, yesterday I managed to get the Pi working perfectly as a Tor Routed access point using exactly the same steps).
Screenshot from the tutorial:

configure ip for bitnami owncloud virtual appliance

I installed Bitnami owncloud virtual appliance stack on Virtual box and within no time, I was able to sync files to and from this box. However, the main problem with Virtual Box is that the IP address keeps changing when the owncloud instance is powered off and then turned back on - which makes sense. Is there any way to keep the server IP static so that we don't need to configure the clients everytime the IP is changed.
You could change the config (from auto to static) in the following way
sudo vi /etc/network/interfaces (“vi” or “nano”)
iface eth0 inet static
address 192.168.0.100
# your own IP
netmask 255.255.255.0
# network mask
gateway 192.168.0.1
# standard gateway (router)
dns-nameservers 192.168.0.1 8.8.8.8
# DNS (optional)
/etc/init.d/networking restart (restart network)
ifconfig
for the IP addresses check or you “shutdown –h now” (reboot)). Please, keep in mind that multiple copies need multiple IP's. In Virtual Box remember to switch between NAT and Bridge - if required.