On Sun, Mar 27, 2011 at 07:01:28PM -0600, Don Raboud wrote:
Hi all,
Shortened question:
Is there a way to force Network Manager to autoconnect using a fixed IP address? There is a conection present called "Auto eth0" which takes precedence over my defined connection "Fixed IP".
I had the same problem some time ago (it was with opensuse 11.1) and I didn't find any solution already available. Therefore I created my own. Step one: create the executable script /etc/NetworkManager/dispatcher.d/ipalias with this content ------------------------------------------------------------------- #!/bin/bash MACROUTER=( 00:11:22:33:44:55 00:11:22:33:44:56 ) MYIP=65 if [[ $2 = up ]]; then IPROUTER=$(/sbin/ip addr show dev $1 | awk '$1=="inet"{print gensub(/\.[^.]*/,"",3,$2);exit}').1 [[ ${IPROUTER%.*.*} != 192.168 ]] && exit if ping -c 1 $IPROUTER >/dev/null ; then MAC=$(/sbin/arp -n | awk -v i=$IPROUTER '$1==i{print $3}') for ((a=0;a<${#MACROUTER[*]};a++)); do if [[ $MAC = ${MACROUTER[a]} ]]; then if ! /sbin/ip addr | grep -q "inet ${IPROUTER%.*}.${MYIP}/" ; then /sbin/ifconfig $1:1 ${IPROUTER%.*}.$MYIP fi break fi done fi fi ------------------------------------------------------------------- You need to put in the variable MACROUTER the mac adddress of your router. You can have more than one router. The script also assumes that the ip address of the router is 192.168.xx.1 The script works with wired or wireless connection. The first network interface that connects to your router get a second fixed ip address. Enable port forwarding to this fixed ip address. If you connect to another unknown router, the script does nothing. One problem that I have found with this solution is that from time to time the fixed ip address disappear. I never had enough time to investigate the cause, but I have implemented a workaround. I have created another executable script: /root/bin/check_network_alias with this content ------------------------------------------------------------------- #!/bin/bash [[ -x /etc/NetworkManager/dispatcher.d/ipalias ]] || return IF=( $(/sbin/ifconfig | awk '/^[[:alpha:]]/{print $1}') ) LIST=() for((a=0;a<${#IF[*]};a++)) ; do [[ ${IF[a]} != ${IF[a]/:} ]] && continue ! /sbin/ifconfig ${IF[a]} | grep -qF encap:Ethernet && continue LIST=( ${LIST[@]} ${IF[a]} ) done for((a=0;a<${#LIST[*]};a++)) ; do /sbin/ifconfig ${LIST[a]} | grep -qF 'inet addr:' && \ ! /sbin/ifconfig ${LIST[a]}:1 | grep -q 'inet addr:' && \ /etc/NetworkManager/dispatcher.d/ipalias ${LIST[a]} up done ------------------------------------------------------------------- and added this line in root's crontab: */10 * * * * /root/bin/check_network_alias With this setup I have a reliable fixed ip address using networkmanager. Last thing. This works with 11.3. Not tested yet with 11.4 Giacomo -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org