The following tutorial assumes that you want to provide the interwebs to a PC connected via eth0 to your host, and that your host is connected to the world via wlan0.
- Set up the local IP address
# ifconfig eth0 192.168.250.1
or, if you're using ip:
# ip a a 192.168.250.1/24 dev eth0
- Enable IPv4 forwarding
# sysctl -w net.ipv4.ip_forward=1
- Forward packets via iptables
# iptables -A FORWARD --in-interface eth0 -j ACCEPT
# iptables --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE
- Launch dnsmasq
# dnsmasq -F 192.168.250.2,192.168.250.10,12h -i eth0 -d
4.1 If dnsmasq is not available, set up IP on the second machine by hand
# ifconfig eth0 192.168.250.2
# route add default gw 192.168.250.1
...or, without ifconfig/route...
# ip a a 192.168.250.2/24 dev eth0
# ip r a default via 192.168.250.1
- ???
- Profit!
Hey, casual onlooker that's maintaining their own network as a hobby over here.
What would be the best way to do that automatically, in your opinion? (as in; not using a
systemd
service to run this bash script)