Lagg failover FreeBSD - freebsd

I've tried using channel bonding(active-backup) in ubuntu and it worked well . I could understand that the bonded interfaces are monitored by MII monitoring and when an interface goes down and slave takesover it sends a gratuitous arp for updating neighbour cache . I tried to achieve the same in FreeBSD by using the lagg interface. However I could'nt understand how the link states are monitored . lagg also does not send any gratuitous arp. So how does lagg (active failover ) work ?

Have you read the section in the FreeBSD handbook that talks about Link Aggregation and failover?
https://www.freebsd.org/doc/handbook/network-aggregation.html
Make sure you load the if_lagg kernel module in /boot/loader.conf:
if_lagg_load="YES"
The, in rc.conf, bring your ethernet devices up and create a lagg0 interface with those as members:
ifconfig_igb0="UP polling"
ifconfig_igb1="UP polling"
ifconfig_igb2="UP polling"
ifconfig_igb3="UP polling"
ifconfig_lagg0="create laggproto lacp laggport igb0 laggport igb1 laggport igb2 laggport igb3 128.115.132.165 netmask 255.255.255.0"
I wrote a blog post about it a few years ago, it is still fairly accurate:
https://mywushublog.com/2010/04/lagg-freebsd/
You will need to configure your switch ports for LACP

Related

Raspbian : Force a wlan0 static ip [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
I would like to configure a wlan0 static ip and connect through it by ssh.
Here my /etc/network/interfaces :
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
adress 192.168.0.2
netmask 255.255.255.0
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.100.102
netmask 255.255.255.0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
When I do ifconfig my wlan0 and eth0 interfaces are correctly configured :
However, when I want to ssh my raspberry by wifi, my Wifi router give to my raspberry the ip : 192.168.100.116.
How can I force my Wifi router to give 192.168.100.102 to my rapsberry pi ?
Moreover, My Wifi router give to my raspberry sometimes 192.168.100.102 and sometimes 192.168.100.116
Don't know why
I experienced similar issues when I wanted to connect my Rasperry Pi 2 with Raspbian Jessie Lite in a headless configuration for access using SSH from my Windows 10 PC with PuTTY.
In my case it turned out that the Ahavi daemon (an implementation of zeroconf) conflicted with the DHCP and name server options of my router.
Raspbian Jessie and Raspbian Jessie Lite comes pre-configured with an Avahi and a DHCP client deamon for automated network configuration. In most situation this will probably work fine, but if not, things take a turn for the worse with unpredictable side-effects.
Instead of going too deep into any details (its really a long story) I will just summarize here what I did and why. There are too many possible issues and I dont want to push you into the wrong direction. Try it out. If it fails, look for another approach or leave a comment for clarification.
Now let's get your feet wet:
Try it first on a non-productive SD card with a fresh copy of Raspbian Jessie (for headless servers I prefer Raspbian Jessie Lite).
Start the Raspberry Pi with a keyboard and a monitor connected and login with user pi.
Start raspi-config with sudo raspi-config and make sure to turn on the SSH server (menue 7 Advanced Options -> A4 SSH).
Get your current IP address for eth0 with ifconfig.
Try to connect to this address over ethernet using ssh. In case you cant connect, resolve this issue first. You cant connect over WLAN at this stage.
In case your connection succeeds, you can do the rest of your configuration using this connection over ssh.
Purge the avahi-daemon
$ sudo apt-get purge avahi-daemon
Dont worry about the error message 'rmdir: failed to remove ‘/var/run/avahi-daemon’: Directory not empty'. This is related to a an empty socket and a pid file, that currently cannot be removed. You can ignore this message or remove the directory manually, but it wont hurt in case you just leave it.
$ sudo rm -r /var/run/avahi-daemon
Configure /etc/network/interfaces
It's important to know, that we need only one single change in this file. Open /etc/network/interfaces for changes with the editor of your choice (note: if you followed this steps 1:1 extended vim is not yet installed).
$ sudo nano /etc/network/interfaces
Add the line auto eth0 just before the existing line iface eth0 inet manual. That's all we have to do here is to here. After the changes the file should look like this:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Note: make sure to read and to understand the comments on top of the file!
Configure the DHCP client daemon
Next, as stated in the comments of the previously edited file, add the static ip configuration at the end of the configuration file for the DHCP client daemon.
It might sound silly to use a DHCP client if we are going to use static IP addresses anyway. However, when I tried to remove the DHCP client daemon I experienced new configuration and/or dependency issues. Finally I decided to keep as close to the standard configuration as possible and leave it as is.
The configuration is done at the very end in the file /etc/dhcpcd.conf (watch proper spelling). The last line in the file should read: 'nohook lookup-hostname'. So let's open the the file in the editor and scroll down to the bottom of the file.
$ sudo nano /etc/dhcpcd.conf
Add there the static ip definition. In my case the definitions at the of /etc/dhcpcd.conf look like this:
nohook lookup-hostname
# static ip configuration for eth0 and wlan0
interface eth0
static ip_address=192.168.1.61/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
interface wlan0
static ip_address=192.168.1.62/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
Note that the syntax is different from the syntax used in /etc/network/interfaces. For a full class C network the netmask must be provided in form of a /24 at the end of the IP address. For further details consult man dhcpcd.conf.
Reboot and test your configuration with eth0
After the next reboot you should have a reliable network configuration with static ip addresses. But remember, we are not yet finished and only eth0 will work. At this point even no IPv4 address will be shown for wlan0 if ifconfig is issued
In case it fails and you didn't do anything wrong so far (carefully check for typos), then you have another issue that must get fixed first; in this case this solution is probably not for you.
Configure WLAN
To configure WLAN we have to edit /etc/wpa_supplicant/wpa_supplicant.conf and add a network configuration to it.
In my case I'm using WPA/PSK for secure access and after modifying the country code and adding the network entry, the content of the file looks something like this:
country=CH
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# home network; allow all valid ciphers
network={
ssid="home"
scan_ssid=1
key_mgmt=WPA-PSK
psk="very secret passphrase"
}
ssid="home" is the WLAN network name (SSID) of the WLAN router or access point.
scan_ssid=1 scans for hidden SSID's. This is usual practice but can slowdown the scan process.
key_mgmt=WPA-PSK defines that WPA pre-shared key management protocol will be used.
psk="very secret passphrase" defines your passphrase to access the router.
Replace the values assigned for ssid and psk with the real values for your secure WLAN access. There are several supported protocols, some requiring other and more options.
Consult man wpa_supplicant.conf for additional and more detailled information.
Reboot and test your configuration with wlan0
Now it's time to reboot and test wlan0. The ip address configured for wlan0 should now appear if ifconfig is issued.
If this is the case you should be able to access the Rasperry Pi using ssh with the IP address configured for wlan0.
I hope you are happy and everything works fine for you so far. If this is the case, I could stop writing here and leave you alone. But wait, there is more!
Two network connections, does that make sense?
If you connect to the Raspberry Pi from the same network over both, eth0 and wlan0 and issue an ifconfig to take a look at the transmitted and received packets or bytes, you will recognize, that even you connected to the IP for wlan0 most traffic is going through eth0.
I cant explain why this is the case, but obviously somehow the packets are routed along the faster path which sounds good so far.
However, I've seen rare situations where this behaviour was undesirable and slowed my connections down. Since I'm using my Raspberry Pi either near my router using a wired connection to eth0 or more distant from the router with no access to a cable using wlan0, I decided to stop wlan0 if a cable with an active connection to the router is attached to eth0.
To do this I created the script /home/pi/ifdown-wlan-if-not-needed.sh
#!/bin/sh
#### Shutdown wlan0
# Test eth0 for a cable attached and
# shutdown wlan0 if this is the case.
###
sleep 30
cable=$(cat /sys/class/net/eth0/carrier)
echo $cable
if [ "$cable" = "1" ]; then
sudo ifdown wlan0
fi
exit 0
Then I've set the script to executable
$ chmod +x /home/pi/ifdown-wlan-if-not-needed.sh
And added it for execution after reboot with crontab -e to the crontab of user pi.
#reboot /home/pi/ifdown-wlan-if-not-needed.sh
Name to IP address resolution
So far I have not yet addressed the name to IP address resolution problem. How this can be done best, depends on your network equipment and use case.
My router provides the ability to bind names to MAC addresses, hostnames and IPv4 adresses. However, for some reason none of these options really work. Some times it works by simply using the given name, other times the suffix .home is needed. Sometimes the names disappear from the list or no name resolution takes place even everything looks ok.
I finally defined the adresses in the C:\Windows\System32\drivers\etc\hosts file of my Windows PC and my Notebook. This is certainly not state of the art but works reliable and without hassle.
However, I cant guarantee that what I did works for you too, but I hope it brings you on the right track to get your problem solved. I've been using my configuration since the release of Raspbian Jessie about one year ago. It survived any updates without hassle so far.
Good luck!
Login on your router management interface and (if it has this feature, most do have it) reserve a DHCP address on the router for your selected client, so that the specific client always has the same IP address. See this article for more information.

Soft Access Point/Client Connect using wpa_supplicant with 2.4/5Ghz channels

This is a weird one. Let me start with that.
I am currently working on a Yocto embedded linux board from Digi, if that matters. I have just managed to, through use of dnsmasq and wpa_supplicant, allow other devices to connect to the board.
My current question is this: Can I use the 5.0 Ghz channel for allowing other devices to connect, and the 2.4Ghz channel to allow for the board to connect to other wifi access points?
My configurations:
#dnsmasq.conf
interface=wlan0
dhcp-range=10.0.0.10,10.0.0.200,2h
#interfaces
auto wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
wpa_driver nl80211
wpa_conf /etc/wpa_supplicant.conf
#wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
fast_reauth=1
update_config=1
#Soft AP Mode
ap_scan=2
network={
ssid="mySSID"
mode=2
frequency=2412
key_mgmt=WPA-PSK
proto=RNS
pairwise=CCMP
psk="MySecret"
}
Does anyone has an idea (or better yet, an improved version of what I'm doing) of how to get it to do this?

List of all devices in a subnet programatically

I would like to get the list of all the active IP devices in a network using C.
I will explain my problem with an example.
example: I have 5 devices in a network with the IP ranging from
device 10.0.0.2
device 10.0.0.3
device 10.0.0.4
device 10.0.0.5
device 10.0.0.6
From my application I would like to get this list. My platform is Linux and I am using C. Currently I am not using any networking libraries. If some libraries provide such utilities I am one to use the same.
Please advice on the same.
There is no super fast direct logic for knowing which IP-addresses are online, but there are tricks that can be used.
The most common that does not require anything special is just to trying to connect to each host using TCP, on the service you expect.
Another technique can be do send out ICMP ping first, but not all OS'es answer to ping with default settings etc.
Last technique that can be used (that only works for local networks, not via gateway), is that after you try to send the ping, look at the ARP table. If a valid ARP entry exists, the host is online, even if no ping reply has been received.
You can use nmap (note /24 for the subnet mask, and -sn flags for the quick Ping Scan), as stated in the https://www.howtogeek.com/423709/how-to-see-all-devices-on-your-network-with-nmap-on-linux/
sudo nmap -sn 192.168.4.0/24
You can also do a broadcast ping but nmap gives you much more details:
ping 192.168.178.255 -b

Linux bridge of my own making: arp request never succeeds

I wrote a bridge (layer 2 switch) using my Boost.Asio extension. We can easily make additional sockets, endpoints and protocols which meet their type requirements. And my extension uses linux packet socket with AF_PACKET, SOCK_RAW and htons(ETH_P_ALL) (See man 7 packet for more information about packet socket).
Here's an example for explaining how my bridge works:
[PC1] <----> IF1[PC2]IF2 <----> [PC3]
Bridge connects the network interfaces(e.g. eth0) IF1 and IF2 so PC1 can communicate with PC3 via bridge running on PC2. The way to connect interfaces is sending packets received from IF1 to IF2 (and vice versa)
My bridge works under the wired connections as expected, but it doesn't work under the wireless connections. So I tried to find what causes this problem and I found that ARP request never succeeded.
The actual environment which causes this problem is:
[PC1] <--wired--> eth0[PC2]wlan0 <--wireless(802.11g)--> [router1]
Under the environment above, for example, now PC1 tries to send ping(ICMP) packet to router1. To send it to PC3, PC1 has to know the MAC address of router1 so PC1 sends ARP request to FF:FF:FF:FF:FF:FF And my bridge running on PC2 receives it from eth0 and send it to wlan0, but router1 never sends arp reply to PC1.
note: SOCK_RAW packets are passed to and from the device driver without any changes in the packet data. (quoted from man page of packet)
What should I do to allow PC1 to communicate with router1?
Thank you.
Edit:
Here is my Boost.Asio extension.
github: pfpacket/libarex
And this is my bridge using above.
libarex/example/layer2_switch/interface_bridge.cpp
I'm writing up what we discussed in the comments.
It is a common problem that wireless bridging is problematic (under linux at least, I don't know for others). Investigation has shown that most probably the wireless driver or chipset of the hardware used as bridge is incapable of doing bridging operations (brctl failing supports this assumption).
Other possible reasons, as explained in the link above, may be the AP dropping packets with unassociated MAC adresses or the likes.
Additionally, the code works fine for wired interfaces, so it is a hardware problem on some layer. Not much more to say about it.

bond on software-bridge connection issue

What you have:
bond (bond0) interface (all modes except 4) with at least 2 ifaces (say eth0 / eth1) connected on the same external switch
bond0 interface joined on a software bridge (br0)
virtual machine (vm0) (eg LibVirt::LXC) with an interface on br0
What you get:
vm0 is not able to connect to (most) IP addresses via bond0 over br0
"bond0: received packet with own address as source address" in syslog
Why you get this:
When vm0 wants to contact an external IP address it will send out an ARP request. This L2 broadcast with the source mac of vm0 will leave through (depending on bonding mode) eg eth0, but via the external switch, re-enter through eth1 and thus bond0. Hence the switch br0 will learn the mac-address of vm0 on the port connected to bond0. As a consequence the ARP-reply is never received by vm0.
What can you do to resolve:
The reason I post this, next to sharing the info, is that I wasn't able to figure out a good enough solution. Those I did find are:
On vm0 set static ARP entry
Use bond0 mode=4 but your external switch must support this
Configure your external siwtch to use private VLAN on eth0/eth1 but only works in some use-cases and adds complexity
Add both physical interfaces to the bridge with spanning tree enabled, instead of using bond driver
Statically configuring the MAC of vm0 on the correct port of br0 is not an option on Linux (works on OpenBSD though)
I'm really hoping for a more elegant solution here... Anyone?
Thanks
I've got the same problem and I come up with the same analysis.
The only non-invasive/scalable solution I've found is to use the active/backup bonding (mode 1). The tradeoff is that you lose the aggregation.
IMO, the best solution is to use 802.3ad, but I can't always use it because I'm limited with 6 port-channels on most of my switches.
Try these options in bridge:
brigde_fd 0
bridge_stp off # switch on with more system like this
bridge_maxage 0
bridge_ageing 0
bridge_maxwait 0
Taken from this thread:
kvm bridge also in proxmox

Resources