Xubuntu for routing forwarding

Source: Internet
Author: User
Tags iptables

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.