NetworkManager and static IP address
NetworkManager is very convenient tool for everyday networking needs – particularly laptop networking needs. It has some issues, though. One of the biggest is inability to define network profiles manually with static IP configuration, which – personally – I prefer to use when I am at home. Fortunately, there is a workaround.
Easiest way is to define static IP configuration for given device (i.e. eth1) in system-config-network tool. NetworkManager will automatically pick up these settings while connecting through that device next time. Simple as that! :) But there is even better news – static IP configuration is one of the features planned for 0.7 version of NetworkManager, so hopefully workarounds won’t be necessary anymore soon.
Related
- http://live.gnome.org/DarrenAlbers/NetworkManagerFAQ
- http://live.gnome.org/NetworkManager
- http://www.ces.clemson.edu/linux/nm.shtml
Lots of information on installing and using NetworkManager
December 12, 2006 at 10:52
Ran into the same problem, but had another curve-ball thrown at me: I have to wired networks I connect to, but I only need (want) to use a Static IP on one of them.
Fortunately this network has DHCP configured; just badly. Since it has DHCP, at least I should normally get something from the DHCP server that is marginal accuracy, in this case the Default Gateway.
Since I only want a static IP if I connect using the wired link, mys solution became fairly easy to implement: I used NetworkManagerDispatcher.
In the /etc/NetworkManager/dispatcher.d/ directory I dropped the following file:
So far it’s working very well for me.
Regards,
Eug??ne
December 12, 2006 at 10:59
Thanks for that solution! As the matter of fact, I’ve stopped using NetworkManager for a while, since it has serious problems with connecting to my wireless network. It just keeps asking for WEP key all the time, and maybe 1 time per 10 will connect at all. :( I didn’t have time to investigate it, so I switched into WiFi Radar, which used to work great on my previous machine, and works well now too. Only pain is to activate eth0 interface manually if I plug cable in. Well.
December 13, 2006 at 11:09
I had that… I just wish I could remember what I did to make it all go away.
As an update, an for anyone else who finds this page using Google like I did at first, I see I duffed the script I pasted in. Here’s the one I currently use directly from my Dispatcher file:
#!/bin/sh
#
# Check if we’re on the Office LAN
OFFICEGW=”10.121.20.1″;
STATICIP=”10.121.21.20″;
STATICNM=”255.255.252.0″;
STATICBC=”10.121.23.255″;
IF=$1
STATUS=$2
WHICHLAN=`/usr/bin/nm-tool| \
/usr/bin/awk ‘/Device: eth0/,/Device: eth1/’| \
/bin/grep -q “Gateway: *${OFFICEGW}” && echo “Office” || echo “Other”`;
if [ 'Office' == "${WHICHLAN}" and 'eth0' == "${IF}" and 'up' == "${STATUS}" ]; then
/sbin/ifconfig eth0 ${STATICIP} netmask ${STATICNM} broadcast ${STATICBC};
elif [ 'Office' == "${WHICHLAN}" and 'eth0' == "${IF}" and 'down' == "${STATUS}" ]; then
/sbin/ifconfig eth0 0.0.0.0;
fi;
I do think I need to investigate WiFi-Radar, though…
August 12, 2008 at 5:38
Can you please tell us the NAME of the file? You specified the directory and the contents but not the filename…