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