Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
modprobe bonding do not provide bond0 in bonding_masters fil
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: 46
Location: FRANCE

PostPosted: Sun Feb 04, 2018 8:41 pm    Post subject: modprobe bonding do not provide bond0 in bonding_masters fil Reply with quote

[#modprobe bonding do not provide "bond0" value in bonding_masters file]

Hello, since few years i use bonding under systemd with home made service and configuration files
just with net-firewall/iptables , sys-apps/iproute2 , net-misc/ifenslave and modprobe.

Since last upadte (today) of my system, have no bond0 device at boot....grrrrr

Before: when you start module bonding (manually, idem if auto at boot)
you have with this command
# ls /sys/class/net
the listing of all network devices with bond0...
---> bond0 bonding_masters eno1 enp2s0 enp8s0 lo sit0
now have only --> bonding_masters eno1 enp2s0 enp8s0 lo sit0


modprobe bonding create a file /sys/class/net/bonding_masters
and(?) a symlink /sys/class/net/bond0

i think in bonding_masters we have a bond0 value, today this file is empty...

the only work around i found is to manually inject bond0 in bonding_masters file
and only after, i can manually start my systemd bonding service
i found this tips in this good topic https://backdrift.org/manage-linux-bonding-without-ifenslave-using-sysfs

i love and use gentoo since 15 years ... but since 2 years ...
Back to top
View user's profile Send private message
christophe_y2k
n00b
n00b


Joined: 07 Jan 2008
Posts: 46
Location: FRANCE

PostPosted: Thu Jul 01, 2021 11:39 pm    Post subject: Systemd network bonding without network manager Reply with quote

Kernel 5.12.13-gentoo
Manual setup for Network Bonding under SystemD without network manager
Config: 4xLAN and 1xWAN network cards

Assign Natural and Friendly network card name:
# ls /sys/class/net
--> eno1 enp1s0f0 enp1s0f1 enp2s0 enp8s0 lo

# nano /etc/systemd/network/10-wan1.link
Code:
[Match]
MACAddress=68:05:ca:xx:yy:zz

[Link]
Description=Intel(R) PRO/1000 Network Connection (e1000e)
Name=wan1


# nano /etc/systemd/network/11-lan1.link
Code:
[Match]
MACAddress=70:85:c2:xx:yy:zz

[Link]
Description=Intel(R) PRO/1000 Network Connection (e1000e)
Name=lan1


# nano /etc/systemd/network/12-lan2.link
Code:
[Match]
MACAddress=70:85:c2:xx:yy:zz

[Link]
Description=Intel(R) Gigabit Ethernet Network Connection (igb)
Name=lan2


# nano /etc/systemd/network/13-lan3.link
Code:
[Match]
MACAddress=90:e2:ba:xx:yy:zz

[Link]
Description=Intel(R) Gigabit Ethernet Network Connection (igb)
Name=lan3


# nano /etc/systemd/network/14-lan4.link
Code:
[Match]
MACAddress=90:e2:ba:xx:yy:zz

[Link]
Description=Intel(R) Gigabit Ethernet Network Connection (igb)
Name=lan4


# ls /sys/class/net
--> lan1 lan2 lan3 lan4 lo wan1

Auto "bonding" kernel module loading at boot under systemd :
----------------------------------------------------------------------------
# nano /etc/modules-load.d/bonding.conf
Code:
# Load bonding at boot
bonding


//----------------------------------------------------------------\\
|| Service "network@.service" ||
|| For Fixed IP ||
\\----------------------------------------------------------------//
# nano /etc/systemd/system/network@.service
Code:
[Unit]
Description=Network connectivity (%i)
Wants=network.target
Before=network.target
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 -4 addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/bin/ip -4 route add default via ${gateway} metric ${metric} dev %i

ExecStop=/bin/ip -4 route del default via ${gateway}
ExecStop=/bin/ip -4 addr flush dev %i
ExecStop=/bin/ip link set dev %i down

[Install]
WantedBy=multi-user.target


//--------------------------------\\
|| WAN card configuration ||
|| here => wan1 ||
\\--------------------------------//
# nano /etc/conf.d/network@wan1
Code:
address=192.168.253.2
netmask=24
broadcast=192.168.253.255

#FreeBox 10G CANNES
#gateway=192.168.253.1

#FreeBox 10G MANDELIEU
gateway=192.168.253.254

metric=1


# systemctl daemon-reload
# systemctl start network@wan1
# systemctl status -l network@wan1
# systemctl enable network@wan1
# journalctl -xr

# systemctl disable NetworkManager

# echo "sys-apps/systemd nat" >> /etc/portage/package.use
# emerge --ask --quiet --verbose systemd

For DNS search:
# nano /etc/resolv.conf
Code:
nameserver 8.8.8.8


//---------------------------------------\\
|| Service "bond@.service" ||
\\---------------------------------------//
# nano /etc/systemd/system/bond@.service
Code:
[Unit]
Description=Network BOND connectivity (%i)
Wants=network.target
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/bond@%i

ExecStartPre=/bin/sh -c "echo "+%i" > /sys/class/net/bonding_masters"
ExecStartPre=/bin/sh -c "echo ${bond_mode} > /sys/class/net/%i/bonding/mode"
ExecStartPre=/bin/sh -c "echo ${bond_miimon} > /sys/class/net/%i/bonding/miimon"
ExecStartPre=/bin/sh -c "echo ${bond_updelay} > /sys/class/net/%i/bonding/updelay"
ExecStartPre=/bin/sh -c "echo ${bond_downdelay} > /sys/class/net/%i/bonding/downdelay"
ExecStart=/bin/sh -c "echo "+${bond_lan1}" > /sys/class/net/%i/bonding/slaves"
ExecStart=/bin/sh -c "echo "+${bond_lan2}" > /sys/class/net/%i/bonding/slaves"
ExecStart=/bin/sh -c "echo "+${bond_lan3}" > /sys/class/net/%i/bonding/slaves"
ExecStart=/bin/sh -c "echo "+${bond_lan4}" > /sys/class/net/%i/bonding/slaves"

ExecStart=/bin/ifconfig %i ${address}/${netmask} broadcast ${broadcast} up
ExecStart=/bin/ip -4 route add default via ${gateway} metric ${metric}

ExecStart=/usr/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=/usr/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 -4 addr flush dev %i
ExecStop=/bin/ifconfig %i down

ExecStop=/bin/sh -c "echo "-${bond_lan4}" > /sys/class/net/%i/bonding/slaves"
ExecStop=/bin/sh -c "echo "-${bond_lan3}" > /sys/class/net/%i/bonding/slaves"
ExecStop=/bin/sh -c "echo "-${bond_lan2}" > /sys/class/net/%i/bonding/slaves"
ExecStop=/bin/sh -c "echo "-${bond_lan1}" > /sys/class/net/%i/bonding/slaves"
ExecStop=/bin/sh -c "echo "-%i" > /sys/class/net/bonding_masters"

[Install]
WantedBy=multi-user.target


//---------------------------------------\\
|| BOND0 File configuration ||
\\---------------------------------------//
# nano /etc/conf.d/bond@bond0
Code:
address=192.168.0.1
netmask=22
broadcast=192.168.3.255
gateway=192.168.0.1
metric=2
wan=wan1
bond_lan1=lan1
bond_lan2=lan2
bond_lan3=lan3
bond_lan4=lan4
bond_mode=0
bond_miimon=1000
bond_updelay=1000
bond_downdelay=1000


# systemctl daemon-reload
# systemctl start bond@bond0
# systemctl status -l bond@bond0
# systemctl enable bond@bond0
# journalctl -xr

For disable INTEL TSO BUG with network module e1000e --> for me wan1 and lan1 :
------------------------------------------------------------------------------------------
# emerge --ask --quiet sys-apps/ethtool

# nano /etc/systemd/system/tsooff@.service
Code:
[Unit]
Description=Disable TSO with Intel e1000e Network card (%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
ExecStart=/usr/sbin/ethtool -K %i tso off
ExecStop=/usr/sbin/ethtool -K %i tso on

[Install]
WantedBy=multi-user.target


# systemctl start tsooff@lan1
# systemctl status -l tsooff@lan1
# systemctl enable tsooff@lan1

# systemctl start tsooff@wan1
# systemctl status -l tsooff@wan1
# systemctl enable tsooff@wan1
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