Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

The new OpenRC networking script

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
145 posts
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Next
Author
Message
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 2:59 pm

the only net.* in /etc/init.d is the new net.lo which is started by openrc

Code: Select all

# cat net.lo
#!/sbin/runscript
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.

depend() {
        provide net
}

start() {
        ebegin "Bringing up network interface lo"
        ifconfig lo 127.0.0.1 netmask 255.0.0.0 up && \
        route add -net 127.0.0.0 netmask 255.0.0.0 dev lo
        eend $?
}

stop() {
        ebegin "Shutting down network interface lo"
        route del -net 127.0.0.0 netmask 255.0.0.0 dev lo &&
        ifconfig lo down
        eend $?
}
It looks to me like dhcpcd takes care of all the rest automatically now.

this is dhcpcd-5.1.2-r1 openrc-0.5.0-r2 and openresolv-3.3.2 on funtoo btw. Does that make a difference?
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 3:10 pm

The net.lo script which I still have here is about 15k. On Gentoo net.lo is the dedicated name for the AllInOneSuperDuperMegaNetworkScript which is supposed to be replaced.

Your net.lo is included in our network init script. About the eth0 interface I don't know what is responsible in your case.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 3:32 pm

My eth0 interface connects my computer nic to the modem - just like before. What else could it be?

My understanding is, now net.lo only performs the task of setting up the lo interface, and nothing else. And dhcpcd handles everything else automatically that does not require special commands.

In my case I use a static IP, so it is configured in /etc/dhcpcd.conf,

Code: Select all

interface eth0
static ip_address=192.168.2.10
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
hence my question about configuring the wlan0 interface in /etc/dhcpcd.conf - but I don't know if this is correct, it's just a guess

Code: Select all

allowinterfaces wlan0
cheers. :)
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 4:07 pm

Mike Hunt wrote:My eth0 interface connects my computer nic to the modem - just like before. What else could it be?
With responsible I mean what is actually calling "ifconfig eth0 up".
My understanding is, now net.lo only performs the task of setting up the lo interface, and nothing else.
The net.lo script you posted does only that, yes. Funtoo differs here from gentoo.
And dhcpcd handles everything else automatically that does not require special commands.
Yeah, most beside brining up the interface itself.
In my case I use a static IP, so it is configured in /etc/dhcpcd.conf,

Code: Select all

interface eth0
static ip_address=192.168.2.10
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
This is a good example on how to set up a static configuration.
hence my question about configuring the wlan0 interface in /etc/dhcpcd.conf - but I don't if this is correct, it's just a guess

Code: Select all

allowinterfaces wlan0
You configure the wlan part of dhcp as you do with ethernet. There is no difference.
allowinterfaces wlan0 tells dhcpcd to only manage wlan0 and ignore all other interfaces.

I suspect udev for brining up your interfaces. You might want to have a look into the udev rules on your system.
Top
d2_racing
Bodhisattva
Bodhisattva
User avatar
Posts: 13047
Joined: Mon Apr 25, 2005 2:25 pm
Location: Ste-Foy,Canada
Contact:
Contact d2_racing
Website

  • Quote

Post by d2_racing » Mon Oct 19, 2009 4:13 pm

sera wrote: What to you mean by stopping? Bringing the interface down? If so this hardly matters for power consumption (unlike wifi) so why would you want that anyway?
I mean, I'm at home on my lazyboy on the net, so I have started /etc/init.d/wpa_supplicant start and I going back to my office on the third floor, so basically, I may want to disable my wireless connection to actually use my lan cable.

So how do I renew my IP adress with my lan interface eth0 ? Does dhcpcd do it automagically ? Or, maybe the best is to use WICD ?
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 4:21 pm

sera wrote:

Code: Select all

allowinterfaces wlan0
You configure the wlan part of dhcp as you do with ethernet. There is no difference.
allowinterfaces wlan0 tells dhcpcd to only manage wlan0 and ignore all other interfaces.
According to man dhcpcd.conf that is what "interface" does. Subsequent options are only parsed for this interface.
sera wrote:I suspect udev for brining up your interfaces. You might want to have a look into the udev rules on your system.
In fact, yes it looks that way.

Code: Select all

# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x14e4:0x1677 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<mac address>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
That's with sys-fs/udev-135-r9 btw.

My apologies if I caused any confusion. :)
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 5:06 pm

Mike Hunt wrote:According to man dhcpcd.conf that is what "interface" does. Subsequent options are only parsed for this interface.
The interface keyword is to create sections for the different interfaces. They start at the keyword interface and end before the next keyword interface or at EOF.
allowinterfaces and denyinterfaces are global withe- resp. blacklists.
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<mac address>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"[/code]
That's not it, this line is only to make sure a certain nic always gets the same interface name. Useful in case of multiple nics.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 6:28 pm

This is what I have in the /etc/udev/rules.d folder

