Unable to start eth0 interface on raspberry pi4 model B - raspberry-pi4

I could not find any useful resource. How to restart eth0 properly. I'm running ubuntu server 22.04.1 on raspberry pi 4 model B. I tried running sudo ifconfig eth0 up it did not work.
eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
Here is network configure on raspberry pi
pi#homeserver:/etc/network$ ls
if-down.d if-post-down.d if-pre-up.d if-up.d interfaces
pi#homeserver:/etc/network$ cat interfaces
# 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
pi#homeserver:/etc/network$ ls
if-down.d if-post-down.d if-pre-up.d if-up.d interfaces
pi#homeserver:/etc/network$
Any help greatly appreciated.

Related

Configure kvm (libvirt) routed network on Ubuntu 16.04 host

I have an Ubuntu 16.04 KVM hypervisor behind a Debian-based firewall, and I'm trying to make the guest VMs IP-reachable, preferably matching the subnet I'm using for that collection of machines.
The firewall is hosting a 10.4.0.0/16 network, and successfully NAT'ing and accepting applicable traffic.
The hypervisor is at 10.4.20.250, with the virsh network configuration shown below. Of note, I've extended the netmask to try separating the clients from the host:
<network>
<name>default</name>
<uuid>02b5de1a-cde4-45dd-b8f5-a9fdfa1c6809</uuid>
<forward mode='route'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:a3:f0:e9'/>
<ip address='10.4.20.20' netmask='255.255.255.128'>
</ip>
</network>
The hypervisor (10.4.20.250) also has the following:
# ip r
default via 10.4.0.1 dev enp0s25 onlink
10.4.0.0/16 dev enp0s25 proto kernel scope link src 10.4.20.250
10.4.20.0/25 dev virbr0 proto kernel scope link src 10.4.20.20
169.254.0.0/16 dev enp0s25 scope link metric 1000
# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.fe54009e64d0 yes vnet0
# ip link show virbr0
3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether fe:54:00:9e:64:d0 brd ff:ff:ff:ff:ff:ff
# virsh domiflist myguest
Interface Type Source Model MAC
-------------------------------------------------------
vnet0 bridge virbr0 virtio 52:54:00:9e:64:d0
The guest ("myguest") at 10.4.20.25 is able to reach the internet at large; it's configured with:
ip r
default via 10.4.20.20 dev eth0
10.4.0.0/17 dev eth0 proto kernel scope link src 10.4.20.25
From a terminal session connected to the hypervisor (10.4.20.250), I can ping itself, the bridge at 10.4.20.20, the guest at 10.4.20.25, the firewall at 10.4.0.1, and the internet at large.
From the firewall (10.4.0.1) I can ping the hypervisor (10.4.20.250) and the bridge (10.4.20.20) .. but pings to the client (10.4.20.25) are lost. Similarly, from another machine on the 10.4 network, I can ping the firewall, the hypervisor, and the bridge, but not the client. I have the following rules set:
ip r
default via 10.4.0.1 dev enp4s0 onlink
10.4.0.0/16 dev enp4s0 proto kernel scope link src 10.4.2.1
10.4.20.0/25 via 10.4.20.20 dev enp4s0
192.168.15.0/24 dev enp1s0 proto kernel scope link src 192.168.15.242
Any help what configuration I might be missing to make my client be reachable from remote devices?
Note, I have tried to set the forward mode as 'open' but virsh net-edit gives me the following error:
error: unsupported configuration: unknown forwarding type 'open'

Raspberry pi is unable to reach gateway

Recently we brought raspberry pi 3b.Beginning we used to access the internet using an ethernet cable and it used to connect properly but now raspberry pi is not able to reach the gateway itself and it's taking its default IP address i.e 169.xxx.xxx.xx.
what would be the issue?we tried to reinstalling the operating system again the same issue .it worked for one day after that same problem.so please help me to solve the issue.
Finally, I am able to figure it out after trial and error method. I have missed "auto eth0" before the iface statement i.e
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
network 255.255.255.0
gateway xxx.xxx.xxx.xxx
dns-nameservers 8.8.8.8
Assuming that you have a windows computer available, open cmd and run the following command:
ipconfig
note down the values that display. Now on your pi, enter the command
sudo nano /etc/network/interfaces
This will open the network interfaces file. Look for the line similar to 'inet eth0 inet manual' Then remove this line and everything to do with the eth0 interface, since we are going to start over.
in the interfaces file, add the following section:
auto eth0
inet eth0 inet static
address xxx.xxx.xxx.xxx
network 255.255.255.0
gateway xxx.xxx.xxx.xxx
dns-nameservers 8.8.8.8
Replace the x in address with the first 3 groups of the value taken from the windows system. For example, if the ip address on the windows system was 192.168.0.221, enter 192.168.0.xxx
The last group of xxx for address should be something unique to everything else on your network.
'gateway' should be whatever the gateway value in windows was (assuming these machines are on the same network)
[Ctrl]+[x], Save changes
reboot via
sudo reboot
once the system has rebooted
ifconfig eth0
should list the new settings. Test them by pinging the below address (google)
sudo ping 8.8.8.8

Hotspot using hostapd and wpa_supplicant

I need to create a hotspot setup using hostapd for EAP-SIM,EAP-AKA and EAP-AKA' and test it with wpa_supplicant.
Currently I am able to use hostapd for WPA-PSK authentication, hostapd2.4 is used for this setup.I have modified the hostapd.conf for supporting hotspot but when I try to connect , the network will be always in scanning state and won't connect. The necessary parameters for HS20 in wpa_supplicant is also enabled.
The following are the supplicant parameters,
build configuration:
CONFIG_INTERWORKING=y
CONFIG_HS20=y
wpa_supplicant configuration:
Enable Interworking
interworking=1
Enable Hotspot 2.0
hs20=1
auto_interworking=1
Also have specified a credentials block which takes necessary parameters for authentication with hostapd.
Using wpa_supplicantv2.5.I also have a dhcp server running for assigning IP address and also a milenage db running for EAP-SIM,EAP-AKA and EAP-AKA' authentication.
Can anyone suggest what are the necessary basic setup for enabling hotspot in hostapd?
Step 1 :
iw list Check AP is listed
Step 2 :
sudo vim hostapd.conf
-------------------------- interface=wlan0 driver=nl80211 ssid=ath9k_SSID #SSID hw_mode=g channel=1 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=3 wpa_passphrase=12345678
#password wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP rsn_pairwise=CCMP
#comment last 4 lines for Open
Step 3 :
sudo vim /etc/dhcp/dhcpd.conf
-------------------------- default-lease-time 600; max-lease-time 7200; subnet 192.168.1.0 netmask 255.255.255.0 { range
192.168.1.170 192.168.1.200; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "mydomain.example"; }
Step 4 :
sudo vim /etc/network/interfaces
-------------------------- auto wlan0 iface wlan0 inet static address 192.168.1.250 netmask 255.255.255.0
Step 5 :
sudo /etc/init.d/isc-dhcp-server stop sudo service network-manager stop sudo killall wpa_supplicant ps -N | grep -i hostapd # make sure there are no hostapd/wpa_supplicant processes are running
Step 6 :
Remove ethernet cable sudo ifconfig wlan0 192.168.1.169 netmask
255.255.255.0 sudo /etc/init.d/isc-dhcp-server restart => to set IP for STA sudo ./hostapd ./hostapd.conf -dddt Step 7: Connect from another device. Should be able to see the IP assigned.

How to connect multiple Dockers to different bridges in a single host machine?

