linux出口ip命令,linux sh 如何根据出口网关来获取本机出口ip

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

测试机器:华为P7-L07

安卓测试环境:EMUI 3.1 安卓5.1.1(版本号:P7-L07C01B851,基带版本:23.600.06.00.00,内核版本:3.0.8-00533-gdc91976 android@localhost #2 Sat Oct 10 16:06:36 CST 2015) ROOT chroot容器挂载Debain 8 Jessie与安卓并行运行,在Linux Deploy里设置Linux对内置和外载SD卡的完全访问

安卓ROOT过程:先用kingroot获得ROOT权限再在制作机器系统镜像后传至电脑上用winHEX抓取机器解锁码进行BootLoader解锁然后再刷第三方TWRP RECOVERY再把Kingroot卸载掉然后再在TWRP里刷superSU安装包以获得纯净ROOT管理

Linux测试环境:Debain 8 Jessie 加 Busybox 加 安卓系统里运行的“hin2n”APP 加 其它软件……(部分详情请看实验部分)

实验:

root@localhost:/storage/sdcard1# ip r

default via 10.4.131.1 dev wlan0 metric 305

10.0.2.0/24 dev tun0 proto kernel scope link src 10.0.2.9

10.4.131.0/24 dev wlan0 proto kernel scope link src 10.4.131.228 metric 305

10.8.0.0/24 dev tun1 proto kernel scope link src 10.8.0.1

root@localhost:/storage/sdcard1# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

default 10.4.131.1 0.0.0.0 UG 305 0 0 wlan0

10.0.2.0 * 255.255.255.0 U 0 0 0 tun0

10.4.131.0 * 255.255.255.0 U 305 0 0 wlan0

10.8.0.0 * 255.255.255.0 U 0 0 0 tun1

root@localhost:/storage/sdcard1# ifconfig

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:25776 errors:0 dropped:0 overruns:0 frame:0

TX packets:25776 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:1803914 (1.7 MiB) TX bytes:1803914 (1.7 MiB)

tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

inet addr:10.0.2.9 P-t-P:10.0.2.9 Mask:255.255.255.0

UP POINTOPOINT RUNNING MTU:1400 Metric:1

RX packets:13665 errors:0 dropped:0 overruns:0 frame:0

TX packets:12857 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:500

RX bytes:887658 (866.8 KiB) TX bytes:784802 (766.4 KiB)

tun1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

inet addr:10.8.0.1 P-t-P:10.8.0.1 Mask:255.255.255.0

UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:100

RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

wlan0 Link encap:Ethernet HWaddr **:**:**:**:**:**

inet addr:10.4.131.228 Bcast:10.4.131.255 Mask:255.255.255.0

inet6 addr: fe80::**********/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1400 Metric:1

RX packets:211696 errors:0 dropped:82 overruns:0 frame:0

TX packets:337241 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:27209237 (25.9 MiB) TX bytes:29321849 (27.9 MiB)

root@localhost:/storage/sdcard1# ifconfig `ip r | sed -nr '/default/{s#.*dev\s*([^ \t]*)\s*.*#\1#p}'` | grep "inet addr:" | awk '{print $2}' | cut -c 6-

10.4.131.228

root@localhost:/storage/sdcard1#uname -a

Linux localhost 3.0.8-00533-gdc91976 #2 SMP PREEMPT Sat Oct 10 16:06:36 CST 2015 armv7l GNU/Linux

root@localhost:/storage/sdcard1# cat /proc/version

Linux version 3.0.8-00533-gdc91976 (android@localhost) (gcc version 4.7 (GCC) ) #2 SMP PREEMPT Sat Oct 10 16:06:36 CST 2015

root@localhost:/storage/sdcard1# busybox

BusyBox v1.22.1 (Debian 1:1.22.0-9+deb8u1) multi-call binary.

BusyBox is copyrighted by many authors between 1998-2012.

Licensed under GPLv2. See source distribution for detailed

copyright notices.

Usage: busybox [function [arguments]...]

or: busybox --list[-full]

or: busybox --install [-s] [DIR]

or: function [arguments]...

BusyBox is a multi-call binary that combines many common Unix

utilities into a single executable. Most people will create a

link to busybox for each function they wish to use and BusyBox

will act like whatever it was invoked as.

Currently defined functions:

[, [[, acpid, adjtimex, ar, arp, arping, ash, awk, basename, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chgrp,

chmod, chown, chroot, chvt, clear, cmp, cp, cpio, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, df, diff,

dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo, egrep, env, expand, expr, false, fgrep, find,

fold, free, freeramdisk, fstrim, ftpget, ftpput, getopt, getty, grep, groups, gunzip, gzip, halt, head, hexdump, hostid,

hostname, httpd, hwclock, id, ifconfig, init, insmod, ionice, ip, ipcalc, kill, killall, klogd, last, less, ln, loadfont,

loadkmap, logger, login, logname, logread, losetup, ls, lsmod, lzcat, lzma, lzop, lzopcat, md5sum, mdev, microcom, mkdir,

mkfifo, mknod, mkswap, mktemp, modinfo, modprobe, more, mount, mt, mv, nameif, nc, netstat, nslookup, od, openvt, patch,

pidof, ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, readlink, realpath, reboot, renice, reset, rev, rm,

rmdir, rmmod, route, rpm, rpm2cpio, run-parts, sed, seq, setkeycodes, setsid, sh, sha1sum, sha256sum, sha512sum, sleep,

sort, start-stop-daemon, stat, strings, stty, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar,

taskset, tee, telnet, test, tftp, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, udhcpc, udhcpd,

umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode,

vconfig, vi, watch, watchdog, wc, wget, which, who, whoami, xargs, xz, xzcat, yes, zcat

root@localhost:/storage/sdcard1#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值