基于iptable软路由设置
来源:互联网 发布:网站流量数据分析 编辑:程序博客网 时间:2024/05/18 19:43
1.使用到的iptable命令:
清除防火墙规则
iptables -F
iptables -F -t nat
查询防火墙规则
iptables -L
iptables -L -t nat
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth5 -j MASQUERADE
2.Ubuntu环境下搭建
首先开启两个网卡(桥接),一个接电脑的有线(eth2),一个接电脑的无线网卡(eth5)。使用eth2作为lan口,eth5作为wan口。
设置eth2 ip 192.168.4.1路由地址,去除网关。
设置eth5 ip ---可连接外网ip地址,添加网关如:
route add default gw 192.168.1.1 dev eth5
设置转发命令
#echo 1 >> /proc/sys/net/ipv4/ip_forward
设置iptable命令
iptables -F
iptables -F -t nat
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o eth5 -j MASQUERADE
这样将电脑的有线口接到交换机口,其他机器接到交换机都可以上网。
3.安卓机器
使用4G网卡ppp0作为wan口,有线eth0作为lan口,eth0设置ip为
busybox ifconfig eth0 192.168.4.1 不要设置网关。
4G网关和ip自动设置。
设置转发命令
#echo 1 >> /proc/sys/net/ipv4/ip_forward
设置iptable命令
iptables -F -t nat ;iptables -F; iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
5.连接路由的客户端网络参数获取:
静态IP设置模式
虚拟机设置一个ip如:桥接到有线网卡中,与安卓机器eth0用同一个交换机
ifconfig eth5 192.168.4.102 ;route del default; route add default gw 192.168.4.1 dev eth5
同时虚拟机也需要设置一下DNS,用getprop命令查看安卓系统dns,然后将该DNS设置到虚拟机中(Ubuntu)。
动态IP设置模式
Dhcp服务器
使用busybox本身的dhcp功能,从busybox-1.16.1\examples\udhcp目录中获取到
udhcpd.conf修改内容:
start 192.168.4.20
end 192.168.4.254
opt dns 210.21.4.130 221.5.88.88
option subnet 255.255.255.0
opt router 192.168.4.1
#opt wins 192.168.10.10
#option dns 129.219.13.81 # appened to above DNS servers for a total of 3
option domain local
option lease 864000 # 10 days of seconds
放入安卓系统中(/etc),执行启动服务器命令:
busybox udhcpd -fS /etc/udhcpd.conf &
对于iptable的详细介绍请点击点击打开链接
- 基于iptable软路由设置
- Iptable----编写软路由路由防火墙
- 基于HashSet 实现 IpTable
- 基于BitMap 实现IpTable
- iptable设置NAT
- linux iptable设置
- iptable端口映射设置
- iptable 设置 ubuntu
- iptable一些常见设置
- raw表 IPTABLE 和 路由的关系
- 基于Attribute的Web API路由设置
- 基于Attribute的Web API路由设置
- iptable设置端口重定向
- IPTable
- iptable
- iptable
- iptable
- iptable
- unity3d : failed to initialize unity graphics
- linux下的多线程下载工具 axel
- spring和mybatis整合02
- 直接插入排序
- 通用大型网站页面静态化解决方案
- 基于iptable软路由设置
- POJ 3461 Oulipo
- docker 容器固定ip
- eclipse项目中有红色感叹号
- 用 python 抓取网页中的动态数据
- 新手引导 字幕效果
- Revit开发之改变双击事件
- Java 数据库连接池、线程池和对象池总结
- python下使用epoll