Is it possible to connect multiple Dockers (in my case, multiple instances of the same docker) each to different bridge in a single host machine?
3rd party solutions like pipework recommends first looking for "native" ways.
Something like that:
When I start 2 instance, the 1st use by default docker0 bridge, while the 2nd is instructed to use br1 (different IP range) :
sudo docker run -t -i me/tester:latest /bin/bash
sudo docker --bridge=br1 run -t -i me/tester:latest /bin/bash
results in both having the same IP range from Doker0:
root#2a259a88d9c8:/# ip a
...
73: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 86:d7:cc:c8:b7:e8 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.32/16 scope global eth0
--
root#0b849a5398af:/# ip a
...
79: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 26:84:ad:6c:70:6b brd ff:ff:ff:ff:ff:ff
inet 172.17.0.34/16 scope global eth0
valid_lft forever preferred_lft forever
This is how it is done using the new native docker networking:
Create docker networks (linux bridges) with a predefined subnets
docker network create --subnet=192.168.10.0/24 net1
docker network create --subnet=192.168.20.0/24 net2
docker network create --subnet=192.168.30.0/24 net3
The created networks correspond to linux bridges
brctl show
Create tap interfaces
sudo ip tuntap add dev tap1 mode tap
sudo ip tuntap add dev tap2 mode tap
sudo ip tuntap add dev tap3 mode tap
and join them to the bridges
sudo brctl addif br-a24f2eb2e054 tap1
sudo brctl addif br-d28c0759c37a tap2
sudo brctl addif br-d9512f62e471 tap3
starting your containers
sudo docker run -itd --name=c1 phusion/baseimage
sudo docker run -itd --name=c2 phusion/baseimage
sudo docker run -itd --name=c3 phusion/baseimage
Connecting containers to network
docker network connect net1 c1
docker network connect net2 c2
docker network connect net3 c3
Verify that each container is connected to its network
docker network inspect net1
docker network inspect net2
docker network inspect net3
Connected containers get their ip from their corresponding network subnets
docker exec c1 ip a s eth1
docker exec c2 ip a s eth1
docker exec c3 ip a s eth1
Disconnecting containers from networks
docker network disconnect net1 c1
docker network disconnect net2 c2
docker network disconnect net3 c3
Remove the networks
docker network rm net1
docker network rm net2
docker network rm net3
You can create custom bridges and then run each container with the option -b <BRIDGE> or --bridge=<BRIDGE>, but I have not try this and I wouldn't be absolutely sure that this approach works without any issue. If you read this Docker issue, I think the suggest it is not possible this way.
But as commented in that issue, you can disable any docker network management (running the container with the option --net=none, and then organize the network as you wish using pipework.
Finally you can take a look of zettio/weave. Using it you can run easily each container in the network you wish, and also it gives you a lot of possibilities if you want to expand your docker environment from one to various machines (as docker swarm does).

Using TunTap with linux kernel 2.6

The TunTap documentation on the vtun site points out that the driver is only supported till Linux kernel 2.4. Is there any way to get it to run on 2.6 and 3.2 versions of Linux?
A cat on the device shows:
# cat /dev/net/tun
cat: File descriptor in bad state
I tried installing directly from the rpm file to see how far I could go and got:
# rpm -i tun-1.1-6.rh71.i386.rpm
error: Failed dependencies:
/bin/sh is needed by tun-1.1-6.i386
Is there any way I can get this to work on linux 2.6+ or are there any good alternatives to tuntap that you are aware of?
The tuntap documentation is outdated. Also, in newer versions of linux, you might need to use
tunctl
instead of
ip tuntap add
To install tunctl on debian Squeeze, install the package 'uml-utilities' which provides the tunctl command. You can add a new tunnel using
tunctl -t tun1
Use the below script to create it automatically, just copy the contents in to a file.sh, change the "ETHOIPADDR" to your ip address, similarly also the change the gateway and broadcast address and run the script with sudo permission.
#!/bin/sh
#
# script to bring up the tun device in QEMU in bridged mode
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
ETH0IPADDR=192.168.0.3
GATEWAY=192.168.0.1
BROADCAST=192.168.0.255
#
# First take eth0 down, then bring it up with IP address 0.0.0.0
#
/sbin/ifdown eth0
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
/usr/sbin/brctl addbr br0
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl addif br0 $1
#
# only a single bridge so loops are not possible, turn off spanning tree protocol
#
/usr/sbin/brctl stp br0 off
#
# Bring up the bridge with ETH0IPADDR and add the default route
#
/sbin/ifconfig br0 $ETH0IPADDR netmask 255.255.255.0 broadcast $BROADCAST
/sbin/route add default gw $GATEWAY
#
# stop firewall - comment this out if you don't use Firestarter
#
/sbin/service firestarter stop

Resources