Archlinux netctl configure static IP address when network cable is unplugged

2

I have two servers with Archlinux.

Both of them are using static IP address with netctl. Both of them are accessed only with ssh (e.g. I have no keyboard and monitor).

Problem I facing is when server boot, if the network cable is unplugged, the IP address is not set up.

I tried with ExcludeAuto=no and with ForceConnect=yes, but no success.

I tried with ifplugd as well, but it does my server inaccessible so I did not test much.

I know I can probably do it with ip link or ifconfig directly, but I am looking for some more intelligent solution.

Configuration looks like this:

# /etc/netctl/lan1 

Description='A basic static ethernet connection'
Interface=enp1s0
Connection=ethernet
IP=static
Address=('192.168.0.3/24')
Gateway='192.168.0.1'
DNS=('8.8.8.8')

Nick

Posted 2017-05-30T05:58:29.677

Reputation: 463

can you include the configuration of the interfaces in /etc/network/interfaces – Jimmy_A – 2017-05-30T08:40:05.547

there is no such file. just /etc/netctl/lan1 – Nick – 2017-05-30T11:07:17.660

yeah, I was still thinking of Linux. Update your question with the configuration of your interface, there might be something missing – Jimmy_A – 2017-05-30T11:11:51.823

done, updated... – Nick – 2017-05-30T12:40:00.210

The configuration seems fine. You said you tried using ifplugd which would be able to solve your issue. Can you try restarting netctl with the interface down the first time and then up if that doesn't work? Also, maybe there is another network manager installed that conflicts with the configuration – Jimmy_A – 2017-05-30T13:12:03.657

Answers

2

I checked netctl source code and found I need to add following lines into netctl profile:

ForceConnect=yes
SkipNoCarrier=yes

e.g. full profile must be something like this:

# /etc/netctl/lan1 

Description='A basic static ethernet connection'
Interface=enp1s0
Connection=ethernet
IP=static
Address=('192.168.0.3/24')
Gateway='192.168.0.1'
DNS=('8.8.8.8')

ForceConnect=yes
SkipNoCarrier=yes

if you search google for SkipNoCarrier=yes, you can find it online, but it is still not well documented on Archlinux website.

Nick

Posted 2017-05-30T05:58:29.677

Reputation: 463