Code: Select all

64-device-mapper.rules  70-persistent-cd.rules   98-devkit.rules
70-libgphoto2.rules     70-persistent-net.rules
70-libsane.rules        90-hal.rules
I don't see anywhere else eth0 is started except dhcpcd - I did grep -r eth0 /etc/* - this is all there is

Code: Select all

# grep '^[^#]' /etc/dhcpcd.conf
hostname
option domain_name_servers, domain_name, domain_search, host_name
option ntp_servers
option interface_mtu
require dhcp_server_identifier
nohook lookup-hostname
interface eth0
static ip_address=192.168.2.10
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 6:41 pm

d2_racing wrote:So how do I renew my IP adress with my lan interface eth0 ? Does dhcpcd do it automagically ? Or, maybe the best is to use WICD ?
Just plugging in the network cable should give you a lease. Dhcpcd is supposed to do all for you here.
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 6:43 pm

Mike Hunt wrote:This is what I have in the /etc/udev/rules.d folder

Code: Select all

64-device-mapper.rules  70-persistent-cd.rules   98-devkit.rules
70-libgphoto2.rules     70-persistent-net.rules
70-libsane.rules        90-hal.rules
I see you have devkit, this might be the reason for your magically brought up interface.

Better grep for net in /etc/udev/rules.d.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 7:15 pm

Oooh magical, cool 8)

Code: Select all

# grep '^[^#].*net' /etc/udev/rules.d/*
/etc/udev/rules.d/70-persistent-net.rules:SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<mac address>", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
A deeper search gives these perhaps relevant lines
  • /etc/conf.d/udev:persistent_net="yes"
    /etc/init.d/udevd: udevadm trigger --subsystem-match=net

Code: Select all

# cat /etc/udev/rules.d/98-devkit.rules

# pass all events to the DeviceKit daemon
RUN+="socket:/var/run/devkit/udev_socket"
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 7:37 pm

You could remove device-kit from any runlevel and restart your machine for a simple test.
Top
d2_racing
Bodhisattva
Bodhisattva
User avatar
Posts: 13047
Joined: Mon Apr 25, 2005 2:25 pm
Location: Ste-Foy,Canada
Contact:
Contact d2_racing
Website

  • Quote

Post by d2_racing » Mon Oct 19, 2009 7:47 pm

Mike Hunt wrote: In my case I use a static IP, so it is configured in /etc/dhcpcd.conf,

Code: Select all

interface eth0
static ip_address=192.168.2.10
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
[/quote]

So, what is the best method to do static IP then ? Using the script or using the dhcpcd.conf ?
Last edited by d2_racing on Tue Oct 20, 2009 11:58 am, edited 1 time in total.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 7:55 pm

d2_racing wrote:So, what is the best method to do static IP then ? Using the script or using the dhcpcd.conf ?
I'm not sure. I think (and/or hope) that it's what we are trying to figure out here. On my box it all works "magically", but it isn't quite clear yet why and how.
Last edited by Mike Hunt on Mon Oct 19, 2009 8:03 pm, edited 2 times in total.
Top
d2_racing
Bodhisattva
Bodhisattva
User avatar
Posts: 13047
Joined: Mon Apr 25, 2005 2:25 pm
Location: Ste-Foy,Canada
Contact:
Contact d2_racing
Website

  • Quote

Post by d2_racing » Mon Oct 19, 2009 8:02 pm

That's why we need Roy to look at that actually.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 8:03 pm

In fact, I only did what UberLord said and it works "magically". 8)
Top
pappy_mcfae
Watchman
Watchman
User avatar
Posts: 5999
Joined: Thu Dec 27, 2007 10:51 pm
Location: Pomona, California.
Contact:
Contact pappy_mcfae
Website

  • Quote

Post by pappy_mcfae » Mon Oct 19, 2009 8:47 pm

Mike Hunt wrote:
pappy_mcfae wrote:... with the new scripted networking setup with openec-0.5 and above, you would at least have to have /etc/runlevels/boot/network and /etc/runlevels/default/dhcpcd to get the new setup to work for dhcpcd.
Yes, my mistake. I did indeed add dhcpcd to the default runlevel.

But there is no network in the boot runlevel

Code: Select all

# eselect rc show boot          
Status of init scripts in runlevel "boot" 
  alsasound                 [started]     
  bootmisc                  [started]     
  fsck                      [started]
  hostname                  [started]
  hwclock                   [started]
  keymaps                   [started]
  localmount                [started]
  lvm                       [started]
  modules                   [started]
  mtab                      [started]
  procfs                    [started]
  root                      [started]
  swap                      [started]
  sysctl                    [started]
  termencoding              [started]
  udev-postmount            [started]
  urandom                   [started]
