legacy: this is for Debian 12 and older

if user does not have a WIFI-Adapter for your Desktop PC, you could hook it up to your LAN of your Laptop and share the internet.

cp -v /etc/network/{interfaces,interfaces.backup}; # backup your existing network configuration
vim /etc/network/interfaces; # edit configuration

# setting up a bridge is similar to setting up a normal network-device
# setup bridge with fixed ip
auto br0
iface br0 inet static
address 192.168.0.123
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports wlan0 eth0
bridge_fd 5
bridge_stp no # depending on your network, you might want to set this to yes

# now save and close
# run
/etc/init.d/networking restart; # restart networking service

user should now be able to connect a PC to LAN port of Laptop and share the Wifi-internet connection.

Debian 13 (Trixie) and newer: (WORK IN PROGRESS!)

# debian switched to ubuntu's netplan
su - root
apt-get install bridge-utils iptables
# create bridge (virtual network device)
brctl addbr br0

# add create temporary ip address for interface br0
ip addr add 192.168.0.123/25 dev br0
# add default gateway
ip route add default via 192.168.0.1

# what is there?
ip -c a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: end0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 5e:4d:7e:a7:d2:95 brd ff:ff:ff:ff:ff:ff
    inet 169.254.110.128/16 metric 2048 brd 169.254.255.255 scope link end0
       valid_lft forever preferred_lft forever
    inet 192.168.0.65/24 brd 192.168.0.255 scope global end0
       valid_lft forever preferred_lft forever
3: end1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 5e:4d:7e:a7:d2:b5 brd ff:ff:ff:ff:ff:ff
    inet 169.254.2.98/16 metric 2048 brd 169.254.255.255 scope link end1
       valid_lft forever preferred_lft forever
    inet 192.168.4.1/24 brd 192.168.4.255 scope global end1
       valid_lft forever preferred_lft forever
4: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 9a:c7:42:91:b8:65 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.123/25 scope global br0
       valid_lft forever preferred_lft forever

ping 192.168.0.123; # pinging the device should already be possible now
PING 192.168.0.123 (192.168.0.123) 56(84) bytes of data.
64 bytes from 192.168.0.123: icmp_seq=1 ttl=64 time=5.82 ms
64 bytes from 192.168.0.123: icmp_seq=2 ttl=64 time=3.09 ms

# backup config
cp -rv /etc/netplan/00-default-use-network-manager.yaml /etc/netplan/00-default-use-network-manager_$(date '+%Y-%m-%d')_backup.yaml
cp -rv /etc/sysctl.conf /etc/sysctl.conf_$(date '+%Y-%m-%d')_backup
# uncomment line net.ipv4.ip_forward=1
sed -i '/^[[:space:]]*#\{0,1\}[[:space:]]*net\.ipv4\.ip_forward=1/s/^[[:space:]]*#\{0,1\}[[:space:]]*//' /etc/sysctl.conf
# activate changes
sysctl -p

# add NICs to the bridge 
# WARNING! THIS WILL POTENTIALLY DISRUBT INTERNET CONNECTIVITY OF THE DEVICE!
brctl addif br0 end0; brctl addif br0 end1;

# just4sake of completeness:
# remove temporary static ip adress for interface br0
ip addr del 192.168.0.123/24 dev br0
# remove default gateway
ip route del default via 192.168.0.1

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin