Linux mobile phones access the internet through USB net

Source: Internet
Author: User

Linux mobile phones access the internet through USB net

Indicate the source and author's contact information during reprinting.
Source:
Http://www.limodev.cn/blog
Contact information of the author: Li xianjing <xianjimli at hotmail dot com>

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

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.