You are not logged in.

#1 2014-10-01 13:51:29

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

[Solved] trouble getting the right settings for a static IP

I'm not sure of how to best set my static IP connection in Arch.

In Manjaro/Ubuntu/etc. I use the Network Connections App and put in my IP, Subnet mask, Gateway and DNS. When I've tried to do it in the commandline to set up Arch, I get a "cannot make connection" error (or something of that sort) when I put in the gateway.

Relevant info for my connection (with XXX and YY standing in for numbers) - this is what I enter for Manjaro/Ubuntu (and what I attempted to use in the commandline to setup Arch - though I added the subnet mask /24 for the IP):

IP: XXX.YY.37.220
Mask: 255.255.255.0
Gateway: XXX.YY.31.1

The output of "ip route show" in a correctly configured/connecting instance of Manjaro on my system is:

default via XXX.YY.31.1 dev eno1 proto static
XXX.YY.31.1 dev eno1 proto static scope link
XXX.YY.37.0/24 dev eno1 proto kernel scope link src XXX.YY.37.220 metric 1

From the beginner's guide, it seems I should set up netctl?  I'm wondering what the right settings would be for this based on the above?

Last edited by emacsomancer (2014-12-15 15:22:16)

Offline

#2 2014-10-01 16:11:30

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 881

Re: [Solved] trouble getting the right settings for a static IP

I found the simplest way to set up things with Netctl is to use the netctl-auto/-ifconfigd settings.  Make your relevant configs in the /etc/netctl directory then start netctl-mathingy and go.  It's well-documented on the wiki on the netctl page.  Of course you're welcome to do something else as this is just my way of doing things with a static ip.

Good luck and have fun!  big_smile

Offline

#3 2014-10-01 16:19:37

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Solved] trouble getting the right settings for a static IP

I'd recommend systemd-networkd myself - I use it with both wired and wireless connections, no issues whatsoever.

If you want help with the issue you mentioned:

emacsomancer wrote:

When I've tried to do it in the commandline to set up Arch, I get a "cannot make connection" error (or something of that sort) when I put in the gateway.

you'll need to provide more details - specifically, the exact commands you entered, and the exact error response(s), not just "something of that sort".

Last edited by tomk (2014-10-01 16:29:47)

Offline

#4 2014-10-01 16:31:27

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 881

Re: [Solved] trouble getting the right settings for a static IP

tomk wrote:

I'd recommend systemd-networkd myself - I use it with both wired and wireless connections, no issues whatsoever.

In all honesty, were I not using my netctl-mathingy I'd use tomk's method too.  It is also pretty simple and easy to setup with minimal fuss.

Last edited by MoonSwan (2014-10-01 16:31:45)

Offline

#5 2014-10-02 16:42:49

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: [Solved] trouble getting the right settings for a static IP

netctl is pretty simple to set up, provided you were able to successfully set up a connection without netcfg. here's my /etc/netctl/enp3s0

Description='Static ethernet (192.168.0.0/24) with IPv6'
Interface=enp3s0
Connection=ethernet
IP=static
Address=('192.168.0.2/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.0.1'
DNS='127.0.0.1'
#DNS=('208.67.220.222' '208.67.222.220' '208.67.220.220' '208.67.222.222' '8.8.4.4' '8.8.8.8' '2620:0:ccc::2' '2620:0:ccd::2')

## For IPv6 autoconfiguration
IP6=stateless

## For IPv6 static address configuration
#IP6=static
#Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
#Routes6=('abcd::1234')
#Gateway6='1234:0:123::abcd'

## automation of scripts pre and post connect
ExecUpPost='/storage/Launchers/tSpeed || true'
ExecDownPre='/storage/Launchers/tSpeedReset || true'

Last edited by HiImTye (2014-10-02 16:43:45)

Offline

#6 2014-10-02 17:34:46

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

Re: [Solved] trouble getting the right settings for a static IP

Ok, I got connected via the commandline method - it was just my own stupid mistake in having written down the gateway IP wrong (with 31 rather than 37 [something the network manager gui seems to silently fix somehow]).

I have a slightly different problem - when I try to set up the systemd method described in the Arch wiki, I get the following error:

Error: an inet prefix is expected rather than "/".

The trouble seems to lie in the net-up.sh, but I don't understand where or why.

Offline

#7 2014-10-02 17:43:36

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 881

Re: [Solved] trouble getting the right settings for a static IP

Post the commands you used and their error messages here.  Without that we can't help you.  If possible also post any relevant config files here too, just as, for example, HilmTye did.  The more information we have the better equipped we are to help you out.

Offline

#8 2014-10-02 18:08:25

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

Re: [Solved] trouble getting the right settings for a static IP

FOllowing the Arch wiki's section on "Persistent configuration on boot using systemd":

I created config file:

/etc/conf.d/net-conf-eno1

address=XXX.YY.37.220
netmask=24
broadcast=XXX.YY.37.255
gateway=XXX.YY.37.1

and created /usr/local/bin/net-up.sh

#!/bin/bash
ip link set dev "$1" up
ip addr add ${address}/${netmask} broadcast ${broadcast} dev "$1"

[[ -z ${gateway} ]] || { 
  ip route add default via ${gateway}
}

and /usr/local/bin/net-down.sh

#!/bin/bash
ip addr flush dev "$1"
ip route flush dev "$1"
ip link set dev "$1" down

and /etc/systemd/system/network@eno1.service

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

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/net-conf-%i
ExecStart=/usr/local/bin/net-up.sh %i
ExecStop=/usr/local/bin/net-down.sh %i

[Install]
WantedBy=multi-user.target

when i try to execute systemctl enable network@eno1 it reports:

Error: an inet prefix is expected rather than "/".

I have narrowed this error down to the net-up.sh, as when I execute sudo ./net-up.sh eno1 it reports the same error as above.

Offline

#9 2014-10-02 18:16:26

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Solved] trouble getting the right settings for a static IP

I'm sure you coud get that to work, but IMO it's sloppy - using /usr/local, among other things.

You've verified that your hardware works by setting up a connection manually, so I'll again recommend that you use systemd-networkd, linked above.

Offline

#10 2014-10-02 20:02:41

emacsomancer
Member
Registered: 2014-09-20
Posts: 211

Re: [Solved] trouble getting the right settings for a static IP

tomk wrote:

I'm sure you coud get that to work, but IMO it's sloppy - using /usr/local, among other things.

You've verified that your hardware works by setting up a connection manually, so I'll again recommend that you use systemd-networkd, linked above.

Ok, I'll do so. I'm a bit confused about the language in the wiki page though, w.r.t. host and container.  If I'm trying to set up a connection to a static IP - do I only set up host, or only container, or something else?

Last edited by emacsomancer (2014-10-02 20:03:20)

Offline

#11 2014-10-02 20:56:18

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [Solved] trouble getting the right settings for a static IP

emacsomancer wrote:

I have narrowed this error down to the net-up.sh, as when I execute sudo ./net-up.sh eno1 it reports the same error as above.

FYI, you're getting the error because the script has no values for the named variables:

# echo $a $b $c

# ip addr add ${a}/${b} broadcast ${c} dev net1
Error: an inet prefix is expected rather than "/".

But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB