Linux 创建虚拟网卡¶
Ubuntu 安装tunctl 命令:
确认内核是否加载run 模块
modinfo tun
方式一:通过tunctl创建虚拟网卡以及设置

方式二:通过ip tuntap 创建虚拟网卡以及设置
# ip help
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |
netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |
vrf | sr }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-h[uman-readable] | -iec |
-f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |
-4 | -6 | -I | -D | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } | -br[ief] |
-o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] |
-rc[vbuf] [size] | -n[etns] name | -a[ll] | -c[olor]}
# ip tuntap help
Usage: ip tuntap { add | del } [ dev PHYS_DEV ]
[ mode { tun | tap } ] [ user USER ] [ group GROUP ]
[ one_queue ] [ pi ] [ vnet_hdr ]
Where: USER := { STRING | NUMBER }
GROUP := { STRING | NUMBER }

tunctl 安装和源码编译:
在线安装:
源码安装:
git clone https://github.com/gooselinux/tunctl.git
cd tunctl
## 假如需要交叉编译,修改export CC=XXXXX 编译器
############################
## 静态编译的话,Makefile 中添加
## $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(BIN).c
## make LDFLAGS="-static"
############################
make
./tunctl --help
运行: