Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to bonding network withOUT systemd-networkd[SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
christophe_y2k
n00b
n00b


Joined: 07 Jan 2008
Posts: 41
Location: EUROPE-FRANCE-MANDELIEU

PostPosted: Sun Aug 16, 2015 3:48 pm    Post subject: How to bonding network withOUT systemd-networkd[SOLVED] Reply with quote

V1.0 - 08-16-2015 - 17h45 GMT +1
V1.1 - 08-16-2015 - 20h28 GMT +1

Hi all !!!
Have 3 network cards, one for the wan and 2 other for my lan and i wan't to bond them...
and one wlan usb(internal usb combo wifi & bluetooth) not used...
easy without systemd but with systemd haaaaaaaargrgrgrg ....

# ls /sys/class/net
eno1 enp3s0 enp8s0 lo sit0 wlp0s20u5

enp3s0 (pci card) for the WAN connected to my vdsl router box.
configured with static ip

enp8s0 and eno1 (integrated pcie network card) i wan't to bond them for my LAN for greater throughput.
configured with static ip and dhcp server
connected to one standard switch

# nano /etc/systemd/network/10-static.network
Code:
[Match]
Name=enp3s0

[Network]
DNS=8.8.8.8

[Address]
Address=192.168.253.5/24

[Route]
Gateway=192.168.253.254


# systemctl enable systemd-networkd.service
# systemctl start systemd-networkd.service
# systemctl status -l systemd-networkd.service
--> août 14 20:29:52 cassiopee systemd-networkd[1896]: enp3s0 : link configured
--> août 14 20:29:55 cassiopee systemd-networkd[1896]: enp3s0 : gained carrier

# cp /etc/resolv.conf /etc/resolv.conf.old
# systemctl enable systemd-resolved.service
# systemctl start systemd-resolved.service

# rm /etc/resolv.conf

For compatibility with resolv.conf, delete or rename the existing file and create the following symbolic link:
# ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Additionally, in order to use the local DNS stub resolver of systemd-resolved
(and thus use LLMNR and DNS merging per interface),
replace dns with resolve in /etc/nsswitch.conf:

# nano /etc/nsswitch.conf
Code:
...
hosts: files resolve myhostname
...


# ping www.gentoo.org
PING www-bytemark-v4v6.gentoo.org (89.16.167.134) 56(84) bytes of data.
64 bytes from www.gentoo.org (89.16.167.134): icmp_seq=1 ttl=50 time=32.8 ms
64 bytes from www.gentoo.org (89.16.167.134): icmp_seq=2 ttl=50 time=33.1 ms

# networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 eno1 ether off unmanaged
3 enp8s0 ether off unmanaged
4 sit0 sit off unmanaged
5 enp3s0 ether routable configured
6 wlp0s20u5 wlan off unmanaged


Ok for the WAN card that good and that work...

Now adding bond...

# nano /etc/systemd/network/11-bond0.netdev
Code:
[NetDev]
Name=bond0
Kind=bond

[Bond]
Mode=balance-rr
MIIMonitorSec=100
UpDelaySec=1s
DownDelaySec=0s


# nano /etc/systemd/network/12-NetworkCardToBond.network
Code:
[Match]
Name=enp8s0 eno1
 
[Network]
Bond=bond0


# nano /etc/systemd/network/13-bond0.network
Code:
[Match]
Name=bond0

[Network]
DNS=8.8.8.8
IPForward=ipv4
IPMasquerade=yes

[Address]
Address=192.168.0.1/22

[Route]
Gateway=192.168.0.1


# systemctl enable systemd-networkd
# systemctl start systemd-networkd
or
# systemctl restart systemd-networkd
# systemctl status -l systemd-networkd

systemd-networkd.service - Network Service
Loaded: loaded (/usr/lib64/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
Active: active (running) since dim. 2015-08-16 17:22:45 CEST; 6s ago
Docs: man:systemd-networkd.service(8)
Main PID: 26446 (systemd-network)
Status: "Processing requests..."
CGroup: /system.slice/systemd-networkd.service
└─26446 /usr/lib/systemd/systemd-networkd

août 16 17:22:45 cassiopee systemd-networkd[26446]: bond0 : netdev ready
août 16 17:22:45 cassiopee systemd[1]: Started Network Service.
août 16 17:22:45 cassiopee systemd-networkd[26446]: bond0 : link configured
août 16 17:22:45 cassiopee systemd-networkd[26446]: enp3s0 : link configured

# ifconfig
bond0: flags=5123<UP,BROADCAST,MASTER,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.252.0 broadcast 192.168.3.255
ether ea:19:dd:94:66:6c txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.253.5 netmask 255.255.255.0 broadcast 192.168.253.255
inet6 fe80::218:4dff:fee9:c6b9 prefixlen 64 scopeid 0x20<link>
ether 00:18:4d:e9:c6:b9 txqueuelen 1000 (Ethernet)
RX packets 94031193 bytes 88576129971 (82.4 GiB)
RX errors 0 dropped 47 overruns 0 frame 0
TX packets 40532634 bytes 30924659314 (28.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Boucle locale)
RX packets 20895 bytes 114749761 (109.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20895 bytes 114749761 (109.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

# networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 eno1 ether off unmanaged
3 enp8s0 ether off unmanaged
4 sit0 sit off unmanaged
5 enp3s0 ether routable configured
6 wlp0s20u5 wlan off unmanaged
7 bond0 ether no-carrier configured

7 links listed.


And effectively No-carrier on the bond0 and no link led on my switch for those card !!!!

# systemctl status -l systemd-resolved.service
● systemd-resolved.service - Network Name Resolution
Loaded: loaded (/usr/lib64/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
Active: active (running) since sam. 2015-08-15 19:57:29 CEST; 21h ago
Docs: man:systemd-resolved.service(8)
Main PID: 8035 (systemd-resolve)
Status: "Processing requests..."
CGroup: /system.slice/systemd-resolved.service
└─8035 /usr/lib/systemd/systemd-resolved

août 15 23:23:00 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.
août 15 23:23:00 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface bond0.
août 15 23:23:51 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.
août 16 15:26:57 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.
août 16 15:26:57 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface bond0.
août 16 15:33:50 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.
août 16 15:33:50 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface bond0.
août 16 16:58:15 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.
août 16 17:24:27 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface bond0.
août 16 17:24:27 cassiopee systemd-resolved[8035]: Switching to DNS server 8.8.8.8 for interface enp3s0.

# ping www.gentoo.org
PING www-bytemark-v4v6.gentoo.org (89.16.167.134) 56(84) bytes of data.
64 bytes from www.gentoo.org (89.16.167.134): icmp_seq=1 ttl=50 time=32.8 ms
64 bytes from www.gentoo.org (89.16.167.134): icmp_seq=2 ttl=50 time=33.0 ms

If anybody have an idea to setup bond under systemd ....
Thanks

i think bond do not work because systemd is too old and the current sys-apps/systemd-218-r3 do not handle bond ...

i need sys-apps/systemd-224-r1 but is masked


Last edited by christophe_y2k on Sun Sep 13, 2015 5:50 pm; edited 2 times in total
Back to top
View user's profile Send private message
gerdesj
l33t
l33t


Joined: 29 Sep 2005
Posts: 621
Location: Yeovil, Somerset, UK

PostPosted: Tue Aug 25, 2015 12:50 am    Post subject: Re: How to bonding network with systemd-networkd.service[FAI Reply with quote

You have given a lot of information 8)

According to this: https://github.com/systemd/systemd/blob/master/NEWS (line 280) version 220 of systemd is needed for bonding. I am currently running 224-r1 so I think you are using x86 or amd64 rather than ~x86 or ~amd64. A quick look at eix systemd shows that 218 is the current "stable".

You have two options: switch to ACCEPT_KEYWORDS="~amd64" in make.conf or just keyword systemd and its dependencies. If it helps, I run several Gentoo based systems (~50). Most of those are for my customers. Gentoo systems can get into a bit of a mess but never become unfixable. I have not used Gentoo in any other way for so long I do not know if it makes any real difference.

Monsieur, je recommande ACCEPT_KEYWORDS="~amd64" (/etc/portage/make.conf) et:

#emerge -uva --deep --newuse --keep-going @world

bon chance!!
Back to top
View user's profile Send private message
christophe_y2k
n00b
n00b


Joined: 07 Jan 2008
Posts: 41
Location: EUROPE-FRANCE-MANDELIEU

PostPosted: Sun Sep 13, 2015 5:45 pm    Post subject: Bonding network under systemd without systemd tools [SOLVED] Reply with quote

Ok after a some time i finish to setup network bonding under systemd WITHOUT the use of new tools,
like "systemd-networkd.service " and "systemd-resolved.service"
and older but STABLE systemd version.
because i do not wan't use unstable gentoo systemd version under my servers...


# networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback n/a n/a
2 eno1 ether n/a n/a
3 enp8s0 ether n/a n/a
4 sit0 sit n/a n/a
5 enp3s0 ether n/a n/a
6 wlp0s20u5 wlan n/a n/a

6 links listed.


"enp8s0" = LAN N°1
"eno1" = LAN N°2
"BOND0" --> LAN 1 + LAN 2

"enp3s0" = WAN (IP STATIC 192.168.253.5)

# emerge --ask --quiet net-firewall/iptables
# emerge --ask --quiet sys-apps/iproute2
# emerge --ask --quiet net-misc/ifenslave

//----------------------------------------------------------------------\\
|| Création du Service "network@" qui servira à configurer la carte WAN ||
|| ou toute carte en adressage IP Fixe ||
\\----------------------------------------------------------------------//
# nano -w /etc/systemd/system/network@.service
Code:

[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/network@%i

ExecStart=/bin/ip link set dev %i up
ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/bin/ip route add default via ${gateway} metric ${metric}

ExecStop=/bin/ip addr flush dev %i
ExecStop=/bin/ip link set dev %i down

[Install]
WantedBy=multi-user.target


-----------------------------------------------------------------
- Fichier de configuration utilisé par le service "network@" -
- de la carte réseau enp3s0 qui nous servira de carte WAN -
-----------------------------------------------------------------
# nano /etc/conf.d/etwork@enp3s0
Code:

address=192.168.253.5
netmask=24
broadcast=192.168.253.255
gateway=192.168.253.254
metric=1


---------------------------------------------------------
- Activation et utilisation de la carte réseau WAN -
---------------------------------------------------------
All command for start stop enable disable ... to copy past ...

# systemctl status -l network@enp3s0
# systemctl start network@enp3s0
# systemctl stop network@enp3s0
# systemctl enable network@enp3s0

# ip link show enp3s0
--> 5: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:18:4d:xx:xx:xx brd ff:ff:ff:ff:ff:ff

//------------------------------------------\\
|| Configuration du module kernel "BONDING" ||
\\------------------------------------------//

Charger le module bonding: (LOAD)
# modprobe bonding

Afficher les infos en cours d'utilisation du module: (RUNNING)
# cat /proc/net/bonding/bond0

Pour connaître les paramètres à utiliser dans le module: (INFO)
# modinfo bonding
--> mode:Mode of operation; 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)

Pour décharger le module bonding: (UNLOAD)
# modprobe -r bonding

Passage des paramètres du module bonding: (SETTINGS FOR MODULE)
# nano /etc/modprobe.d/bonding.conf
Code:

options bonding mode=0
options bonding miimon=1000
options bonding max_bonds=1
options bonding updelay=1000
options bonding downdelay=0


//--------------------------------\\
|| Création du Service "bond@" ||
\\--------------------------------//
# nano -w /etc/systemd/system/bond@.service
Code:

[Unit]
Description=Network bond 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/bond@%i

ExecStartPre=/sbin/modprobe bonding
ExecStart=/bin/ip link set dev %i up
ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/bin/ip route add default via ${gateway} metric ${metric}
ExecStart=/bin/ip link set dev ${lan1} up
ExecStart=/bin/ip link set dev ${lan2} up
ExecStart=/bin/ip link set dev %i up
ExecStart=/sbin/ifenslave --force %i ${lan1} ${lan2}
ExecStart=/sbin/sysctl -w net.ipv4.ip_forward=1
ExecStart=/sbin/iptables --table nat --append POSTROUTING --out-interface ${wan} --jump MASQUERADE
ExecStart=/sbin/iptables --append FORWARD --in-interface %i --jump ACCEPT

ExecStop=/sbin/sysctl -w net.ipv4.ip_forward=0
ExecStop=/sbin/iptables --delete FORWARD --in-interface %i --jump ACCEPT
ExecStop=/sbin/iptables --table nat --flush
ExecStop=/bin/ip addr flush dev %i
ExecStop=/sbin/ifenslave --detach %i ${lan1} ${lan2}
ExecStop=/bin/ip link set dev %i down
ExecStop=/bin/ip link set dev ${lan1} down
ExecStop=/bin/ip link set dev ${lan2} down
ExecStopPost=/sbin/modprobe -r bonding

[Install]
WantedBy=multi-user.target


//---------------------------------------\\
|| Fichier de Configuration du BOND0 ||
\\---------------------------------------//
# nano -w /etc/conf.d/bond@bond0
Code:

address=192.168.0.1
netmask=22
broadcast=192.168.3.255
gateway=192.168.0.1
metric=10
wan=enp3s0
lan1=eno1
lan2=enp8s0


you can easy adapt for more network card, i can't adapt automaticly to the number of the cards, (if anybody can improve that ! )

# systemctl daemon-reload
# systemctl disable bond@bond0
# systemctl enable bond@bond0
# systemctl start bond@bond0
# systemctl status -l bond@bond0
# journalctl -xe
# systemctl stop bond@bond0

# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST> mtu 1500
inet 192.168.0.1 netmask 255.255.252.0 broadcast 192.168.3.255
inet6 fe80::222:4dff:feab:99f2 prefixlen 64 scopeid 0x20<link>
ether 00:22:4d:xx:xx:xx txqueuelen 0 (Ethernet)
RX packets 982221 bytes 1429512139 (1.3 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 523953 bytes 35836034 (34.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether 00:22:4d:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 491184 bytes 715825365 (682.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 262087 bytes 18500269 (17.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xeed00000-eed20000

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.253.5 netmask 255.255.255.0 broadcast 192.168.253.255
inet6 fe80::218:4dff:fee9:c6b9 prefixlen 64 scopeid 0x20<link>
ether 00:18:4d:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 38941282 bytes 32967993370 (30.7 GiB)
RX errors 0 dropped 9 overruns 0 frame 0
TX packets 21851568 bytes 23069646348 (21.4 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp8s0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST> mtu 1500
ether 00:22:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 491203 bytes 713760722 (680.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 262058 bytes 17429841 (16.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xee800000-ee8fffff

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Boucle locale)
RX packets 47178 bytes 354999417 (338.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 47178 bytes 354999417 (338.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 1000
Up Delay (ms): 1000
Down Delay (ms): 0

Slave Interface: eno1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:22:4d:xx:xx:xx
Slave queue ID: 0

Slave Interface: enp8s0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:22:4d:yy:yy:yy
Slave queue ID: 0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum