1. First need two network card (wireless network card and wired network card can be), take this machine as an example:
Wireless network card (WLAN0), wired network card (eth0)
Set Wlan0 DHCP dynamically acquire Ip,eth0 static IP 192.168.6.1
2. Network cable A connection between the eth0 and the router Wan port (of course, the router also set static IP, set to 192.168.6.3)
3. If you need to enable your PC to forward IP packets, the Linux system itself has the function of IP packet forwarding, but by default is closed, you need to modify the configuration file to start this function, modify the/etc/sysctl.conf file, will Net.ipv4.ip_ Forward=1 the previous comment is removed. Then use the sudo sysctl-p command to make the above changes take effect.
If you need to solve the problem of IP packet forwarding, the next step is to add a routing table so that the forwarding network card and the forwarded network card can communicate, this needs to be done through iptables. Enter the following command in the terminal:
sudo iptables-t nat-a postrouting-o wlan0-j masquerade sudo iptables-a forward-i wlan0-o eth0-m State
--state Related,established-j ACCEPT
sudo iptables-a forward-i wlan0-o eth0-j ACCEPT
The terminals connected to this router are available online.