7

I just wanted to set up a static IP address for a fedora 19 machine in my LAN. I'm used to /etc/network/interfaces from debian but that file doesn't exist here.
After googling around a little bit, I found a small tutorial that tells one to disable NetworkManager via systemctl and enable network. After that one could configure the static IP address in a file called /etc/sysconfig/network-scripts/ifcfg-*interfacename*.

Here is my first problem: I found a file with the MAC address of my interface as displayed by ifconfig but the name after ifcfg- doesn't match the name from ifconfig. Why is that like this?

My second problem is about using NetworkManager.service or network.service. I read in a Forum, that network.service is still included for compatibility reasons and may be excluded soon. If network.service will soon be replaced by NetworkManager.service, shouldn't I choose NetworkManager.service to configure my network interfaces? If yes, how do I do that with NetworkManager from a shell?

Edit:
Here are the outputs requested:

[root@bitch /]# ifconfig
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 0  (Local Loopback)
        RX packets 97  bytes 12042 (11.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 97  bytes 12042 (11.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p3p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.11  netmask 255.255.255.0  broadcast 192.168.178.255
        inet6 fe80::214:85ff:febc:1c63  prefixlen 64  scopeid 0x20<link>
        ether 00:14:85:bc:1c:63  txqueuelen 1000  (Ethernet)
        RX packets 134347  bytes 169988336 (162.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 78199  bytes 6595669 (6.2 MiB)
        TX errors 0  dropped 0 overruns 1  carrier 0  collisions 0

[root@bitch /]# ls -l /etc/sysconfig/network-scripts/
total 200
-rw-r--r--. 1 root root   437 Sep 15 02:05 ifcfg-enp2s5
-rw-r--r--. 1 root root   254 May 31 09:49 ifcfg-lo
lrwxrwxrwx. 1 root root    24 Jun 27 19:12 ifdown -> ../../../usr/sbin/ifdown
-rwxr-xr-x. 1 root root   627 May 31 09:49 ifdown-bnep
-rwxr-xr-x. 1 root root  5553 May 31 09:49 ifdown-eth
-rwxr-xr-x. 1 root root   781 May 31 09:49 ifdown-ippp
-rwxr-xr-x. 1 root root  4141 May 31 09:49 ifdown-ipv6
lrwxrwxrwx. 1 root root    11 Jun 27 19:12 ifdown-isdn -> ifdown-ippp
-rwxr-xr-x. 1 root root  1642 May 31 09:49 ifdown-post
-rwxr-xr-x. 1 root root  1068 May 31 09:49 ifdown-ppp
-rwxr-xr-x. 1 root root   837 May 31 09:49 ifdown-routes
-rwxr-xr-x. 1 root root  1444 May 31 09:49 ifdown-sit
-rwxr-xr-x. 1 root root  1462 May 31 09:49 ifdown-tunnel
lrwxrwxrwx. 1 root root    22 Jun 27 19:12 ifup -> ../../../usr/sbin/ifup
-rwxr-xr-x. 1 root root 12445 May 31 09:49 ifup-aliases
-rwxr-xr-x. 1 root root   859 May 31 09:49 ifup-bnep
-rwxr-xr-x. 1 root root 10234 May 31 09:49 ifup-eth
-rwxr-xr-x. 1 root root 12033 May 31 09:49 ifup-ippp
-rwxr-xr-x. 1 root root 10437 May 31 09:49 ifup-ipv6
-rwxr-xr-x. 1 root root   804 May 31 09:49 ifup-ipx
lrwxrwxrwx. 1 root root     9 Jun 27 19:12 ifup-isdn -> ifup-ippp
-rwxr-xr-x. 1 root root   642 May 31 09:49 ifup-plip
-rwxr-xr-x. 1 root root  1043 May 31 09:49 ifup-plusb
-rwxr-xr-x. 1 root root  2609 May 31 09:49 ifup-post
-rwxr-xr-x. 1 root root  4154 May 31 09:49 ifup-ppp
-rwxr-xr-x. 1 root root  1925 May 31 09:49 ifup-routes
-rwxr-xr-x. 1 root root  3268 May 31 09:49 ifup-sit
-rwxr-xr-x. 1 root root  2607 May 31 09:49 ifup-tunnel
-rwxr-xr-x. 1 root root  3775 May 31 09:49 ifup-wireless
-rwxr-xr-x. 1 root root  4623 May 31 09:49 init.ipv6-global
-rw-r--r--. 1 root root 13836 May 31 09:49 network-functions
-rw-r--r--. 1 root root 26134 May 31 09:49 network-functions-ipv6

Content of /etc/sysconfig/network-scripts/ifcfg-enp2s5:

PEERROUTES="yes"
IPV6INIT="yes"
NAME="enp2s5"
IPV6_PEERDNS="yes"
DEFROUTE="yes"
UUID="7622e20e-3f2a-4b5c-83d8-f4f6e22ed7ec"
PEERDNS="yes"
IPV4_FAILURE_FATAL="no"
HWADDR="00:14:85:BC:1C:63"
BOOTPROTO="static"
IPV6_DEFROUTE="yes"
IPV6_AUTOCONF="yes"
IPV6_FAILURE_FATAL="no"
TYPE="Ethernet"
ONBOOT="yes"
IPV6_PEERROUTES="yes"
IPADDR=192.168.178.11
NETMASK=255.255.255.0
BROADCAST=192.168.178.255
NETWORK=192.168.178.0
GATEWAY=192.168.178.1

Grepping dmesg for udevd:

[root@bitch network-scripts]# dmesg | grep udevd
[    0.788381] systemd-udevd[97]: starting version 204
[    2.457296] systemd-udevd[322]: starting version 204
[    3.110272] systemd-udevd[329]: renamed network interface eth0 to p3p1
11
  • Can you please post the output of the folloring two commands 1) ls /etc/sysconfig/network-scripts 2) ifconfig Commented Sep 15, 2013 at 0:51
  • I know you said you wanted to do it from a command shell, but I posted an answer detailing how to do it with the graphical interface. If you post the output of the 2 commands I mentioned in the previous comment, I will revise my answer to help with doing it via the command shell. Commented Sep 15, 2013 at 1:29
  • I will post them, just a sec.
    – wullxz
    Commented Sep 15, 2013 at 2:58
  • I feel like p3p1 is configured as an alias, and enp2s5 is the real name. What about the output from grep -e "NAME=\|HWADDR=" /etc/sysconfig/network-scripts/ifcfg-enp2s5? Is the value of NAME= equal to enp2s5 or p3p1? Commented Sep 15, 2013 at 5:27
  • The variable name might be DEVICE instead of NAME... Commented Sep 15, 2013 at 5:29

2 Answers 2

5

Command-Line Instructions

After much digging, I found that the ifcfg-* file names, and the NAME= variable in the file have very little to do with the actual assignment. You can literally change them to whatever you want... I did a test on my machine changing them to eth0 and the manual/static IP was still applied upon startup. The key here seems to the be HWADDR variable inside the file. The NAME= value only seems to be the name displayed in the graphical Network Manager settings. So, that being said I believe all you need to do is...

  1. Make sure NetworkManager.service is still enabled, and network.service is disabled.

  2. The most IMPORTANT step is to delete the current ifcfg-enp2s5 script.

    sudo rm /etc/sysconfig/network-scripts/ifcfg-enp2s5
    
  3. Create a new script named ifcfg-p3p1

    sudo nano /etc/sysconfig/network-scripts/ifcfg-p3p1
    
  4. Set the contents of ifcfg-p3p1 to the following, and update the respective IP settings with your desired settings.

    TYPE=Ethernet
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=p3p1
    UUID=7622e20e-3f2a-4b5c-83d8-f4f6e22ed7ec
    ONBOOT=yes
    DNS1=10.0.0.1
    IPADDR0=10.0.0.2
    PREFIX0=24
    GATEWAY0=10.0.0.1
    HWADDR=00:14:85:BC:1C:63
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes
    

As for why the ifcfg-* name was different from the actual device name. I don't know but suspect it has something to do with how the Network settings were applied during installation.

Graphical Instructions

  1. Open System Settings
  2. Click on Network
  3. Click on Options...
  4. Click on the IPv4 Settings* or IPv6 Settings tab depending on what IP version your home network is using (most likely IPv4).
  5. Click on the Method combo-box and select the Manual option.
  6. Click on the Add button.
  7. Type the address you want in the Address columns (e.g. 10.0.0.20).
  8. Type the netmask for your network in the Netmask column (e.g. 255.255.255.0).
  9. Enter the gateway (usually your router's IP) in the Gateway column (e.g. 10.0.0.1)
  10. Enter your DNS server in the DNS servers text-box (e.g. 10.0.0.1)

    Wired Connection Options Dialog

  11. Click on Save...
  12. When you return to the Network settings, turn the Wired interface OFF.
  13. It should automatically turn back on with the static address information you entered in the previous steps. If it does not turn on, click the toggle switch to turn it on.

    Network Settings After Manual IP Selection


To answer your question about using the NetworkManager.service over network.service. There is definitely potential it could be removed in later releases. As a general rule of thumb though, no matter the topic is, you should always try to avoid using anything "included for backwards compatibility". So, you should stick to using NetworkManager if you can.

4
  • because I control this machine over SSH. GUI stuff is no solution. That's why I wanted a solution to configure NetworkManager on a shell and I'm also wondering why the network service should be replaced despite it's easy configurable from the shell.
    – wullxz
    Commented Sep 15, 2013 at 2:58
  • And for your rule of thumb: That's why I ask about using one of these two, but I need to use a shell-based solution. Linux is often used as server OS. There has to be something to use from the shell, right?
    – wullxz
    Commented Sep 15, 2013 at 3:03
  • NetworkManager is part of the GNOME project, and I believe this was their doing, but I can't find anything to back it up. If you don't know already, GNOME is doing some crazy stuff. Commented Sep 15, 2013 at 5:13
  • I deleted ifcfg-eth* files from /etc/sysconfig/network and Network Manager began to work as it should!
    – Paul
    Commented Oct 6, 2016 at 12:30
1

I don't use Fedora, but according to this post, the file you are looking for should be /etc/sysconfig/network-scripts/ifcfg-p3p1 which should look something like this:

DEVICE=eth0
BOOTPROTO=none
HWADDR=00:13:20:5E:C0:47
ONBOOT=yes
DHCP_HOSTNAME=balthasar.benhome.com
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=no
IPADDR=172.16.3.3
NETMASK=255.255.255.192
GATEWAY=172.16.3.1

Setting up the IP there should work.

8
  • Nope, it doesn't. I read somewhere, that one should simply create a ifcfg-interfacename, restart network.service and edit the properties. But when I created an empty ifcfg-p3p1, network.service wouldn't start again. It is definitely enp2s5 where p3p1 is configured (the static IP address I configured there was applied to my network interface).
    – wullxz
    Commented Sep 15, 2013 at 7:20
  • @wullxz yes it looks like it is enp2s5 but you had not posted the contents of that file before. Try adding NM_CONTROLLED=no to it which tells the interface it is not controlled by networkmanager.
    – terdon
    Commented Sep 15, 2013 at 14:53
  • how do I control it then, if NetworkManager doesn't? It has to come up automatically on reboot.
    – wullxz
    Commented Sep 15, 2013 at 19:16
  • @wullxz no idea really, that's why that was just a comment. You might consider flagging this for migration to Unix & Linux you might have better chances there.
    – terdon
    Commented Sep 15, 2013 at 19:33
  • 1
    @wullxz You've asked this (good) question less than a day ago. It's got good responses so far, and we generally don't like to migrate questions away unless they've been sitting here without much attention or hope of getting answered for a day or two. I suggest you flag it again in a day or so if it's not resolved – just say I told you to. Thanks for your understanding.
    – slhck
    Commented Sep 15, 2013 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .