$ ping 8.8.8.8 ping: socket: Operation not permitted
# setcap cap_net_admin,cap_net_raw+p /bin/ping
# getcap /bin/ping /bin/ping = cap_net_admin,cap_net_raw+p
$ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
Category Archives: Linux
Problem after upgrading Zabbix Agent on Debian (from Stretch to Buster)
If You occured the problem in /var/log/zabbix-agent/zabbix_agentd.log
Message from <Zabbix Server IP> is missing header. Message ignored.
Downgrade Zabbix Agent from 4.x to your server version.
# apt-get remove zabbix-agent
Download appropriate version from http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix/
# wget http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix/zabbix-agent_3.0.28-1%2Bbuster_amd64.deb
install it
# dpkg -i zabbix-agent_3.0.28-1+buster_amd64.deb
lock if for future upgrades
# apt-mark hold zabbix-agent
unmask
# systemctl unmask zabbix-agent
enable and start
# systemctl enable zabbix-agent
# systemctl start zabbix-agent
quick linux wifihotspot
To launch a basic wifi hotspot you need: iwconfig, iptables, dnsmasq, hostapd on your Linux box. Install it. Enable it (systemct enable).
To search what package a file belongs to, help youself an use:
apt-filesearch package
or
pacman -Fys package
Check if your system is compatibile with hostap, use iwconfig to list interfaces.
$ iwconfig
wlan0 IEEE 802.11 ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr=2347 B Fragment thr:off
Power Management:on
eth0 no wireless extensions.
lo no wireless extensions.
Edit or create desired files.
For dnsmasq use your internal adress space.
#
# /etc/dnsmasq/dnsmasq.conf
#
dhcp-range=192.168.1.64,192.168.1.128,12h
For Debian edit /etc/default/dnsmasq and add following:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
For hostpad, change parameters for interface (interface), name of your wifi network (ssid), wifimode (hw_mode), channel (channel), password (wpa_passphrase), and use or not isolation (ap_isolate), hide your wifi or not (ignore_broadcast_ssid).
#
# /etc/hostapd/hostapd.conf
#
interface=wlan0
driver=nl80211
hw_mode=g
#ieee80211n=0
#ieee80211n=1
channel=4
ssid=private
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=12345678
#ap_isolate=1
ignore_broadcast_ssid=0
Create script to run hotsopt and internet sharing, define yours external and internal interfaces (EXTIF, INTIF) and make it executable.
#
# masq.sh
#
#!/bin/sh
EXTIF=eth0
INTIF=wlan0
echo killing processes if something is using wifi interface
airmon-ng check kill
ip a a dev $INTIF 192.168.1.254/24
ip l set dev $INTIF up
echo '(re)starting dnsmasq'
systemctl restart dnsmasq
echo '(re)starting hostpad'
systemctl restart hostapd
echo flushing...
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
echo setting ip_forward...
echo 1 > /proc/sys/net/ipv4/ip_forward
#echo loading modules...
#modprobe ipt_MASQUERADE
echo configuring NAT...
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
Troubleshooting:
hostapd -d /etc/hostapd/hostapd.conf
Of course you can do everything your own way. It is just an outline of how to run basic Acces Point.
I’m using it on my RaspberryPi.
Monitoring UDP datagrams
Run script udpstat.sh in console
#!/bin/sh
while true
do
HOUR=`date '+%H'`
echo $HOUR
sar -n UDP 1 -1 >/var/log/stats/udpstats$HOUR.txt
done
Add job to crontab
0 * * * * /usr/bin/kill $(/usr/bin/ps aux |/usr/bin/grep '[s]ar -n UDP 1 -1' |/usr/bin/awk '{print $2}')
Limit UDP packets
/sbin/iptables -A OUTPUT -p udp -m state --state NEW -j ACCEPT
/sbin/iptables -A OUTPUT -p udp -m limit --limit 10000/s -j ACCEPT
/sbin/iptables -A OUTPUT -p udp -j DROP
creating md5 sums on filesystem
time find -name "." -type f -not -path "/proc/" -not -path "/sys/" -not -path "/dev/" -not -path "/run" -exec md5sum "{}" + > /root/checklist.chk
mpd in userspace with pulseaudio
create config for mpd:
vi ~/.config/mpd/mpd.conf
bind_to_address "172.16.254.254"
music_directory "/home/jasiu/Music"
playlist_directory "/home/jasiu/Music"
#db_file "/var/lib/mpd/mpd.db"
#log_file "/var/log/mpd.log"
user "jasiu"
audio_output {
type "pulse"
name "My Pulse Output"
server "localhost"
# server "remote_server" # optional
# sink "remote_server_sink" # optional
}
modify configuration of pulseaudio to allow play through tcp from localhost
# vi /etc/pulse/default.pa
add this line to config:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
If you do not want to restart your X session load desired module manually
$ pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
and finally start mpd in userspace
$ mpd –no-daemon –verbose
To play not in user space:
Add user mpd to pulse access and modify global config /etc/mpd.conf
audio_output {
type "pulse"
name "My Pulse Output"
server "localhost"
# server "remote_server" # optional
# sink "remote_server_sink" # optional
}
modify /etc/pulse/default.pa
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
restart pulseaudio
$ pulseaudio -k
Try to play using yours favourite mpd player:
for example MPDroid for mobile phone or Sonata for non Windows environment
Debian postinstall
Stop avahi
# systemctl disable avahi-daemon
Enable rc.local capability/compatibility
# echo $'#!/bin/sh -e\nexit 0'
convert text in command line
more sometext | iconv -f iso8859-2 -t utf8 |more
where iso8859-2 is orginal encoding and utf8 is desired encoding of the text file
benchmark for Linux/FreeBSD
In Linux:
# git clone https://github.com/kdlucas/byte-unixbench.git # cd byte-unixbench/UnixBench/ # ./Run
Modifications on FreeBSD:
comment out in Makefile
#OSNAME:=$(shell uname -s)
modify ./Run
#!/usr/bin/perl -w
#!/usr/local/bin/perl -w
my $make = $ENV{MAKE} || "make";
my $make = $ENV{MAKE} || "gmake";
then
./Run
MATE – Change DPI from command line
If You accidentally changed DPI to very high value and cannot revert to previous settings from GUI, use command line:
$ gsettings list-schemas | grep mate| grep font
$ gsettings list-keys org.mate.font-rendering
rgba-order
antialiasing
dpi
hinting
$ gsettings get org.mate.font-rendering dpi
500.0
$ gsettings set org.mate.font-rendering dpi 96