This is with openrc-0.5.0-r2 btw.
Assumption number ten-million: I believe the presence of dhcpcd in /etc/runlevels/default will not only bring up itself, it would naturally have to bring up /etc/init.d/network as well. I will test that later, after I test the wpa_supplicant script.

Blessed be!
Pappy
This space left intentionally blank, except for these ASCII symbols.
Top
Mike Hunt
Watchman
Watchman
User avatar
Posts: 5287
Joined: Sun Jul 19, 2009 11:01 pm

  • Quote

Post by Mike Hunt » Mon Oct 19, 2009 8:53 pm

pappy_mcfae wrote:I believe the presence of dhcpcd in /etc/runlevels/default will not only bring up itself, it would naturally have to bring up /etc/init.d/network as well. I will test that later, after I test the wpa_supplicant script.

Blessed be!
Pappy
I'm not quite sure about that:

Code: Select all

# stat /etc/init.d/network
stat: cannot stat `/etc/init.d/network': No such file or directory
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Mon Oct 19, 2009 9:01 pm

Seems even newer versions of dhcpcd bring up the interfaces themselves. Amazing. :D
So no need to search any further.

The wlan0 interface is brought up too. Still the wpa_supplicant script is needed unless you choose to go with iwconfig.
Top
pappy_mcfae
Watchman
Watchman
User avatar
Posts: 5999
Joined: Thu Dec 27, 2007 10:51 pm
Location: Pomona, California.
Contact:
Contact pappy_mcfae
Website

  • Quote

Post by pappy_mcfae » Mon Oct 19, 2009 11:37 pm

Using the new networking, here is what I found.

Yes, you need the wpa_supplicant script along with either the dhcpcd script or a script like the one I showed earlier. If you are using an unprotected AP (not a good idea), you don't need the wpa_supplicant script. This has been tested. Now, I'll eliminate /etc/runlevels/network, and see if the scripting still works.

There is no such thing as magic. Take that from a self-identified witch.

Blessed be!
Pappy
This space left intentionally blank, except for these ASCII symbols.
Top
pappy_mcfae
Watchman
Watchman
User avatar
Posts: 5999
Joined: Thu Dec 27, 2007 10:51 pm
Location: Pomona, California.
Contact:
Contact pappy_mcfae
Website

  • Quote

Post by pappy_mcfae » Tue Oct 20, 2009 12:01 am

On the question of whether or not /etc/init.d/network needs to be in /etc/runlevels/boot, the answer is, "yes." However, using net.lo at the same point will also work. The new networking does work with net.lo if /etc/init.d/network is non-existent, or un-started.

So, once again, there is no magic.

Blessed be!
Pappy
This space left intentionally blank, except for these ASCII symbols.
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Tue Oct 20, 2009 7:51 am

d2_racing wrote:
Mike Hunt wrote: In my case I use a static IP, so it is configured in /etc/dhcpcd.conf,

Code: Select all

interface eth0
static ip_address=192.168.2.10
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
[/quote]

So, what is the best method to do static IP then ? Using the script or using the dhcpcd.conf ?[/quote]

It's more a question of personal preferences. If you are using dhcpcd anyway I'd set it in dhcpcd.conf otherwise in network, no additional script needed.
Top
d2_racing
Bodhisattva
Bodhisattva
User avatar
Posts: 13047
Joined: Mon Apr 25, 2005 2:25 pm
Location: Ste-Foy,Canada
Contact:
Contact d2_racing
Website

  • Quote

Post by d2_racing » Tue Oct 20, 2009 11:57 am

If we refer to the Funtoo doc, then we should use the script.
Top
sera
Retired Dev
Retired Dev
Posts: 1017
Joined: Fri Feb 29, 2008 3:03 pm
Location: CET

  • Quote

Post by sera » Tue Oct 20, 2009 12:26 pm

d2_racing wrote:If we refer to the Funtoo doc, then we should use the script.
As we learned in this thread Funtoo is not the same as Gentoo. Thy have a specialized loopback init script called net.lo, not to be confused with our net.lo.

Network on Gentoo is also to bring up the loopback interface but has a little more functionality on top. You can set routes, static IPs, create bridges and other things.
So unlike Gentoo, Funtoo really needs a separate script if not using dhcpcd.
Top
d2_racing
Bodhisattva
Bodhisattva
User avatar
Posts: 13047
Joined: Mon Apr 25, 2005 2:25 pm
Location: Ste-Foy,Canada
Contact:
Contact d2_racing
Website

  • Quote

Post by d2_racing » Tue Oct 20, 2009 12:31 pm

Right now, I'm using OpenRc 0.5.2 without any net.lo,net.eth0 and you were right, dhcpcd is acting like ifplugd.

I have a valid dhcp adress when I plug my net cable and when I play with it, I have a new release of IP adress, so it's working pretty good.

And Wicd is working pretty well also with the new method too.
Top
Post Reply

145 posts
  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Next

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic