Linux mobile phones access the internet through USB net

Source: Internet
Author: User
Article title: Linux mobile phones access the internet through usbnet. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Set the IP address and route of the mobile phone:

Configure usbnet ifconfig usb0 1.1.1.2

Configure the Gateway (busybox required): route add default gw 1.1.1.1

Set the DNS of the mobile phone:

1. Linux Mobile Phone: Copy/etc/resolv. conf on the PC to a file with the same name.

2. android phone (replace 192.168.1.1 with the actual DNS ):

Setprop net. eth0.dns1 192.168.1.1

Setprop net. dns1 192.168.1.1

PC end:

Configure usbnet ifconfig usb0 1.1.1.1

Run the following script:

#! /Bin/sh

INTIF = "usb0"

EXTIF = "eth0"

EXTIP = "'/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed-e's /.*://''"

/Sbin/depmod-

/Sbin/modprobe ip_tables

/Sbin/modprobe ip_conntrack

/Sbin/modprobe ip_conntrack_ftp

/Sbin/modprobe ip_conntrack_irc

/Sbin/modprobe iptable_nat

/Sbin/modprobe ip_nat_ftp

Echo "1">/proc/sys/net/ipv4/ip_forward

Echo "1">/proc/sys/net/ipv4/ip_dynaddr

Iptables-P INPUT ACCEPT

Iptables-F INPUT

Iptables-P OUTPUT ACCEPT

Iptables-F OUTPUT

Iptables-P FORWARD DROP

Iptables-F FORWARD

Iptables-t nat-F

Iptables-a forward-I $ EXTIF-o $ INTIF-m state -- state ESTABLISHED, RELATED-j ACCEPT

Iptables-a forward-I $ INTIF-o $ EXTIF-j ACCEPT

Iptables-t nat-a postrouting-o $ EXTIF-j MASQUERADE

Related Article

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.