I've got a Raspberry Pi. I would like to have it running with a Pidora, and run something cool on it. I'm taking some notes in the process.
DHCP on my machine
For starters, let's have it running. I could attach it to the ADSL router, but where's the fun in this? So I learned a number of things. My local machine is going to act as DHCP server on the Ethernet NIC, where I'll attach the Raspberry.
Setup of the local machine:
DNSMasq
port=0
for disabling DNS and keeping DHCP;interface=eno1
since I just want to run it on the Ethernet interface;dhcp-range=192.168.128.2,192.168.128.20
declares my DHCP range.dhcp-option=6,192.168.1.1
will ask DHCP clients to use 192.168.1.1 (the ADSL router) as DNS.
The Ethernet connection must be static
- Option 0: Disable network manager and control manually
- Option 1: Control using network manager (
nmcli
), so we can keep configuration. Going for this one.
My Ethernet configuration
After editing with nmcli
a new connection named dhcp_serve
, I
obtained the following network script:
$ cat /etc/sysconfig/network-scripts/ifcfg-dhcp_serve
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=dhcp_serve
UUID=2dddede7-15e8-4a6c-a3ef-2299f4bc6f00
DEVICE=eno1
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
ZONE=internal
IPADDR=192.168.128.1
PREFIX=24
Some comments and gotchas:
I had to manually set
BOOTPROTO=none
in order to disable the DHCP server to run automatically on this connection. This is because we are offering DHCP, but I noticed that TCP was reporting my machine's attempts to do it.If you want your DNSMasq to actually work, it's a put that
/24
on your network. Here thePREFIX
was added by thenmcli
editor when I specified192.168.128.1/24
as address. By default it goes with/32
.The firewall will be in the way. I'm doing this on a Fedora, where the configuration is not linear IMHO.
iptables -L
gives me kind of a maze. I'm not (yet) expert with IP Tables, thus I need to go forfirewall-config
:The
dhcp
port must be enabled in the firewall configuration. This is going to affect theinternal
Zone as consequence of the previous point.The Zone of the Ethernet connection is going to be
internal
. This was set with the mentionedfirewall-config
tool, and got reflected on this network script. The fact is: we want to enable the DNS Masquerade (NAT) later on!
Of course, enable IP forwarding:
echo 1 > /proc/sys/net/ipv4/ip_forward
Apparently it works, but how do I prevent NM to automatically reset everything if (say) the Raspberry goes down or I detach the Ethernet cable? TODO think of this.
Fresh login in Pidora
After the DHCP is set, it's simply a matter of ssh to the correct IP address. Something you get from the logs.
The default password is just raspberrypi
, as mentioned in the
online documentation.
Fix the SD Card
The default installation will just use 2 of the N available gigabytes. In my case I've got 4 Gigabytes. The graphic installation application however shows a resize root filesystem option.
There must be a program for this.
$ rpm -qa | grep resize
rootfs-resize-3.0-7.rpfr20.noarch
Yup. Sounds like we found it. How does it work?
$ rpm -ql rootfs-resize
/.nofsresize
/.rootfs-repartition
/.rootfs-resize
/.swapsize
/usr/lib/systemd/system/rootfs-resize.service
/usr/sbin/rootfs-resize
/usr/share/doc/rootfs-resize
/usr/share/doc/rootfs-resize/COPYING
/usr/share/doc/rootfs-resize/README.md
It's fairly easy: the rootfs-resize
program is a python script. It
requires certain files in place as parametrization. Everything is clearly
described in the script in form of comments.
Just run and claim all your space.