Static IP Address of eth0 is not showing on my Raspberry Pi - 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

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

How to forward packets between VLANs on Open vSwitch router?

I'm trying to configure an OVS router. I want to achieve that, by adding flows on the OVS router, the devices connected with switch ports (port 2-5) can access to the internet, if the internet cable is inserted into the WAN port (port 1).
My VLAN configuration in file /etc/config/network of the OVS router is:
eth1.1: 0t, 2
eth1.2: 0t, 3
eth1.3: 0t, 4
eth1.4: 0t, 5
eth1.5: 1, 6
The output of ovs-vsctl show is:
root#OpenWrt:~# ovs-vsctl show
84d9ab2f-a3e6-46e3-874f-156ef975d673
Bridge "br0"
Controller "tcp:<an IP address>"
is_connected: true
fail_mode: standalone
Port "eth1.4"
Interface "eth1.4"
Port "eth1.2"
Interface "eth1.2"
Port "eth1.1"
Interface "eth1.1"
Port "br0"
Interface "br0"
type: internal
Port "eth1.3"
Interface "eth1.3"
The truncated output of ifconfig is:
br0: 192.168.3.1
eth0: 192.168.0.105 (There is another home router)
eth1, eth1.1-1.4
As the subnet provides IP prefix of 192.168.3.* and the router itself is assigned IP of 192.168.0., I wonder if it's helpful to add a flow to forward packets from 192.168.3. to 192.168.0.104.
So is it correct if I suppose, a machine with IP 192.168.3.10, for example, it wants to make query to google, the path should be 192.168.3.10->192.168.0.105->192.168.0.1(home router)->outside?
This is to build a flow based on Layer3. But I'm wondering if I can build flows between VLANs? According to my configuration, WAN port is port1, belongs to VLAN 5. Do you think is viable to add flows bidirectionally from VLAN 1 (machine connected) to VLAN 5 and from VLAN 5 to VLAN 1? If so, is there any examples I can flow please?
Another detail. The output of ifconfig shows eth0 interface was assigned IP 192.168.0.105, which means it's connected with my home router (192.168.0.1). So do I need to forward packets between these to IP addresses?
I really appreciate any help.
The following commands add two rules to send packet from VLAN 5 and port 5 to port 1 with VLAN 1 and vice versa:
ovs-ofctl add-flow br0 in_port=5,dl_vlan=5,actions=mod_vlan_vid:1,output:1
ovs-ofctl add-flow br0 in_port=1,dl_vlan=1,actions=mod_vlan_vid:5,output:5
I have solved this problem. Following is the solution.
The main idea is to build a linux bridge connected with OVS bridge, when I need the VLANs to be able talking with outside internet. I can use brctl to operate linux bridge. Firstly I tried:
brctl addbr br-lan
brctl addif br-lan br0
Then all the machine can access to the internet. But unfortunately, only for couple minutes. After that, the router collapsed. I could not access to the OVS router anymore unless I reset it. That could be caused by the incorrect bridge configuration. I tried many ways and finally this one works:
brctl addbr br-lan
ifconfig br-lan 192.168.3.1
brctl addif br-lan br0
ifconfig br0 0.0.0.0
I considered linux bridge br-lan should be originally connected with eth0 (wan). And as I know, br0 could means 'local', with IP address 192.168.3.1. All VLANs talk with this IP address. If I move 'local' to linux bridge which connected with wan port, it should work.
Thanks for everybody who viewed and tried to help me!

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:

Raspberry Pi Zero W Honeypot (similar to Wireless AP)

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.

Raspberry refuses to change IP

I am running raspin on an Raspberry Pi2 and I have configured it to have a staic IP on eth0 but it never changes it sticks to its DHCP lease. This is what I have in the interfaces-file under networking.
iface eth0 inet static
address 192.168.1.60
gateway 192.168.1.1
netmask 255.255.255.0
Have I done anything wrong? Am I blind? :)
Did you try restarting network?
/etc/init.d/networking restart
Not an answer to your question, but a workaround.
Add a static IP lease rule in your DHCP server, this is going to be your router in most cases.
Try restarting the RPi or network - the edited interfaces file doesn't take effect until you do that. Some routers also don't like you requesting a certain IP, so you can also set it to DHCP on the RPi and configure the router so that it always assigns a certain IP to the device.