Last active
August 8, 2023 07:15
-
-
Save Lirt/7a3811c30fb49b5269dc1251f39eee9f to your computer and use it in GitHub Desktop.
Useful things with linux networking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Debian default gateway /etc/network/interfaces | |
up route add default gw 62.210.123.1 | |
# Force interface eth0 to 10 Gbit speed | |
ethtool -s <device> speed 10000 duplex full autoneg off | |
# For the setting to be persistent across reboots | |
# edit "/etc/udev/rules.d/71-ethtool.rules"ff and | |
# add "SUBSYSTEM=="net", ACTION=="add", NAME=="<device>", RUN+="/sbin/ethtool <device> -s speed 100 duplex full autoneg off" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Traffic shaping libvirt / Quality of service | |
<devices> | |
<interface type='network'> | |
<source network='default'/> | |
<target dev='vnet0'/> | |
<bandwidth> | |
<inbound average='1000' peak='5000' floor='200' burst='1024'/> | |
<outbound average='128' peak='256' burst='256'/> | |
</bandwidth> | |
</interface> | |
</devices> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get HW address of interface. Split by ':' | |
interface="eth0" | |
cat /sys/class/net/$interface/address | |
# Get operational state of interface (up/down/unknown) | |
cat /sys/class/net/$interface/operstate | |
# Get carrier status of network interface (interface must be up). | |
# 0 if interface is DOWN | |
# 1 if interface is UP | |
cat /sys/class/net/$interface/carrier |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -nL | grep -Eo "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" | sort | uniq | xargs -I {} -P 50 ping -W1 -c1 {} | grep -B1 "0 received" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment