[opensuse-kde] Network Manager - how to control automatic connection?
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". Under Manage Connections there is no "Auto eth0" listed, so it appears to be built in and I can't change anything about it. Under my defined connection "Fixed IP" "Connect automatically" is checked but that hasn't helped. (There is also a greyed-out unchecked box "System connection".) This problem was discussed on the opensuse forums several months back, but no real resolution was found <http://forums.opensuse.org/english/get-technical-help-here/network- internet/450420-can-set-connection-network-manager.html> Background: I use port forwarding in my router, which was supplied by my ISP, to allow SSH access from the internet to my local machine. I have to specify a destination IP address in the router. This works as long as my machine maintains a fixed (local) IP address which I've chosen to be 192.168.1.65 [1]. Using network manager (plasmoid-networkmanagement) I have configured my wired connection to use this fixed IP address [2]. The problem is that there is an "Auto eth0" connection as well which takes precedence whenever a new connection needs to be made automatically [3]. The result is usually a different IP address, and hence I lose the ability to access my machine from outside the network [4]. Notes: [1] Unfortunately the router lacks the ability to assign a fixed IP address to a given mac address. [2] I could use the traditional ifup/ifdown approach but network manager makes it convenient to use VPN connections. [3] The router is both wired/wireless and SWMBO has a laptop which occassionally can't connect to the wireless network. She has learned that the easiest solution is to cylce on/off the router which then allows her to connect. [4] I suppose I could enable access to my router configuration from the internet, using a strong password, and then I could see which addresses have been assigned and configure the port-forwarding that way. That just seems like a far less secure option. -- Don -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Mon, 28 Mar 2011 03:01, Don Raboud
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".
Under Manage Connections there is no "Auto eth0" listed, so it appears to be built in and I can't change anything about it. Under my defined connection "Fixed IP" "Connect automatically" is checked but that hasn't helped. (There is also a greyed-out unchecked box "System connection".)
This problem was discussed on the opensuse forums several months back, but no real resolution was found
<http://forums.opensuse.org/english/get-technical-help-here/network- internet/450420-can-set-connection-network-manager.html>
Background:
I use port forwarding in my router, which was supplied by my ISP, to allow SSH access from the internet to my local machine. I have to specify a destination IP address in the router. This works as long as my machine maintains a fixed (local) IP address which I've chosen to be 192.168.1.65 [1].
Using network manager (plasmoid-networkmanagement) I have configured my wired connection to use this fixed IP address [2].
The problem is that there is an "Auto eth0" connection as well which takes precedence whenever a new connection needs to be made automatically [3]. The result is usually a different IP address, and hence I lose the ability to access my machine from outside the network [4].
Notes: [1] Unfortunately the router lacks the ability to assign a fixed IP address to a given mac address.
[2] I could use the traditional ifup/ifdown approach but network manager makes it convenient to use VPN connections.
[3] The router is both wired/wireless and SWMBO has a laptop which occassionally can't connect to the wireless network. She has learned that the easiest solution is to cylce on/off the router which then allows her to connect.
[4] I suppose I could enable access to my router configuration from the internet, using a strong password, and then I could see which addresses have been assigned and configure the port-forwarding that way. That just seems like a far less secure option.
Here is what I do: - Open YaST2 as root (in kde it's in the Application->System menu, and asks for root password) - select "Network Devices" (below "Search" box) - in the section "Network Devices" (in the other pane than before) select "Network Settings" - a new window opens. select the register-card/tab "Global Options" - in section "Network Setup Method" select Traditional Method with ifup. - select register-card/tab "Overview", select your Card, click "Edit" below. - the window changes its content. select tab "General". - in section "Device Activation" either "At Boot Time" or "On Cable Connection" should be selected. - select tab "Address", below "Device Type" select "Statically assigned IP Address". - enter Your ip (192.168.1.65) in the field IP Address, your subnet (255.255.255.0 or 255.255.0.0) in the field "Subnet Mask", and the name of your computer in the field "Hostname". - at the lower edge of the window click "Next". the window content switches back. - now with just a few extra entries you can make your life easier. - select tab "Hostname/DNS", enter the ip of your router (192.168.1.1 ??) in the field "Name Server 1". - select tab "Routing" and enter your router ip in the field "Default Gateway" (maybe named "Default IPv4 Gateway"), and select your card (eth0) in the Device field. - at the lower edge of the window click "OK". - end YaST2, reboot your computer, check your config (e.g. with /sbin/ifconfig in the konsole/xterm) I hope this gives you some help. -- Yamaban, - who really dislikes the "Network Manager" behavior, - out. -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Monday, March 28, 2011 04:37:05 am Yamaban wrote:
On Mon, 28 Mar 2011 03:01, Don Raboud
wrote: 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".
Under Manage Connections there is no "Auto eth0" listed, so it appears to be built in and I can't change anything about it. Under my defined connection "Fixed IP" "Connect automatically" is checked but that hasn't helped. (There is also a greyed-out unchecked box "System connection".)
<snip>
Here is what I do:
<snip>
- in section "Network Setup Method" select Traditional Method with ifup.
<snip>
-- Yamaban, - who really dislikes the "Network Manager" behavior, - out.
8-) Thanks Yamaban for the detailed instructions! That would however leave me back at the traditional method (an option I was considering) but I am trying to get Network Manager to work predictably with respect to automagically assigned IP addresses. In the meantime, I think I have found a workaround. Network Manager calls dhcpclient when an automatic connection needs to be made. So I edited /etc/dhclient.conf by adding the following lines to the end of the default supplied file interface "eth0" { fixed-address 192.168.1.65; } so that dhclient will request this specific IP address. The router happily supplies it, so I now get the desired behavior. Hopefully nothing else gets messed up by this change, but as this is my home machine with one wired connection only, I don't think this will cause any problems. -- Don -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Mon, 28 Mar 2011 13:58, Don Raboud
On Monday, March 28, 2011 04:37:05 am Yamaban wrote:
On Mon, 28 Mar 2011 03:01, Don Raboud
wrote: 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".
Under Manage Connections there is no "Auto eth0" listed, so it appears to be built in and I can't change anything about it. Under my defined connection "Fixed IP" "Connect automatically" is checked but that hasn't helped. (There is also a greyed-out unchecked box "System connection".)
<snip>
- in section "Network Setup Method" select Traditional Method with ifup. <snip> -- Yamaban, - who really dislikes the "Network Manager" behavior, - out.
8-)
Thanks Yamaban for the detailed instructions! That would however leave me back at the traditional method (an option I was considering) but I am trying to get Network Manager to work predictably with respect to automagically assigned IP addresses.
In the meantime, I think I have found a workaround. Network Manager calls dhcpclient when an automatic connection needs to be made. So I edited /etc/dhclient.conf by adding the following lines to the end of the default supplied file
interface "eth0" { fixed-address 192.168.1.65; }
so that dhclient will request this specific IP address. The router happily supplies it, so I now get the desired behavior. Hopefully nothing else gets messed up by this change, but as this is my home machine with one wired connection only, I don't think this will cause any problems.
Wow! Never thougt of this in conjuction with Network Manager. For a "normal" Desktop with "just" one ip this should work for sure. (My setup is much more complex, three eth, one with two IPv4, one with six IPv4 and four IPv6, and one with zero IPv4 but eight IPv6, all with vlan config, a bit much for Network Manager. And then comes the routing. No fun at all the first time, but great when it works.) Cheers, and kudos to you, please be so nice and share your solution in the forum. -- Yamaban, out. -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Monday, March 28, 2011 06:28:33 am Yamaban wrote:
On Mon, 28 Mar 2011 13:58, Don Raboud
wrote: On Monday, March 28, 2011 04:37:05 am Yamaban wrote:
On Mon, 28 Mar 2011 03:01, Don Raboud
wrote: 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".
Under Manage Connections there is no "Auto eth0" listed, so it appears to be built in and I can't change anything about it. Under my defined connection "Fixed IP" "Connect automatically" is checked but that hasn't helped. (There is also a greyed-out unchecked box "System connection".)
<snip>
- in section "Network Setup Method" select Traditional Method with ifup.
<snip>
--
Yamaban, - who really dislikes the "Network Manager" behavior, - out.
8-)
Thanks Yamaban for the detailed instructions! That would however leave me back at the traditional method (an option I was considering) but I am trying to get Network Manager to work predictably with respect to automagically assigned IP addresses.
In the meantime, I think I have found a workaround. Network Manager calls dhcpclient when an automatic connection needs to be made. So I edited /etc/dhclient.conf by adding the following lines to the end of the default supplied file
interface "eth0" {
fixed-address 192.168.1.65;
}
so that dhclient will request this specific IP address. The router happily supplies it, so I now get the desired behavior. Hopefully nothing else gets messed up by this change, but as this is my home machine with one wired connection only, I don't think this will cause any problems.
Wow! Never thougt of this in conjuction with Network Manager. For a "normal" Desktop with "just" one ip this should work for sure.
(My setup is much more complex, three eth, one with two IPv4, one with six IPv4 and four IPv6, and one with zero IPv4 but eight IPv6, all with vlan config, a bit much for Network Manager. And then comes the routing. No fun at all the first time, but great when it works.)
Wow! I don't even want to know why it is like that...
Cheers, and kudos to you, please be so nice and share your solution in the forum.
Yamaban, I'll be happy to share it, when it finally works :-( I thought it was working. Before the change, "Fixed IP" -> consistently returned 192.168.1.65 "Auto eth0" -> *consistently* returned 192.168.1.64. I made the change stated above (and only that change), restarted the network, and both interfaces now *consistently* (about 5 attemps each) return 192.168.1.65. However, to be sure this was working as expected, I changed the dhconfig.conf file to request a different address (192.168.1.66 or 192.168.1.200) and followed the same steps and this time the change did not work - I still get 192.168.1.65 consistently from both interfaces, whnich is an improvement, but not predictable. From the logs, "Auto eth0" calls dhcpclient so I think this approach should work, but as I see three possible issues spring to mind: 1) dhcpclient and dhclient.conf cannot combine to request a fixed ip address. From my reading of the man page (admittedly late last night) it appears that this should be possible however. 2) I have the syntax wrong for dhclient.conf - this is a distinct possibility. I'll have to do more digging and testing as I've never played with this before. 3) My particular router won't honor such a request for a fixed IP address. I have no idea about this one. I'll report back anything I find out. If anyone else has any ideas I would appreciate the input. -- Don -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
On Monday, March 28, 2011 07:28:51 am Don Raboud wrote: < big snip >
I'll report back anything I find out.
I'll add comments to various bits below, pulled from both this message and others in the thread. I want to thank Giacomo for providing the correct method. On Monday, March 28, 2011 06:28:33 am Don Raboud wrote:
In the meantime, I think I have found a workaround. Network Manager calls dhcpclient when an automatic connection needs to be made. So I edited /etc/dhclient.conf by adding the following lines to the end of the default supplied file
interface "eth0" { fixed-address 192.168.1.65; }
so that dhclient will request this specific IP address.
The correct syntax should be alias { iterface "eth0"; fixed-address 192.168.1.65; option subnet-mask 255.255.255.0; } added to the end of /etc/dhclient.conf. This works from the command line (when Networkmanager is disabled), # /sbin/dhclient eth0 giving both address as expected. However, this does not work with NetworkManager. Only the automatic address is returned. Not sure why. On Monday, March 28, 2011 08:33:32 am Giacomo Comes wrote:
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
< snip> This works very well for me here. I note that the name of the script is unimportant. All scritps in /etc/NetworkManager/dispatcher.d seem to get called when an interface goes up or down. Some of these call other scripts in /etc/sysconfig/network/if-{*}.d/ so there may be other opportunity for hooking in for specific cases. One small comment about the script. I replaced /sbin/ifconfig $1:1 ${IPROUTER%.*}.$MYIP with /sbin/ip addr add ${IPROUTER%.*}.$MYIP/24 dev $1 since my understanding is that ifconfig is obsolete (but dying a long slow death) and ip should be used instead. Both seem to work here. Actually, in my simple case (one router, one wired connection), the following script is an (almost, see below) sufficient replacement for Giacomo's script: ------------------------------------------- #!/bin/bash [[ $1 = eth0 && $2 = up ]] && /sbin/ip addr add 192.168.1.65/24 dev eth0 ------------------------------------------
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.
< snip > I've found that later when a VPN connection is made the fixed address remains, but when the VPN connection is subsequently closed, NetworkManager gets rid of the fixed address. To workaround this, I changed the simple script above to ------------------------------------------- #!/bin/bash [[ $1 = eth0 && $2 = up ]] && /sbin/ip addr add 192.168.1.65/24 dev eth0 [[ $1 = tun0 && $2 = vpn-down ]] && /sbin/ip addr add 192.168.1.65/24 dev eth0 ------------------------------------------ This is a dumb script, but seems to work for my simple case. If there are problems there is still Giacomo's workaround, which I haven't tried yet. Again, big thanks to Giacomo for showing the way to fix this! -- Don -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
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
On Mon, 28 Mar 2011 16:33, Giacomo Comes
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 <snip> I have created another executable script: /root/bin/check_network_alias with this content <snip> 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
Bravo! Even better than the dhcpconfig hack. Now, not to rain into anyones parade, but: 1. why is there no detailed documentation of the whole "Network Manager"? - see for example the http protocol finely documented: when what is done, and how to handle errors and edge-cases - even /sbin/ip is better documented - the involvment of dhcp is never clearly documented - neither is /etc/NetworkManager/dispatcher* 2. without forthing your way through the whole source-code, a user will never find solutions for the actual edge-case the user has, by him/herself. Even Google doesn't help in most of this. 3. This is NOT an openSUSE specific problem. Other distros fight with this too. Never the less there is NO solution. 4. This is NOT an KDE / GNOME / XFCE specific problem, well may be on the front-end side. but the 'core' is not desktop bound. Sorry for the rant, but I'm not convinced that "Network Manager", as it is, could be called a better solution than "traditional" ifup/ifdown. To me it's a source of frustation for every non-standard situation. -- Yamaban, who feels cleansed after this rant, out. -- To unsubscribe, e-mail: opensuse-kde+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kde+help@opensuse.org
participants (3)
-
Don Raboud
-
Giacomo Comes
-
Yamaban