BPI R2 Create DHCP for LAN Ports

Hello, I have a banana pi R2 board card. I installed the ubuntu operating system on this card as in the link https://wiki.banana-pi.org/Getting_Started_with_R2. My purpose is to process the data coming from the devices connected to the card via LAN ports via tcp protocol or send it to the network that I am connected to via GWAN(eth1). What I want to do at the first stage is to assign ip to raspberry pi devices connected to Banana Pi LAN ports with dhcp. when i connect raspberry pi devices to LAN i can’t see raspberry pi getting an ip on eth0.

I may not have been able to express myself fully because my experience in embedded linux is insufficient. Can you please help with this regards

first you should use a newer system as the vendors ubuntu/debian images (afair ubuntu 16.4/18.4) will get no updates anymore. Search in forum for my buster/ubuntu 20.4 image.

then your network topology is not clean to me…you are talking about an rasberry pi and some devices you want to connect to r2’s lan-ports…

so i guess your topology is like this

RPI - (wan) r2 (lan) - other devices

so you need a dhcp server running on r2-lan-ports/bridge to get your clients obtaining an ip from r2. then you need a static route on your rpi because it does not know your subnet from r2 lan segment (which has to be different to the r2wan/RPI network) or you have to setup NAT on r2 wan-port, so that all traffic from clients reach RPI with r2s WAN-IP

you’ll find some information how to do on my wiki https://wiki.fw-web.de/

Hello thanks for your answer My topology Home Network<--------DATA—GWAN(BananaPI eth1) <—cpu<—eth0–LAN PORT<-----RPI Firstly I want to assign a IP to RPI and my LAN port ,because I want to send TCP message from my RPI to Banana PI. I don know where I started . Best Regards

Ok, so your rpi is client on r2 lan.

Basicly it is same, so just install dhcp server listening on lan-port(s) and on wan configure NAT or add static route in your home gateway for traffic from rpi to homegateway

You can create a bridge over lan-ports,add ip to it which is gateway for rpi and configure dhcp-server (dnsmasq or systemd-networkd or any other) pushing subnet and gateway to rpi

E.g.

Homegateway
192.168.0.1/24
|
192.168.0.2/24
Wan
R2
Lanbr0
192.168.1.1/24 (dhcp range 192.168.1.2-100,gateway 192.168.1.1)
Lan0 lan1 lan2
|
192.168.1.5/24
Rpi

Then add nat on wan or add a static route in your homegateway that 192.168.1.0/24 is reached via 192.168.0.2

Thanks for your answers. Could you share a document about configuring dhcp on LAN ports ? I have not enough experience in embedded Linux.

It’s only linux…nothing special there…services are setup the same way like on x86

My current network config uses dnsmasq as dhcp server, see server section here: https://wiki.fw-web.de/doku.php?id=en:bpi-r2:network:start#dhcp

Thank you for replys Best regards

Hello I tried many solution but i couldn’t get a result form my test. when i connectted my rpi to BananaR2 lan0 port, rpi always get ip 169.254.72.171 . when i tried ping 169.254.72.171 on my bananapi i always get Destination Host Unreachable error. how can i fix it ? Best Regards

you have to set an ip to the lan-port (e.g. 192.168.0.1, needs to be different to your other lan-segments) on r2 and run an dhcp-server (i use dnsmasq, see my wiki) on this interface propagating the ip subnet (192.168.0.2-254/24) to your rpi

169.254.72.171 is no valid lan-subnet

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:network:start#dhcp

i configured /etc/network/interfaces file as follows:

The loopback network interface

auto lo iface lo inet loopback

auto lan0 iface lan0 inet manual

auto eth0 iface eth0 inet manual pre-up ip link set $IFACE up post-down ip link set $IFACE down auto lan0 iface lan0 inet manual pre-up ip link set $IFACE up post-down ip link set $IFACE down

after that i configured /etc/dnsmasq.d/interfaces.conf file as follows interface=lan0 #interface=wlan1

interface=tun0

interface=lxcbr0

interface=eth1

#interface=ap0

DHCP-Server nicht aktiv fĂĽr Interface no-dhcp-interface=ppp0

#no-dhcp-interface=bond0 no-dhcp-interface=eth1 no-dhcp-interface=lxcbr0 #dhcp-authoritative dhcp-range=lan0,192.168.10.100,192.168.10.150,255.255.255.0,48h dhcp-option=lan0,3,192.168.10.1 But i got “unknown interface lan0” error. could you help me Best regards

which image/kernel do you use? is guess you use old image with kernel 4.4, right? there is no lan0

cat /etc/issue
uname -a
ip a

old 4.4 kernel has only eth0 and eth1 where wan was afair wan-port is eth1 and eth0 is lan. so replace lan0 by eth0 in your dhcp config and configure eth0 with static lan-IP

Thank you it is working Ä° put configuration below may be you could share in forum. Ä° do not know rules .

sudo nano /etc/network/interfaces
////////////////////////////////////////////////////

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 192.168.10.120
  netmask 255.255.255.0
  gateway 192.168.10.1
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down
/////////////////////////////////////////////
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved 
ls -lh /etc/resolv.conf 
sudo unlink /etc/resolv.conf
echo nameserver 8.8.8.8 | sudo tee /etc/resolv.conf
sudo apt update
sudo apt install dnsmasq
---------------->E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
                     E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
                      try it https://itsfoss.com/could-not-get-lock-error/ method1 
sudo nano /etc/dnsmasq.conf 
"#conf-dir=/etc/dnsmasq.d" ->"conf-dir=/etc/dnsmasq.d"  (delete only # ) 
sudo nano /etc/dnsmasq.d/interfaces.conf
////////////////////////////
interface=eth0
#interface=wlan1
# interface=tun0
# interface=lxcbr0
# interface=eth1
#interface=ap0
# DHCP-Server nicht aktiv fĂĽr Interface no-dhcp-interface=ppp0
#no-dhcp-interface=bond0 no-dhcp-interface=eth1 no-dhcp-interface=lxcbr0
#dhcp-authoritative
dhcp-range=eth0,192.168.10.100,192.168.10.150,255.255.255.0,48h
dhcp-option=eth0,3,192.168.10.1
////////////////////////////////////////////////
service dnsmasq start
sudo reboot 

Best Regards

you should use an ip for interface outside the dhcp-range e.g. 192.168.10.99

wonder about your apt error

and please use code-block (<>) next time, i have edited your post

1 Like