Fedora 17: Setting a static IP address


This is a quick tutorial on how to set a static IP address using the command line within Fedora 17.

note: these instructions also work in Fedora 18

 

 

First disable the gnome network manager from starting up

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

Now start the network service and set to run on boot

systemctl restart network.service
systemctl enable network.service

Check which interface(s) you want to set to static

[root@server ~]# ifconfig
em1: flags=4163 mtu 1500
inet 192.168.1.148 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::dad3:85ff:feae:dd4c prefixlen 64 scopeid 0x20 ether d8:d3:85:ae:dd:4c txqueuelen 1000 (Ethernet)
RX packets 929 bytes 90374 (88.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1010 bytes 130252 (127.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19

lo: flags=73mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 0 (Local Loopback)
RX packets 32 bytes 3210 (3.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 3210 (3.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Now you will need to edit the config file for that interface

vi /etc/sysconfig/network-scripts/ifcfg-em1

Edit the config to look like so. You will need to change BOOTPROTO from dhcp to static and add IPADDR, NETMASK, BROADCAST and NETWORK variables. Also make sure ONBOOT is set to yes.

UUID="e88f1292-1f87-4576-97aa-bb8b2be34bd3"
NM_CONTROLLED="yes"
HWADDR="D8:D3:85:AE:DD:4C"
BOOTPROTO="static"
DEVICE="em1"
ONBOOT="yes"
IPADDR=192.168.1.2
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
GATEWAY=192.168.1.1

Now to apply the settings restart the network service

systemctl restart network.service


35 thoughts on “Fedora 17: Setting a static IP address

  1. Hi Daniel,

    I managed to set my Fedora 17 to a static IP following the above post.
    Firefox does not connect to the internet though. Can you help me resolve that?

    Thanks,
    Arun

    • It could be your proxy settings in Firefox. Make sure they are set to auto detect. Also check your details are correct like your default gateway. Try to ping google.com and 8.8.8.8 to check that DNS is working and the internet is general. Hope this helps

      • Hi Daniel,

        I have the same problem too..firefox doesn´t connect to the internet anymore. Do you know where to change the proxy settings on firefox? I tried to find Tool/options on the defaul version but i couldn´t find it so i update my version on the terminal but i still don´t know where to chenge them.

        Do you have any suggestion?

        Thanks,
        Fabry

        • Tools>Options>Advanced>Network>Connection>Settings…

          Try ‘Auto-detect proxy settings’ for this network.

          Also try chrome. I have personally found Firefox to not work very well on Linux in general

          • This is nonsense. I am a programmer and I can tell you Firefox has nothing the hell to do with this problem . lol Try to give advices that are based on something more critical please. Firefox is one of the best internet flyer we got.

          • @Godfroy. I’m glad you programming skills somehow make you qualified to say my free advise is useless. If I need advise on C#, Java, php etc then i’m guessing your the person to ask. However I am a Linux and Windows Systems Engineer and work/configure this software to work on various size networks.

            Firstly if you have a better way please reply with a useful suggestion. Where I work we used to have several gateways and regularly had to change proxy’s in Firefox. Firefox manages its own proxy’s and doesn’t always use the one set by the system unlike chrome which uses the systems only. So its worth checking these settings to make sure ‘Auto detect’ is selected. If this fails I believe you can try ‘none’. Different networks may require different proxy settings.

            Yeah Firefox is great I have been using it since version 1.0. However i’m my personal experience using it on Ubuntu & Centos I have found chrome to perform better and crashes less than firefox.

            I cannot guarantee that my advise is always accurate or that it will work in an individuals circumstances but it might help.

          • hi Daniel,

            I am having the same problem and nothing you suggested worked. What I did was disable the network service and enabled the genome but now I am back where I started. I am a super noob at this but I was able to follow your instructions.

            My question is why must we disable the genome?

            And can we change the IPADDR, NETMASK, BROADCAST and NETWORK variables to what ever we want?

            Thanks,
            andrew

          • Hello Andrew,

            I think you are referring to the network settings withing Gnome 3. You can set a static IP address via the GUI interface in Gnome and set a static address.

            This tutorial is more useful for someone who wants to use Fedora as a server or having issues with Gnome. If you are using Fedora as a desktop then sticking with the Gnome network manager may be a better choice for you

  2. I need Network Manager to remain in control AND I need the static IP address. When I disable Network Manager critical files are deleted by systemctl with rm commands and the network interface dies all together. Presumably because configuration files elsewhere on the system go poof.

    I modify the /etc/sysconfig/network-scripts/ifcfg-em1 file from a script and it works great. However, prior to making those changes the script makes a backup copy of the original ifcfg-em1 file called ifcfg-em1_old_at_TIMESTAMP_RANDOM_NUMBER. Network manager does an “ET Phone Home” on that newly created backup file and uses that instead of the file called ifcfg-em1. How weird is that??

    Somewhere, the system is tracking that copy and identifies with it. I’ve got my hunting rifle out looking for that beastie….. No success as yet getting all this to run unattended from a script. For the record I’m loading the base system from a live media install CD reference platform 3.3.4-5.fc17.i686 and then running my script against that. During the CD install all the default options are taken with the objective of all subsequent modifications are performed by the script.

    Network manager is giving me fits.

    • I think the issue you have with the network-scripts/em1 is that you are backing up the file in to the network-scripts directory. I think that the system will read all the files in that directory including your backup file. This maybe causing some confusion for the system. Try backing up the file else where.

      I cant say I had the same issue when disabling NetworkManager. I simply turned off NetworkManager and enabled network make the modifications to the interface file and that’s it :-) .

      I would expect to loose connectivity while you are making these changes so if you are not sitting in front of the server/PC or have it on a VM you might have issues.

      Hope this helps :-)

  3. Daniel, I just discovered that the Live Install disc is imbedding network information into the LVM during install. Eeerrgh… moving to look at Fedora core and if that doesn’t work – I’ll have to spin my own distro.

    • I don’t quite understand what you mean. As LVM its only a logical volume for a partition to sit on allowing you to get one partition across multiple disks and has nothign to do with network interfaces

  4. How do you setup this file to work with or without IPv6, and both with IPv4, cause in my case the /etc/sysconfig/network-scripts/ifcfg-eth0 contain only IPv6 informations?

  5. Ok I’ve already found the info for configuring both IPv6 & IPv4 :
    in file : /etc/sysconfig/network
    Add or append following line:
    NETWORKING_IPV6=yes

    In file /etc/sysconfig/network-scripts/ifcfg-eth0
    #***** For IPv6 Configuration ******
    IPV6INIT=yes
    IPV6ADDR=1402:f0c0:1002:0011:0000:0000:0000:0002
    IPV6_DEFAULTGW=1402:f0c0:1002:0011:0000:0000:0000:0001
    #****** For IPv4 Configuration ******
    IPADDR=192.168.1.2
    NETMASK=255.255.255.0
    BROADCAST=192.168.1.255
    NETWORK=192.168.1.0
    GATEWAY=192.168.1.1

  6. Pingback: GuruPlug Server Fedora Remix Penetration Testing: 0.3 Release « Kowrinanthan Dayalingam

  7. Pingback: Impostare un IP statico su Fedora 17 | ZoiLab

  8. I followed this tutorial on fedora 18 with some minor changes

    After disabling networkmanager

    systemctl stop NetworkManager.service
    systemctl disable NetworkManager.service

    then I copied in my case ifcfg-em1 (old p4 system)
    to a backup and made the changes you described.

    /etc/sysconfig/network-scripts/ifcfg-em1

    then I restarted NetworkManager

    systemctl enable NetworkManager.service
    systemctl start NetworkManager.service

    I think this line takes care of networkmanager
    NM_CONTROLLED=”yes”

    I tried NM_CONTROLLED=”no” along with the commands for
    the old network method but that did not work for me.

    • For F18 stopping the network manager with :-
      systemctl stop NetworkManager.service

      followed by your original changes to ‘/etc/sysconfig/network-scripts/ifcfg-em1′, this time for 192.168.0.x network in my case :-

      IPADDR=192.168.0.128
      NETMASK=255.255.255.0
      BROADCAST=192.168.0.255
      NETWORK=192.168.0.0
      GATEWAY=192.168.0.1

      and adding

      NM_CONTROLLED=”yes”

      as suggested in previous post.

      then restarting the network manager :-

      systemctl start NetworkManager.service

      Does the trick nicely.

      Wish they would not keep changing things ….

      • and in ‘/etc/sysconfig/network-scripts/ifcfg-em1′ :-

        DNS1=8.8.8.8
        DNS2=4.4.4.4

        BTW Your Ethernet interface may not be ‘em1′ so do a ‘ifconfig’ command and check the name of your Ethernet device.

  9. Can any one help me please.
    I have server with CentOs installed/
    I have two Lan Cards in it. one is given local Ip ad 192.168.1.201
    Other Lan card is given Live static IP like 203.130.16.214
    Local IP is working fine on LAN. Live ip is pinging over the internet?

    Kindly help me?? what should is need to do?

        • it is working fine on a Windows server installed system. but when i installed two lan cards in linux system i am unable to access my system.
          I assigned this live ip to Lan interface eth1.

          • All I can gather so far is that you have assigned a static Internet IP to eth1 and an internal IP to eth0. Are you using the CentOS server as an internet gateway? what are you trying to use to access the server? Is the server on a home broadband connection or is it a dedicated server on the Internet? You have not really told me what the problem really is apart from its not working. Remember I do not know anything about your setup. Any infomation to tell us how you have this setup is useful

  10. I am using Fedora 17 via VMware player. The host OS uses a proxy server to connect to internet. what are the settings required in the virtual fedora OS so as to enable the internet connection?

    • At a guess I would make sure that the VM network adapter is set to bridged mode and then configure the proxy settings exactly the same on the VM as it is on the PC. I personalty do not know much about how to setup proxys in fedora. Hope this helps.

Leave a Reply