Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Static IP with NetworkManager?
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
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1395
Location: Fayetteville, NC, USA

PostPosted: Fri Feb 12, 2016 2:24 pm    Post subject: Static IP with NetworkManager? Reply with quote

How the heck do you set a static IP for a system using NetworkManager? I am stumped here and have wasted an hour trying. I need NM for VPN and such, so the service has to start, but how do I tell it to assign a static address to my system on boot? I should have had this system up before 0900 and I am starting to pull out what little hair I have left!
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
nlsa8z6zoz7lyih3ap
Guru
Guru


Joined: 25 Sep 2007
Posts: 378
Location: Canada

PostPosted: Fri Feb 12, 2016 3:11 pm    Post subject: Reply with quote

Instead of using networkamanager, can you achieve your goal by assigning the desired address in your router to your PC's MAC address?

This is the approach that I use.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


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

PostPosted: Fri Feb 12, 2016 3:23 pm    Post subject: Reply with quote

Here is how I do it in KDE 4 using the plasma-nm GUI, but the process will be similar if you are using nm-applet (or, if you prefer, nmtui in a Terminal or Konsole window or in a VT):

1. Click on the plasma-nm icon on the Panel.
2. Click on the spanner icon to open the Connection Editor.
3. Click on 'Add' and create a new connection.
4. On the IPv4 tab:
4.1 For 'Method', select 'Manual'.
4.2 For 'DNS Servers', enter the nameserver's IP address (separated by commas if more than one nameserver).
4.3 Click on 'Add' and do the following:
4.3.1 Under 'Address' enter the static IP address of your machine.
4.3.2 Under 'Netmask' enter the netmask (e.g. I have 255.255.255.0).
4.3.3 Under 'Gateway' enter the gateway IP address.

The steps under 4 above will add some entries to the applicable NetworkManager connection file /etc/NetworkManager/system-connections/<connection> as shown below. If you want, you can create or edit the connection file directly without needing to use a NetworkManager front-end.

Code:
[connection]
id=<connection>
uuid=<uuid>
type=ethernet
autoconnect=false
permissions=user:<username>:;
secondaries=

[ethernet]
mac-address=<MAC address>
mac-address-blacklist=

[ipv4]
address1=<machine's static IP address>/24,<gateway IP address>
dns=<DNS Server 1 IP address>;<DNS Server 2 IP address>;<DNS Server 3 IP address>;
dns-search=
may-fail=false
method=manual

[ipv6]
dns-search=
method=ignore


Actually, the NetworkManager Text User Interface (nmtui) is quite a nice way of doing it in a Konsole or Terminal window, or even in a VT.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
The_Great_Sephiroth
Veteran
Veteran


Joined: 03 Oct 2014
Posts: 1395
Location: Fayetteville, NC, USA

PostPosted: Thu Feb 18, 2016 7:17 pm    Post subject: Reply with quote

It was me. I forgot to do "rc-update add net.enp0s25 default" so it would start. Sorry about that!
_________________
Ever picture systemd as what runs "The Borg"?
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


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

PostPosted: Thu Feb 18, 2016 7:36 pm    Post subject: Reply with quote

The_Great_Sephiroth wrote:
It was me. I forgot to do "rc-update add net.enp0s25 default" so it would start. Sorry about that!

If you're using NetworkManager, you should not be using netifrc as well:

Code:
clevow230ss fitzcarraldo # rc-update show -v | grep 'net\.'
         net.enp4s0f1 |                             
               net.lo |
clevow230ss fitzcarraldo # rc-update show -v | grep NetworkManager
       NetworkManager |      default


Gentoo Wiki - NetworkManager wrote:
OpenRC

Remove any existing network management services (if installed):

Code:
root #for service in $(rc-update show default | grep 'net\.' | awk '{ print $1 }'); do rc-update del $service default; done

Code:
root #rc-update del dhcpcd default

Start NetworkManager:
Code:
root #/etc/init.d/NetworkManager start

To start NetworkManager at boot time add it the default runlevel:
Code:
root #rc-update add NetworkManager default

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
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