热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

树莓派4B+Debian10单臂路由:光猫改桥接后PPPoE自动拨号配置

网卡配置etcnetworkinterfaces.deth0autoeth0allow-hotplugeth0ifaceeth0inetstaticaddress10.5.6

  1. 网卡配置
    /etc/network/interfaces.d/eth0

    auto eth0
    allow-hotplug eth0
    iface eth0 inet static
    address 10.5.6.1
    netmask 255.255.255.0auto wan
    allow-hotplug wan
    iface wan inet ppp
    post-up /usr/sbin/iptables -t nat -A POSTROUTING -o wan -j MASQUERADE
    post-up /usr/sbin/iptables -t filter -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
    post-down /usr/sbin/iptables -t nat -D POSTROUTING -o wan -j MASQUERADE
    post-down /usr/sbin/iptables -t filter -D FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

  2. PPPoE 配置
    /etc/ppp/peers/provider

    ifname wan
    noipdefault
    defaultroute
    connect /bin/true
    noauth
    persist
    noaccomp
    default-asyncmap
    plugin rp-pppoe.so eth0
    user "user"
    lcp-echo-failure 20
    lcp-echo-interval 30

  3. PPPoE 帐号配置
    /etc/ppp/pap-secrets

    # * password
    "user" * "password"

  4. DHCP 配置
    /etc/dnsmasq.conf

    interface=eth0
    listen-address=127.0.0.1,10.5.6.1
    dhcp-range=10.5.6.100,10.5.6.200,48h

  5. 访问光猫

    # 启用
    $ sudo ifconfig eth0:0 10.5.5.2 netmask 255.255.255.0
    $ sudo iptables -t nat -A POSTROUTING -o eth0 -d 10.5.5.0/24 -j MASQUERADE
    $ sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.5.5.1:80
    # 关闭
    $ sudo ifconfig eth0:0 down
    $ sudo iptables -t nat -D POSTROUTING -o eth0 -d 10.5.5.0/24 -j MASQUERADE
    $ sudo iptables -t nat -D PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.5.5.1:80


推荐阅读
author-avatar
的士风云
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有