Hi, I’m using BealgeBone Black. I would like to use Ethernet port (eth0) with static IP address.
I can use this command to change ip address manually. But every time when I reboot, the ip address will be changed to default again.
sudo ifconfig eth0 192.168.7.51 netmask 255.255.255.0
So I tried other 2 methods. But none of them works. Every time when I reboot the BBB, the ip address will be changed to default again.
Method 1:
Open the file
sudo nano /etc/network/interfaces
Then add the following codes
iface eth0 inet static
address 192.168.7.51
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.151
Then restart the network and reboot
sudo systemctl restart networking
sudo reboot
Method 2:
Use connman commands, the restart network and reboot
sudo connmanctl config ethernet_f4b898874f31_cable --ipv4 manual 192.168.7.51 255.255.255.0 192.168.7.151 --nameservers 8.8.8.8
Any other suggestions? Thanks
Hi @foxsquirrel Thanks for support.
I used pstree
command in BeagleBone. Here is the output.
debian@BeagleBone:~$ pstree
systemd-+-3*[agetty]
|-avahi-daemon---avahi-daemon
|-cron
|-dbus-daemon
|-nginx---nginx
|-rsyslogd---3*[{rsyslogd}]
|-sshd-+-sshd---sshd---bash-+-pstree
| | `-sudo---apt
| `-sshd---sshd---sftp-server
|-systemd---(sd-pam)
|-systemd-journal
|-systemd-logind
|-systemd-network
|-systemd-resolve
|-systemd-timesyn---{systemd-timesyn}
|-systemd-udevd
`-wpa_supplicant
Steven_Wang:
|-systemd-network
To setup a static ip with systemd-network use this for example:
https://wiki.archlinux.org/title/systemd-networkd#Wired_adapter_using_a_static_IP
You’ll find a pre setup /etc/systemd/network/eth0.network
[Match]
Name=eth0
Type=ether
[Link]
RequiredForOnline=yes
[Network]
DHCP=ipv4
So you’d just change this section:
[Network]
DHCP=ipv4
to:
[Network]
Address=10.1.10.9/24
Gateway=10.1.10.1
DNS=10.1.10.1
etc…
Regards,
1 Like
Thanks @RobertCNelson
I solved the static IP problem. I would like to add a little bit more info for ohter beginners. In my case, I would like to set:
static ip address = 192.168.7.51
gateway=192.168.7.151
netmask=255.255.255.0
DNS=8.8.8.8
So I used command
sudo nano /etc/systemd/network/eth0.network
Edit the file to
[Match]
Name=eth0
Type=ether
[Link]
RequiredForOnline=yes
[Network]
DHCP=no
Address=192.168.7.51/24
Gateway=192.168.7.151
DNS=8.8.8.8
Save the file, then use the command
sudo systemctl restart systemd-networkd
Wait for 3-5 seconds, plugin the ethernet cable to BeagleBone Black, use command
ifconfig
Then we will see the eth0 ip address becomes static 192.168.7.51. After reboot, the static IP address is the same.
One more follow-up question:
I must use usb0 cable to connect to the PC, then ssh into the BBB, then plug the ethernet cable. If I plug both cables to the PC when boot up, I cannot ssh to the PC. Why is that?
Thanks a lot
1 Like