Skip to main content
Topic: static network configuration (Read 6248 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

static network configuration

I feel like I ask this question all the time, and I just don't seem to get it.

WIth ifconfig and route scripts out of fashion, how do I set up networking on boot for ethernet without using Network Manager

I am reading this and I'm doubting that these commands will work outside of systemd

https://wiki.archlinux.org/index.php/Network_configuration#Get_current_device_names

Re: static network configuration

Reply #1
I'm sure it will work. The command ip is provided by proute2 and is already available in artix repo

Code: [Select]
~ >>> which ip                                                                                                                                                          
/usr/bin/ip
~ >>> pacman -Qo /usr/bin/ip                                                                                                                                           
/usr/bin/ip is owned by iproute2 4.13.0-1
~ >>> pacman -Qi iproute2                                                                                                                                              
Name            : iproute2
Version         : 4.13.0-1
Description     : IP Routing Utilities
Architecture    : x86_64
URL             : http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
Licenses        : GPL2
Groups          : base
Provides        : iproute
Depends On      : glibc  iptables  libelf
Optional Deps   : linux-atm: ATM support
Required By     : dhclient  networkmanager  openvpn  vpnc
Optional For    : inxi
Conflicts With  : iproute
Replaces        : iproute
Installed Size  : 2004.00 KiB
Packager        : Artix Build Bot
Build Date      : Thu 07 Sep 2017 05:00:01 AM WITA
Install Date    : Tue 19 Sep 2017 07:03:52 PM WITA
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Edit :

You can still connect to internet in terminal using networkmanager with nm-tui
If I can hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate!

Re: static network configuration

Reply #2
I installed that and played with it.  Its not good at all.  I can see why I have been avoiding it.  A simple ifconfig output to see your current IP addresses is a huge production.  :(

[ruben@www3 ~]$ ip addr show
Code: [Select]
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp6s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:01:c0:16:d8:c6 brd ff:ff:ff:ff:ff:ff
3: wlp4s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether d2:f8:fb:b6:18:71 brd ff:ff:ff:ff:ff:ff
4: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:01:c0:1a:f9:c5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.55/24 brd 10.0.0.255 scope global dynamic enp0s25
       valid_lft 18612sec preferred_lft 18612sec
    inet6 fe80::6e63:95ae:4f2f:ccb8/64 scope link
       valid_lft forever preferred_lft forever

I hate these device names as well.  I don't want to memorize all these noncommunicable names with 7 digits.  I can use them as random password generators.

Re: static network configuration

Reply #3
I need to remove Network Manager.


Re: static network configuration

Reply #5
I installed that and played with it.  Its not good at all.  I can see why I have been avoiding it.  A simple ifconfig output to see your current IP addresses is a huge production.  :(
[ruben@www3 ~]$ ip addr show
i dont think linux is really for you
>kinda kidding
are you saying ifconfig doesnt run for you, or that you would rather type "ifconfig" rather than "ip a s"?  there is a simple solution to both those "issues".
as for ip, it took me like 2 mins to set up an ethernet connection on an emergency restore after my nic driver stopped working and NM wasnt available.  all i had was the man page.

Re: static network configuration

Reply #6
a simple configuration for static ip with iproute2
 
Code: [Select]
ip link set enp6s0 up <-- bring up your interface
ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev enp6s0 <-- add an address to your interface
ip route add default via 192.168.1.1 <-- define the route address to find your router
i don't know if open-rc have rc.local file and if it have when it launched. Maybe you can start your network stuff with it putting the above command on it to start the network at boot time, or maybe create a service and enable it at boot time, i don't use open-rc,so ..... Obviously replace the address by the good one to suit your needs.
Hope this help
Obarun : free to control your system

Re: static network configuration

Reply #7
a simple configuration for static ip with iproute2
 
Code: [Select]
ip link set enp6s0 up <-- bring up your interface
ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev enp6s0 <-- add an address to your interface
ip route add default via 192.168.1.1 <-- define the route address to find your router
i don't know if open-rc have rc.local file and if it have when it launched. Maybe you can start your network stuff with it putting the above command on it to start the network at boot time, or maybe create a service and enable it at boot time, i don't use open-rc,so ..... Obviously replace the address by the good one to suit your needs.
Hope this help

Yes, I am going to wan to do something like this. 

I can set up an /etc/host file something like this:
127.0.0.1      localhost
127.0.0.1      localhost.mrbrklyn.com

# special IPv6 addresses
::1            localhost ipv6-localhost ipv6-loopback

fe00::0        ipv6-localnet

ff00::0        ipv6-mcastprefix
ff02::1        ipv6-allnodes
ff02::2        ipv6-allrouters
ff02::3        ipv6-allhosts
10.0.0.5        home.mrbrklyn.com home
96.57.23.82    www.mrbrklyn.com www

Not sure how the internals work here.  There is an /etc/networks on my suse server

loopback        127.0.0.0
#link-local    169.254.0.0
link-local      10.0.0.0

I used to load a simplified networking script in /etc/init.d/ and make the appropriate links in sysV nameology etc.

I let systemd take over this functionality and Manjaro seemed to do it in its configuration and I had a spare script to set up all the services I wanted that looked like this:

Code: [Select]
#/bin/sh

PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome2/bin:/opt/gnome/bin:/opt/kde3/bin:/opt/kde2/bin:/usr/openwin/bin:/usr/lib/java/bin:/opt/gnome/bin

export PATH

echo " Entered ROUTE.SH"
/sbin/route add -host 10.0.0.5 dev eth0
/sbin/route add -net 10.0.0.0 netmask 255.255.255.0 dev eth0
/sbin/route add default gw 96.57.23.82 dev eth1
/sbin/route add 10.0.0.0 gw 10.0.0.5 dev eth0
/usr/sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
/sbin/route -n

Services like named and apache were more detailed scripts with a snippet a bit like this:
Code: [Select]
case "$1" in
    start)
   echo -n "Starting name server BIND "
   if [ ! -e /etc/named.conf.include ]; then
       touch /etc/named.conf.include
   fi
   if [ ! -e /etc/named.d/forwarders.conf ]; then
      touch /etc/named.d/forwarders.conf
   fi

IP addresses are static in /etc/sysconfig/network/ifcfg-eth0
[ruben@www sysconfig]$ sudo cat ./network/ifcfg-eth0

Code: [Select]
BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IFPLUGD_PRIORITY='0'
IPADDR='10.0.0.5/24'
MTU=''
NAME='RTL8111/8168B PCI Express Gigabit Ethernet controller'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='ifplugd'
USERCONTROL='no'

How they were exactly triggered I'm not completely certain of.  But it has been increasingly removed from my control
and I'd like to reverse that trend.

Re: static network configuration

Reply #8
i dont think linux is really for you
>kinda kidding
are you saying ifconfig doesnt run for you, or that you would rather type "ifconfig" rather than "ip a s"?  there is a simple solution to both those "issues".
as for ip, it took me like 2 mins to set up an ethernet connection on an emergency restore after my nic driver stopped working and NM wasnt available.  all i had was the man page.
I'm a huge fan of ifconfig myself, plus I hate the output of ip. No need to pass judgement on people's preferences, even as kinda joke, please.

Re: static network configuration

Reply #9
Why do you not want to use NetworkManager?

Re: static network configuration

Reply #10
I've found that a default installation will have the dhcpcd service enabled.
Look to see if dhcpcd is listed when you execute
Code: [Select]
# rc-update show
(note as root)
My experience has been that dhcpcd can cause havoc trying to be helpful automagically configuring network interfaces. So if you have a configuration setup for a network IF on boot and it doesn't work...my suggestion is to make sure something else like dhcpcd isn't undermining your efforts.


Re: static network configuration

Reply #11
it should be set up in /etc/conf.d/net

??

Re: static network configuration

Reply #12
[www3 ~]# rc-update show
       NetworkManager |      default                          
          agetty.tty1 |      default                          
          agetty.tty2 |      default                          
          agetty.tty3 |      default                          
          agetty.tty4 |      default                          
          agetty.tty5 |      default                          
          agetty.tty6 |      default                          
               binfmt | boot                                  
            bluetooth |      default                          
             bootmisc | boot                                  
               cronie |      default                          
                 dbus |      default                          
                devfs |                                 sysinit
                dmesg |                                 sysinit
              elogind | boot                                  
                 fsck | boot                                  
             hostname | boot                                  
              hwclock | boot                                  
              keymaps | boot                                  
            killprocs |                        shutdown       
    kmod-static-nodes |                                 sysinit
                local |      default nonetwork                
           localmount | boot                                  
             loopback | boot                                  
              modules | boot                                  
             mount-ro |                        shutdown       
                 mtab | boot                                  
                named |      default                          
               net.lo | boot                                  
             netmount |      default                          
                 ntpd |      default                          
     opentmpfiles-dev |                                 sysinit
   opentmpfiles-setup | boot                                  
               procfs | boot                                  
                 root | boot                                  
            savecache |                        shutdown       
                 sshd |      default                          
                 swap | boot                                  
               sysctl | boot                                  
                sysfs |                                 sysinit
            syslog-ng |      default                          
         termencoding | boot                                  
                 udev |                                 sysinit
         udev-trigger |                                 sysinit
              urandom | boot                                  


it is the top one I want to remove

Re: static network configuration

Reply #13
I think this is the instructions to kill off Network Manager within the context of opernrc

https://wiki.gentoo.org/wiki/Netifrc#Static_address_.28CIDR_notation.29




[www3 home]# locate netifrc
/usr/lib/netifrc
/usr/lib/netifrc/net
/usr/lib/netifrc/sh
/usr/lib/netifrc/version
/usr/lib/netifrc/net/adsl.sh
/usr/lib/netifrc/net/apipa.sh
/usr/lib/netifrc/net/arping.sh
/usr/lib/netifrc/net/bonding.sh
/usr/lib/netifrc/net/br2684ctl.sh
/usr/lib/netifrc/net/bridge.sh
/usr/lib/netifrc/net/ccwgroup.sh
/usr/lib/netifrc/net/clip.sh
/usr/lib/netifrc/net/dhclient.sh
/usr/lib/netifrc/net/dhcpcd.sh
/usr/lib/netifrc/net/dummy.sh
/usr/lib/netifrc/net/ethtool.sh
/usr/lib/netifrc/net/firewalld.sh
/usr/lib/netifrc/net/hsr.sh
/usr/lib/netifrc/net/ifconfig.sh



 

Re: static network configuration

Reply #14
FWIW, to solve this you need to create links from /etc/init.d/net.lo to eth0 etc al, and then make chages to the config file
/etc/conf.d/net
[ruben@www3 init.d]$ grep -v "#" /etc/conf.d/net
config_eth0="96.57.23.83/29"
config_eth1="10.0.0.37/24"
routes_eth0="default via 96.57.23.81
10.0.0.0/24 via 10.0.0.5
96.57.23.80/29 via 96.57.23.81
dns_domain_eth0="mrbrklyn.com"
dns_servers_eth0="10.0.0.5 166.84.1.2"
dns_domain_eth1="mrbrklyn.com"
dns_servers_eth1="96.57.23.83  166.84.1.2"




The links look like this
total 388
drwxr-xr-x 68 root root  4096 Oct  7 18:31 ..
drwxr-xr-x  2 root root  4096 Oct  7 17:31 .
lrwxrwxrwx  1 root root    18 Oct  7 17:31 net.eth1 -> /etc/init.d/net.lo
lrwxrwxrwx  1 root root    18 Oct  7 17:31 net.eth0 -> /etc/init.d/net.lo