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!
Invoke
iptables-save
(and you may need to redirect the output to/etc/iptables/rules.v4
depending on your OS).Replace your
/etc/dnsmasq.conf
with the following:Add
net.ipv4.ip_forward=1
to your/etc/sysctl.conf
.And for the last step, you need to somehow bring up eth0 on boot and set the static IP. I'd go with either
/etc/rc.local
and adding a fewifconfig
commands in there, or using/etc/network/interfaces
and configuring it over there - but you may go as far as to create a static IP NetworkManager config if you so desire.