/etc/default/ifplugd
. It is worth paying attention to the -d
option - the time between determining the disconnection of the data transfer medium (cable) and interface deconfiguration, perhaps, it makes sense to increase it, since it is very unpleasant when the connections are broken due to a randomly pulled out cable. The option -u
, on the contrary, can be set to a small value - raising the interface when a cable appears is almost never harmful.HOTPLUG_INTERFACES
in the configuration file), but in practice I could not get it to work, because it was done via udev. In total, I used three Wi-Fi adapters, one of them was connected as a PC Card (PCMCIA), the other via USB, and later a built-in MiniPCI plug-in appeared. Accordingly, in /etc/udev/rules.d/80-LOCAL-wlan-start.rules
rules were gradually added: # WLAN adapters SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", KERNEL=="wlan*", RUN+="/etc/network/wlan-up $env{INTERFACE}" SUBSYSTEM=="rfkill", ACTION=="change", ENV{RFKILL_STATE}=="1", ENV{RFKILL_NAME}=="phy0", ENV{RFKILL_TYPE}=="wlan", RUN+="/etc/network/wlan-up wlan2" SUBSYSTEM=="rfkill", ACTION=="change", ENV{RFKILL_STATE}=="0", ENV{RFKILL_NAME}=="phy0", ENV{RFKILL_TYPE}=="wlan", RUN+="/sbin/ifdown wlan2" SUBSYSTEM=="rfkill", ACTION=="change", ENV{RFKILL_STATE}=="2", ENV{RFKILL_NAME}=="phy0", ENV{RFKILL_TYPE}=="wlan", RUN+="/sbin/ifdown wlan2"
/etc/network/wlan-up
file: #!/bin/sh export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" if=$1 logger -s -t wlan "Bringing up $if" ifconfig $if up poweroff=$(iwconfig $if|grep Tx-Power=off|wc -l) if [ $poweroff -ne 0 ] ; then ifconfig $if down exit fi ifup --force $if 2>&1 | logger -s -t wlan
PATH
variable is necessary, since this variable is not set when invoking a script from udev, so many things start to work completely differently./etc/network/wlan-up
was originally a rather complicated bash script that searched for networks and attempted to log in, but was greatly simplified after I accidentally stumbled upon a guessnet package, which will be discussed below ./etc/network/interfaces
, such as logical interfaces and the mapping
keyword. Logical interfaces, as their name suggests, are nothing more than network configuration profiles, which can be applied when raising an interface like this: ifup eth0=home
. The mapping
keyword represents the ability to write a script that maps a physical interface to a logical one./etc/network/interfaces
is to add a ( stanza ) mapping
section for the corresponding interface: mapping eth1 script guessnet-ifupdown # map default: dhcp # map debug: true # map verbose: true map syslog: true
map
keyword acquires a new meaning: it is used to pass parameters to guessnet (you can read about the original meaning on the interfaces (5)
page or in the ifupdown documentation). But more about that later. iface no-link inet manual test missing-cable pre-up echo No link present. pre-up false iface dhcp inet dhcp iface eth-home inet dhcp post-up route del default 2>&1 >/dev/null || true post-up pon dsl-eth-vpn post-up ifup ipv6-vps pre-down ifdown ipv6-vps pre-down poff dsl-eth-vpn test peer address 192.168.1.1 mac 00:19:CB:48:02:2A source 192.168.1.5 iface eth-lab inet static address 192.168.23.238 netmask 255.255.255.224 gateway 192.168.23.225 test peer address 192.168.23.225
test
keyword is present in the settings of each of these logical interfaces. The very flexible architecture of the ifupdown program allows third-party programs (such as guessnet) to intercept their processing or just ignore them (although guessnet specifically works differently - it simply reassembles the file again). The word test
allows you to specify the condition by which a particular configuration will be selected.no-link
logical interface be created specifically so that guessnet does not attempt to run other tests in the absence of a cable.dhcp
configuration accepts all DHCP settings without replacing anything. It can be useful to set it as the default configuration - most networks still have at least some DHCP server, listening to which instructions you can at least get a basic set of settings.eth-lab
configuration is used on a network with a DHCP server that ignores requests from unfamiliar clients. Therefore, arping of the gateway on this network is done - such a request will work only if both nodes are in the same physical network segment.eth-home
configuration simultaneously uses the settings from the DHCP server, but additionally raises the IPv6 tunnel and also removes the IPv4 default gateway, effectively turning the machine into an IPv6-only node. Another feature: in order to gain access to the “other end” of the IPv6 tunnel, an ADSL connection is used, which is kindly provided by the Zyxel P-660 series modem. Modems of this brand have one interesting whim: they ignore anonymous ARP requests (namely, guessnet sends such messages by default). To avoid this, an address is registered explicitly, which is recorded in the field “source” of the packet. In addition, the modem's MAC address is explicitly specified here.test
keyword supports the wireless
option: iface wifi-MTS.BY inet dhcp test wireless essid MTS.BY wireless-essid MTS.BY wireless-key off
map !no-link
in the mapping
for the Wi-Fi interface.guessnet(8)
page guessnet(8)
. Also, the package is attached a good documentation with examples of use. In principle, nothing prevents the use of guessnet in other distributions - there is a mode of operation “untethered” from the Debian-specific ifupdown package./etc/resolv.conf
once every half a minute. The solution to this problem can be the following script (for dhclient3): case $reason in RENEW) make_resolv_conf () { true } ;; *) return ;; esac
/etc/dhcp3/dhclient-enter-hooks.d
in /etc/dhcp3/dhclient-enter-hooks.d
under any name.Source: https://habr.com/ru/post/121216/
All Articles