找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
楼主: g0g***

求助:K2在 无线接入点 (AP) 模式下自动脚本换LAN网关和DNS;DHCP网关和DNS

[复制链接]
发表于 2019-12-1 21:02 | 显示全部楼层
网关和dns保存在dnsmasq.conf  ,不在resolv.conf

点评

是的。我搞错了。resolv.conf是路由器自身的dns。如果要改dhcp下游的手机,需要改dnsmasq.conf。  详情 回复 发表于 2019-12-2 14:54
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-12-2 14:32 | 显示全部楼层
abovo484 发表于 2019-12-1 20:56
function do_change()            # 命名函数  do_change                        
{
        ping -c 1 ...

感谢您的帮助!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-12-2 14:32 | 显示全部楼层
xxnull 发表于 2019-11-30 17:36
试一下看,不保证好用:

感谢您的帮助!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-2 14:54 | 显示全部楼层
abovo484 发表于 2019-12-1 21:02
网关和dns保存在dnsmasq.conf  ,不在resolv.conf

是的。我搞错了。resolv.conf是路由器自身的dns。如果要改dhcp下游的手机,需要改dnsmasq.conf。

点评

折腾不来,还是太菜了。用route命令更改内网路由192.168.8.0的网段路由的网关,路由卡死。dnsmasq好像可以用命令改,但是参数太多了,搞不懂。另外手动更改dnsmasq.conf配置文件好像不会生效,是否要写入或者读取什  详情 回复 发表于 2019-12-2 21:32
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-2 21:32 | 显示全部楼层
xxnull 发表于 2019-12-2 14:54
是的。我搞错了。resolv.conf是路由器自身的dns。如果要改dhcp下游的手机,需要改dnsmasq.conf。

折腾不来,还是太菜了。用route命令更改内网路由192.168.8.0的网段路由的网关,路由卡死。dnsmasq好像可以用命令改,但是参数太多了,搞不懂。另外手动更改dnsmasq.conf配置文件好像不会生效,是否要写入或者读取什么的?如果方便请指教。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-3 11:26 | 显示全部楼层
试一下这个脚本:

  1. conf_file=/etc/dnsmasq.conf

  2. function do_change()
  3. {
  4.         ping -c 1 192.168.1.252
  5.         if [ $? -ne 0 ]; then
  6.                 cat $conf_file | grep "lan,3,192.168.1.252"
  7.                 if [ $? -ne 0 ]; then
  8.                         return
  9.                 fi
  10.                 logger -p syslog.info "不能ping通改K2..."
  11.                
  12.                 sed -i "s/dhcp-option=tag:lan,3,.*/dhcp-option=tag:lan,3,192.168.1.1/g" $conf_file
  13.                 sed -i "s/dhcp-option=tag:lan,6,.*/dhcp-option=tag:lan,6,180.76.76.76,223.5.5.5/g" $conf_file

  14.         else
  15.                 cat $conf_file | grep "lan,3,192.168.1.252"
  16.                 if [ $? -eq 0 ]; then
  17.                         return
  18.                 fi
  19.                 logger -p syslog.info "重新ping通192.168.1.252..."
  20.                
  21.                 sed -i "s/dhcp-option=tag:lan,3,.*/dhcp-option=tag:lan,3,192.168.1.252/g" $conf_file
  22.                 sed -i "s/dhcp-option=tag:lan,6,.*/dhcp-option=tag:lan,6,192.168.1.252,180.76.76.76,223.5.5.5/g" $conf_file

  23.         fi

  24.         restart_dhcpd   # 重新启动dhcp服务
  25.         radio2_restart  # 重新启动 2.4G WIFI
  26.         radio5_restart  # 重新启动 5G WIFI
  27. }

  28. function do_check()
  29. {
  30.         while [ true ]; do
  31.                 do_change
  32.                 sleep 120
  33.         done
  34. }


  35. do_check &
复制代码
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-3 12:42 | 显示全部楼层
本帖最后由 real 于 2019-12-3 12:44 编辑

刷纯ap固件如极客无线的呢?
N1抽风具体啥表现导致k2做ap失效?

N1的路由能力远远大于k2
应该是N1主路由,K2纯ap才是正道

我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-4 20:25 | 显示全部楼层
[RT-N56U_B1 /home/root]# /etc/storage/gateway.sh
: not founde/gateway.sh: line 1:
: not founde/gateway.sh: line 3:
: not founde/gateway.sh: line 5: {
(192.168.8.2): 56 data bytes

ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss
/etc/storage/gateway.sh: line 41: syntax error: unexpected end of file (expecting "do")
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-4 20:46 | 显示全部楼层
本帖最后由 abovo484 于 2019-12-4 21:06 编辑

把1,3行的空格删除,可以运行到ping,但旁路由开机后,网关没有自动切换。
打开旁路由。网关dnsmasq.conf内网关不会变成旁路由的。手动把dnsmasq.conf内的网关改成旁路由的,关闭旁路由可以变回主路由。期间内部网络 (LAN) - DHCP 服务器界面的网关都没有改变。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-12-4 21:17 | 显示全部楼层
本帖最后由 abovo484 于 2019-12-5 10:33 编辑

手动测试更改dnsmasq.conf的网关为旁路由的ip,关掉旁路由还是可以正常上网,可见设置无效。另外重启路由或者dhcp服务dnsmasq.conf内的网关都会恢复成主路由的。又回到起点了,代码是有效的,但是padavan内dhcp服务运行的机制搞不清楚。多谢xxnull
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2020-3-8 18:05 | 显示全部楼层
懂得人都不帮忙,还得靠自己
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 07:22

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表