You are not logged in.

#1 2018-10-07 12:14:26

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

When ethernet plugged, not bringing the interface up.

Hello forum,

Usually I need to bring the ethernet connection up to allow the DHCP server for a new incoming request. So I do manually

$ sudo ip link set dev enp4s0 up && sudo ip addr add 192.168.12.1/24 dev enp4s0

In such way I get both party connected, because I need to do SSH login. Some time I need to change the login IP, because if plugging twice I'll get another IP.

What I wish to achieve is to get the script execute automatically by ifplugd. Therefore I wrote

$ cat /etc/ifplugd/ifplugd.action 
#!/bin/bash
ip addr add 192.168.12.1/24 dev enp4s0

But there's no good result

# systemctl status ifplugd@enp4s0
● ifplugd@enp4s0.service - Daemon which acts upon network cable insertion/removal
   Loaded: loaded (/usr/lib/systemd/system/ifplugd@.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2018-10-07 18:01:30 +08; 2h 11min ago
  Process: 12103 ExecStart=/usr/bin/ifplugd-daemon enp4s0 (code=exited, status=1/FAILURE)
 Main PID: 12106 (ifplugd)
    Tasks: 1 (limit: 4915)
   Memory: 1.9M
   CGroup: /system.slice/system-ifplugd.slice/ifplugd@enp4s0.service
           └─12106 /usr/bin/ifplugd -i enp4s0 -fwI -u0 -d10

ott 07 18:01:30 AsusG75 ifplugd(enp4s0)[12106]: client: RTNETLINK answers: File exists
ott 07 18:01:30 AsusG75 ifplugd(enp4s0)[12106]: Program execution failed, return value is 2.
ott 07 18:01:30 AsusG75 systemd[1]: Started Daemon which acts upon network cable insertion/removal.
ott 07 18:04:04 AsusG75 ifplugd(enp4s0)[12106]: Link beat lost.
ott 07 18:04:15 AsusG75 ifplugd(enp4s0)[12106]: Executing '/etc/ifplugd/ifplugd.action enp4s0 down'.
ott 07 18:04:15 AsusG75 ifplugd(enp4s0)[12106]: Program executed successfully.
ott 07 18:04:22 AsusG75 ifplugd(enp4s0)[12106]: Link beat detected.
ott 07 18:04:23 AsusG75 ifplugd(enp4s0)[12106]: Executing '/etc/ifplugd/ifplugd.action enp4s0 up'.
ott 07 18:04:23 AsusG75 ifplugd(enp4s0)[12106]: client: RTNETLINK answers: File exists
ott 07 18:04:23 AsusG75 ifplugd(enp4s0)[12106]: Program execution failed, return value is 2.

# ls -l /etc/ifplugd/ifplugd.action 
-rwxr--r-- 1 root root 51  7 ott 17.45 /etc/ifplugd/ifplugd.action

do it good first, it will be faster than do it twice the saint wink

Offline

Board footer

Powered by FluxBB