Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
NetworkManager and static IP [SOLVED! THANKYOU]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Mon Jan 02, 2017 10:47 pm    Post subject: NetworkManager and static IP [SOLVED! THANKYOU] Reply with quote

I've been running a static ip address on my desktop machine forever, and never had a problem
with standard gentoo networking through /etc/conf.d/net -- that setup works fine.

Lately I've found that NetworkManager has crept onto my system and manages a second
IP address it gets from DHCP. I don't want that. Seems like it does the right thing until
I start KDE with startx.

How can I get it to stop? I tried emerge -C, but portage just wants to remerge it.

What is the standard way to not use NetworkManager? In googling all I find is astonishment,
like why would anybody do that? I just don't need two IP's is all. Not in this wild west university
computing environment i'm in.

Or how do I tell it about my static IP address? I don't think I need modemmanager either.
I use KDE and openrc.

Cheers,

Jon


Last edited by jesnow on Wed Jan 04, 2017 11:33 pm; edited 2 times in total
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Mon Jan 02, 2017 11:07 pm    Post subject: Reply with quote

Personally I did the opposite, but if you want to disable NetworkManager my suggestion would be to try the following:

1. Disable the NetworkManager service from starting at boot:

Code:
# rc-update delete NetworkManager default


2. As belt and braces, set 'unmanaged-devices' in the keyfile section in /etc/NetworkManager/NetworkManager.conf as per the snippet from 'man NetworkManager.conf' quoted below.

Code:
KEYFILE SECTION
       This section contains keyfile-plugin-specific options, and is normally only used when you
       are not using any other distro-specific plugin.

       hostname
           This key is deprecated and has no effect since the hostname is now stored in
           /etc/hostname or other system configuration files according to build options.

       path
           The location where keyfiles are read and stored. This defaults to
           "/etc/NetworkManager/conf.d".

       unmanaged-devices
           Set devices that should be ignored by NetworkManager.

           See the section called “Device List Format” for the syntax how to specify a device.

           Example:

               unmanaged-devices=interface-name:em4
               unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4;interface-name:eth2

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog


Last edited by Fitzcarraldo on Mon Jan 02, 2017 11:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Mon Jan 02, 2017 11:11 pm    Post subject: Reply with quote

Thanks! How do you go the other way (ie static IP with NetworkManager?). It seems that the method in the
gentoo installation guide is not correct if that's necessary.

Networkmanager was not in my default runlevel, I think qt must be starting it.

restarting the interface shows the duelling ip's:

Code:


Merckx jesnow # /etc/init.d/net.enp2s0 restart
net.enp2s0         | * Bringing down interface enp2s0
net.enp2s0         | *   Stopping dhclient on enp2s0 ...                                                                           [ ok ]
net.enp2s0         |RTNETLINK answers: No such file or directory
net.enp2s0         |Error talking to the kernel
net.enp2s0         | * Bringing up interface enp2s0
net.enp2s0         | *   129.7.229.76 ...                                                     
net.enp2s0         | *   Adding routes
net.enp2s0         | *     default via 129.7.229.254 ...                                       
Merckx jesnow # ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 129.7.52.242  netmask 255.255.254.0  broadcast 129.7.53.255
        inet6 fe80::88e2:1d18:5a46:43a2  prefixlen 64  scopeid 0x20<link>
        ether 40:61:86:0d:a3:e6  txqueuelen 1000  (Ethernet)
        RX packets 207739  bytes 46070763 (43.9 MiB)
        RX errors 0  dropped 34  overruns 0  frame 0
        TX packets 17845  bytes 1951956 (1.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 483  bytes 37833 (36.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 483  bytes 37833 (36.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Mon Jan 02, 2017 11:31 pm    Post subject: Reply with quote

jesnow wrote:
Thanks! How do you go the other way (ie static IP with NetworkManager?). It seems that the method in the gentoo installation guide is not correct if that's necessary.


I used the Plasma 5 Connection Editor. On the IPv4 tab I set the Method to 'Manual', entered the IP addresses of the DNS servers -- separated by commas -- in the 'DNS Servers' box, clicked on '+ Add' and entered the static IP address I wanted to use, the Netmask (I entered 255.255.255.0), and the Gateway IP address. Works fine. Alternatively, one could edit the appropriate connection file directly in the /etc/NetworkManager/system-connections/ directory ('man nm-settings' lists the various parameters). Mine looks like the following (annonymised):

Code:
[connection]
id=Work Wired Network
uuid=11111111-2222-3333-4444-555555555555
type=ethernet
autoconnect=false
permissions=user:fitzcarraldo:;
secondaries=

[ethernet]
mac-address=AA:BB:CC:DD:EE:FF
mac-address-blacklist=

[ipv4]
address1=192.168.1.112/24,192.168.1.1
dns=111.22.33.44;111.22.33.55;111.22.33.66;111.22.333.777;
dns-search=
may-fail=false
method=manual

[ipv6]
dns-search=
method=ignore

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Mon Jan 02, 2017 11:52 pm    Post subject: Reply with quote

I just want it to work the way it says in the Gentoo configuration guide.

/etc/conf.d/net:
Code:


# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).

config_enp2s0="129.7.229.76 netmask 255.255.254.0"
routes_enp2s0="default via 129.7.229.254"

dns_servers_enp2s0="208.67.222.222 129.7.1.6 8.8.8.8 129.7.1.1"
dns_options_enp2s0="timeout 1 rotate"



This should really work and it doesn't!
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Tue Jan 03, 2017 12:04 am    Post subject: Reply with quote

OK, here's something strange: Netowkrmanager id for sure not in any of my runlevels:

Code:

Merckx jesnow # rc-update show
            alsasound | boot                                         
               binfmt | boot                                         
             bootmisc | boot                                         
          consolefont | boot                                         
                cupsd |      default                                 
                 dbus |      default                                 
            denyhosts |      default                                 
                devfs |                                        sysinit
                dmesg |                                        sysinit
                 fsck | boot                                         
             hostname | boot                                         
              hwclock | boot                                         
           irqbalance |      default                                 
              keymaps | boot                                         
            killprocs |                        shutdown               
    kmod-static-nodes |                                        sysinit
                local |      default nonetwork                       
           localmount | boot                                         
             loopback | boot                                         
              modules | boot                                         
             mount-ro |                        shutdown               
                 mtab | boot                                         
               net.lo | boot default                                 
             netmount |      default                                 
               procfs | boot                                         
                 root | boot                                         
                samba |      default                                 
            savecache |                        shutdown               
                 sshd |      default                                 
                 swap | boot                                         
               sysctl | boot                                         
                sysfs |                                        sysinit
            syslog-ng |      default                                 
         tmpfiles.dev |                                        sysinit
       tmpfiles.setup | boot                                         
                 udev |                                        sysinit
              urandom | boot                                         
           vixie-cron |      default                                 
Merckx jesnow #



But *something* was starting it anyway. So I can shut it down with /etc/init.d/NetworkManager stop, and
down it goes, and the interface now functions correctly.

How do I get NetworkManager NOT to start on boot? Who is starting it?
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Tue Jan 03, 2017 12:56 am    Post subject: Reply with quote

Interesting. According to the Arch Linux Wiki:

Arch Wiki/NetworkManager wrote:
Disable NetworkManager

It might not be obvious, but the service automatically starts through dbus. To completely disable it you can mask the services NetworkManager and NetworkManager-dispatcher.


I have just tried removing the NetworkManager and netmount services from the default runlevel but doing so does not stop dbus starting the NetworkManager service. I expect there is a 'proper' way to stop dbus from automatically starting NetworkManager at boot, but I don't know it. However, you could try the following work-around to stop the service automatically after it has started:

1. Create the file /etc/local.d/10-stop-NetworkManager.start containing the following:

Code:
#!/bin/bash
/etc/init.d/NetworkManager stop

2. Make it executable:

Code:
# chmod +x /etc/local.d/10-stop-NetworkManager.start

3. Reboot to test.


EDIT: Yep, that works.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
jesnow
l33t
l33t


Joined: 26 Apr 2006
Posts: 856

PostPosted: Wed Jan 04, 2017 11:32 pm    Post subject: Reply with quote

I'm going to close out this thread because I got it solved.

Networkmanager is an application and a service like any other. It has use
flags, packages and dependencies. Get rid of those and no more networkmanager.

I turned off USE flags networkmanage and geoloc in make.conf, and
added to /etc/portage/package.use:
Code:

kde-plasma/plasma-workspace -geolocation

That gets rid of all the dependencies, I then unmerged networkmanager itself
and everything connected to it:

Code:

kde-frameworks/networkmanager-qt
net-misc/networkmanager
net-misc/modemmanager


When I did emerge --depclean, a whole lot of other stuff got nuked.
revdep-rebuild did the rest. I think it did rebuild some packages,
but that may have been triggered by other stuff I had removed earlier.

Fact is, my machine doesn't move around, doesn't change networks,
and DOES NOT EVER have a different IP than the one it was assigned.
NetworkManager is marvelous "just-works" software dealing with a shifting
net environment, but doesn't cope well with my corner situation where
none of that is necessary or even wanted.

Thanks to everyone!

Jon.
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Thu Jan 05, 2017 5:08 am    Post subject: Reply with quote

That is certainly the cleanest approach if you will never have a need for NetworkManager.

Nevertheless your initial predicament really roused my curiosity. Not being able to stop NetworkManager from starting in the first place, even though its init script is not in a runlevel, bugged me. The work-around I posted earlier is not good enough, as it closes the stable door after the horse has bolted. I tried all sorts of things with D-Bus configuration files, nmcli commands and so on, but then hit on a relatively straightforward way of stopping the service starting in the first place: I added the following line to the configuration file /etc/conf.d/NetworkManager:

Code:
rc_need="non-existent_service"

I know it is rather ugly, but it does the job. Now D-Bus cannot automatically reactivate NetworkManager, because it was never launched in the first place.

Anyway, good to read that you solved your problem.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum