You are not logged in.

#1 2014-01-09 03:13:09

cadteach
Member
Registered: 2014-01-09
Posts: 1

Trying to switch from DHCP to static

I've just installed arch arm on a pogoplug, and set it up for network printing and scanning on a HP all in one.  It all works wonderfully.  I'm connnected thru a router on eth0 with dhcp currently set up.

I'd like to switch it now to a static IP address, so I've read about netctl and I created a profile, but I can't get eth0 down by either ifconfig eth0 down, ip link set eth0 down , or ip link set dev eth0 down.

It doesn't come down, and so I can't start using the new netctl profile. 

I don't remember what command I brought it up with, or what network control package I'm using, which would help.

Any idea what I can do to get this down?

Offline

#2 2014-01-09 03:16:44

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Trying to switch from DHCP to static

I'm not sure if you need netctl for this: https://wiki.archlinux.org/index.php/St … IP_address


Edit: 'ip link set eth0 down' run as root or with sudo should work.

Last edited by karol (2014-01-09 03:18:45)

Offline

#3 2014-01-09 12:11:55

iOfWhy
Member
Registered: 2012-05-16
Posts: 26

Re: Trying to switch from DHCP to static

netctl is the easiest way to do it.

cp /etc/netctl/examples/ethernet-static /etc/netctl/ethernet-static

then edit the copied file, make sure you have the right interface (use ip addr or link to find out correct name)

start with

netctl start ethernet-static

start at boot with:

netctl enable ethernet-static

Offline

#4 2014-01-09 17:35:22

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,238

Re: Trying to switch from DHCP to static

You can certainly use netctl but it is also perfectly possible and quite easy to use systemd to start the network with a static ip.  Basically you need to create two files as follows which I will put sample numbers in ( have used network device name enp0s25 but if yours is eth0 then you can use that instead):

First create a file /etc/systemd/system/network.service with the following (adapt the ip addresses, and network device name for your own situation, and you can change the filename used for the EnvironmentFile definition below):

[Unit]
Description=Network Connectivity (enp0s25)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-enp0s25.device
After=sys-subsystem-net-devices-enp0s25.device

[Service]
Type=oneshot
RemainAfterExit=yes

#
# Internal home network
#
EnvironmentFile=/etc/conf.d/network.static

ExecStart=/usr/bin/ip link set dev ${ifin} up
ExecStart=/usr/bin/ip addr add ${addrin}/${nmin} broadcast ${brdin} dev ${ifin}
ExecStart=/usr/bin/ip route add default via ${gwin}
#ExecStart=/usr/bin/ip addr add ${addr2in} dev ${ifin}
ExecStop=/usr/bin/ip addr flush dev ${ifin} 
ExecStop=/usr/bin/ip link set   dev ${ifin} down 

[Install]
WantedBy=multi-user.target

Then create a suitable file which is the EnvironmentFile named in this case /etc/conf.d/network.static referenced by the file above with the contents:

#
# Home Network
#
# device name
ifin=enp0s25 
# static address
addrin=10.0.0.10
# netmask 
nmin=24
# broadcast address
brdin=10.0.0.255 
# gateway
gwin=10.0.0.135

Then all you need to do is to set the current card down as in the previous posts

ip addr flush dev eth0
ip link set dev eth0 down

, and stop and disable the dhcpcd service with

systemctl stop dhcpcd
systemctl disable dhcpcd

  and

systemctl disable dhcpcd

, and then start the network service via systemd:

systemctl start network

and to make it come up at boot just do

systemctl enable network

I have this method tried and tested and it works fine - however I also note that you are running arch arm - so if this suggestion does not work you may need to ask the same question on the archlinuxarm forum rather than this mainstream forum for Arch.


Mike C

Offline

#5 2014-01-09 17:38:55

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: Trying to switch from DHCP to static

mcloaked wrote:

You can certainly use netctl but it is also perfectly possible and quite easy to use systemd to start the network with a static ip.

This methos is also documented in the wiki: https://wiki.archlinux.org/index.php/Ne … ng_systemd

Last edited by 2ManyDogs (2014-01-09 17:41:35)

Offline

#6 2014-01-09 20:00:09

mcloaked
Member
From: Yorkshire, UK
Registered: 2012-02-02
Posts: 1,238

Re: Trying to switch from DHCP to static

2ManyDogs wrote:
mcloaked wrote:

You can certainly use netctl but it is also perfectly possible and quite easy to use systemd to start the network with a static ip.

This methos is also documented in the wiki: https://wiki.archlinux.org/index.php/Ne … ng_systemd

Yes it is although it uses different variables such as %i - the use of variables is explained in the systemd documentation if you want to vary the method, and it is a very good idea to read the documention on systemd carefully to help getting the service files set up correctly.  http://www.freedesktop.org/software/sys … .unit.html


Mike C

Offline

Board footer

Powered by FluxBB