Fedora 17: Setting a static IP address

Fedora 17: Setting a static IP address

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

note: these instructions also work in Fedora 18.

Disable Network Manager

1. First stop and disable the gnome network manager from running on boot.

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

2. Now start and enable the network service to run on boot.

systemctl restart network.service
systemctl enable network.service

Set the Static Address

1. Check which interface(s) you want to set as static.

[[email protected] ~]# 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

2. Next edit the config file for the required interface.

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

3. Edit the config file to look similar to the following.

Change the BOOTPROTO from “dhcp” to “static”. Also adding IPADDR, NETMASK, BROADCAST and NETWORK variables and 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

Apply the Settings

Restart the network service to apply the settings.

systemctl restart network.service

Configure DNS

Make sure the correct DNS servers are configured to allow Fedora to resolve domains.

vi /etc/resolv.conf
nameserver 192.168.1.1
nameserver 8.8.8.8

Leave a Reply

49 Comments on "Fedora 17: Setting a static IP address"

Leave a Reply

Sort by:   newest | oldest | most voted
Arun
Guest

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

dgibbs
Guest

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

fab
Guest

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

Charles McGowen
Guest
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… Read more »
dgibbs
Guest
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… Read more »
Charles McGowen
Guest

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.

dgibbs
Guest

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

Elgger
Guest

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?

Elgger
Guest

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

Alex
Guest

Guys
Make sure to add DNS as well.

Greg Brown
Guest

Daniel, thank you for posting this how-to. It was just what I needed!

Good luck with your future endeavors,

Greg

Ana
Guest

I agree, quick and simple tutorial which did just what I needed. I use putty to connect to my vm and was tired of reconfiguring. I would like to second Greg’s sentiments. Thank you Daniel.

trackback

[…] address, even tho my router stated that it assigned an ip address to that MAC. Thus, I followed a post by Daniel Gibbs to set a static IP address to ensure that the GuruPlug will receive and IP address on […]

trackback

[…] è altro che la versione tradotta (con l’aggiunta di qualche considerazione) di un post di Daniel Gibbs, che ringrazio per […]

oystercatcher
Guest

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.

Aaron Gray
Guest

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 ….

Aaron Gray
Guest

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.

Faraz Ahmad
Guest

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?

masaji
Guest

Thank you very much, it’s very helpful 😉 now Linux it’s more complicated than in the first era…. 🙁

david
Guest

route add default gw router-ip-address

uday
Guest

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?

Jonathan
Guest
Hi Daniel, I used your tutorial with some slight modifications with initial success in Fedora 18 on a Panda Board. The ethernet was up and I was able to browse (only opened one web page). However, after a shutdown and restart, I had no ethernet. My changes to your tutorial were: used eth0 instead of em1, eth0 showed up initially in ifconfig. I did not use NM_CONTROLLED and UUID. I used BOOTPROTO=none. When I restarted, nothing showed up for eth0 in ifconfig. So I did systemctl enable NetworkManager.Service and systemctl start NetworkManager.service. The eth0 then showed up in ifconfig. So… Read more »
Satyajit Bhadange
Guest
I am getting this error..what to do ? [[email protected] user101]# systemctl restart network.service Job failed. See system journal and ‘systemctl status’ for details. [[email protected] user101]# systemctl status Too few arguments. [[email protected] user101]# systemctl status network.service network.service – LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network) Active: failed (Result: exit-code) since Wed, 19 Jun 2013 12:35:57 +0530; 57s ago Process: 2379 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE) CGroup: name=systemd:/system/network.service Jun 19 12:35:57 user101 network[2379]: [FAILED] Jun 19 12:35:57 user101 network[2379]: RTNETLINK answers: File exists Jun 19 12:35:57 user101 network[2379]: RTNETLINK answers: File exists Jun 19 12:35:57 user101 network[2379]: RTNETLINK answers: File exists Jun 19… Read more »
lioff
Guest

Same erro after disable network manager

subhashree
Guest

I need to configure lan from my PC to raspberry pi ..OS used in raspberry pi is fedora remix. i need to install the softwares from my PC to fedora remix. can u please say the exact command

trackback

[…] Fedora 17: Setting a static IP address […]

trackback

[…] Fedora 17: Setting a static IP address – Daniel … – 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. […]

trackback

[…] Fedora 17: Setting a static IP address – … – 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 … […]

trackback

[…] Fedora 17: Setting a static IP address – … – 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 … […]

trackback

[…] Fedora 17: Setting a static IP address – … – 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 … […]

trackback

[…] Fedora 17: Setting a static IP address – … – 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 … […]

trackback

[…] Fedora 17: Setting a static IP address – danielgibbs.co.uk – This is a quick tutorial on how to set a static IP address using the terminal within Fedora 17. note: these instructions also work in Fedora 18. […]

trackback

[…] Fedora 17: Setting a static IP address – danielgibbs.co.uk – This is a quick tutorial on how to set a static IP address using the terminal within Fedora 17. note: these instructions also work in Fedora 18. […]

trackback

[…] there are ways to assign a static IP to your computer, for example see here, but there are some problems that needs to be worked out afterwards, e.g. disconnecting from […]

wpDiscuz