User avatar
DougieLawson
Posts: 32372
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 7:39 am

I think the simplest fix for /etc/rc.local is to change
/lib/systemd/system/rc.local.service from

Code: Select all

After=network.target
to

Code: Select all

After=network-online.target
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

hippy
Posts: 2871
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 2:30 pm

DougieLawson wrote:After=network-online.target
That did not work for me. It seems the network is considered online before rc.local and dhcpcd are started.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 2:32 pm

hippy wrote:
DougieLawson wrote:After=network-online.target
That did not work for me. It seems the network is considered online before rc.local and dhcpcd are started.
On and on they bravely go into the gloom.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5069
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 2:45 pm

network-online.target doesn't REALLY know when you're online. You could put something that tests for connectivity and exits when it's found and run it Before=network-online.target, but I don't see much of a point in doing that.

Until we see services which require network-online.target actually rely on network-online.target in their unit files, we'll just settle for either waiting until an IP is granted before saying the network is up or accepting that the network may or may not be up.

At this stage, the following has been decided:
The headless image will wait for the network and the IP address line will appear.
The full image will not wait for the IP address.
The option will be configurable in rc_gui and raspi-config.

I think the 'right' solution would be to make dhcpcd start 'Before' network-online.target and tell it to wait for an IP address. It would speed up boot, since things which don't require the internet connection are free to start in parallel. However, then rc.local and some other services would need to be changed to start after network-online.target.

Another option is to do the above and not modify any service files. Instead, provide instructions on how to make the change yourself, but that's just shifting the burden to the users.

hippy
Posts: 2871
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 2:58 pm

ShiftPlusOne wrote:I think the 'right' solution would be to make dhcpcd start 'Before' network-online.target and tell it to wait for an IP address. It would speed up boot, since things which don't require the internet connection are free to start in parallel. However, then rc.local and some other services would need to be changed to start after network-online.target.
That would seem to me to be the best and most correct solution.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5069
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Jessie: How to display "My IP address is" at login promp

Thu Oct 15, 2015 3:19 pm

hippy wrote:
ShiftPlusOne wrote:I think the 'right' solution would be to make dhcpcd start 'Before' network-online.target and tell it to wait for an IP address. It would speed up boot, since things which don't require the internet connection are free to start in parallel. However, then rc.local and some other services would need to be changed to start after network-online.target.
That would seem to me to be the best and most correct solution.
And perhaps that will be it eventually.

vrx
Posts: 1
Joined: Sun Nov 29, 2015 6:53 pm

Re: Jessie: How to display "My IP address is" at login promp

Sun Nov 29, 2015 7:20 pm

sudo emacs /etc/network/interfaces

# for dhcp
auto eth0
iface eth0 inet dhcp
# manual should be deactivated and auto eth0 added

# for a minimal static address
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0

sudo emacs /etc/rc.local
# Print the IP address with red color
_IP=$(hostname -I) || true
RED='\033[0;31m'
NC='\033[0m' # No Color
if [ "$_IP" ]; then
printf "IP address is ${RED} %s ${NC}\n" "$_IP"
rm -f /etc/issue
printf "IP address is ${RED} %s ${NC}\n" "$_IP" >> /etc/issue
cp -f /etc/issue /etc/issue.net
fi

exit 0

User avatar
DougieLawson
Posts: 32372
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Jessie: How to display "My IP address is" at login promp

Mon Nov 30, 2015 8:28 am

vrx wrote:sudo emacs /etc/network/interfaces

# for dhcp
auto eth0
iface eth0 inet dhcp
# manual should be deactivated and auto eth0 added

# for a minimal static address
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0

sudo emacs /etc/rc.local
# Print the IP address with red color
_IP=$(hostname -I) || true
RED='\033[0;31m'
NC='\033[0m' # No Color
if [ "$_IP" ]; then
printf "IP address is ${RED} %s ${NC}\n" "$_IP"
rm -f /etc/issue
printf "IP address is ${RED} %s ${NC}\n" "$_IP" >> /etc/issue
cp -f /etc/issue /etc/issue.net
fi

exit 0

What are you trying to do?

Static addresses are set in /etc/dhcpcd.conf now. Leave /etc/network/interfaces and /etc/rc.local alone.

Also why emacs? Are you 100% insane?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

ronnyvdbr
Posts: 68
Joined: Sun Mar 01, 2015 8:42 pm

Re: Jessie: How to display "My IP address is" at login promp

Thu Feb 04, 2016 8:13 am

To set a static IP address, add below lines to /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.x/24
static routers=192.168.0.x
static domain_name_servers=192.168.0.x
(replace the x's with your own details :mrgreen: )
Reboot to apply, or run sudo dhcpcd -n to apply immediately.


To set a static ip address on the fly with immediate effect:
sudo dhcpcd -S ip_address=192.168.0.x/24 -S routers=192.168.0.x -S domain_name_servers=192.168.0.x -n eth0

japi
Posts: 1
Joined: Thu Jan 18, 2018 6:22 am

Re: Jessie: How to display "My IP address is" at login prompt

Thu Jan 18, 2018 6:25 am

Just check "Wait for network" in the Raspberry Pi Configuration, you will get it.

Return to “Raspbian”

Who is online

Users browsing this forum: blachanc and 4 guests