ubuntu and variants
- give priority to Wi-Fi over Ethernet for Internet connections:
Wired Connection→IPv4 Settings→Routes→Use this connection only for resources on its network.(source) - check speed of NIC:
cat /sys/class/net/<interface>/speed - check bandwidth of what is being sent in realtime with
nethogs. Add the-Coption tonethogsto see both UDP and TCP (shows only TCP by default)
Netplan
Netplan is a front end for systemd-networkd
- restarting netplan:
systemd restart systemd-networkd.service - try and optionally use a new netplan config:
netplan try - configuration are YAML files that go inside
/etc/netplan - in the config file choose
Network Manageras renderer for GUI, ornetworkdto configure inside the YAML file
Example Netplan yaml file to create a bridge
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: no
eno1:
dhcp4: no
enxf8e43b6c9b8c:
dhcp4: true
bridges:
br2:
dhcp4: no
addresses:
- 10.42.0.1/24
interfaces:
- enp1s0
- eno1
With this configuration you can treat br2 as if it were a real physical interface (run a DHCP server on it, etc.)
Sharing Internet with an interface
- configure the userspace to allow ipv4 forwarding:
- temporary:
sudo echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward - persistant: change setting in
/etc/sysctl.conf
- assuming
enxf8e43b6c9b8cconnects to the internet andbr2is the interface you wish to share internet with
#iptables -t nat -A POSTROUTING -o enxf8e43b6c9b8c -j MASQUERADE #iptables -A FORWARD -i enxf8e43b6c9b8c -o br2 -m state --state RELATED,ESTABLISHED -j ACCEPT #iptables -A FORWARD -i br2 -o enxf8e43b6c9b8c -j ACCEPT
- install
iptables-persistentto retain iptables rules on reboot.
Configure isc-dhcp-server
- inside
/etc/default/isc-dhcp-serverset the interface.- Assuming interface for dhcp server will be br2:
INTERFACESv4="br2"
- configuration goes inside
/etc/dhcp/dhcpd.conf- Assuming interface for DHCP server is at 10.42.0.1, example config:
ddns-update-style none;
authoritative;
default-lease-time 600;
max-lease-time 7200;
subnet 10.42.0.0 netmask 255.255.255.0 {
range 10.42.0.50 10.42.0.254;
option routers 10.42.0.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
}