OpenWrt Forum Archive

Topic: static IP and dynamic PPPoE on WAN interface?

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm using PPPoE to connect to the internet via the WAN port of my ASUS WL-500-GP

/etc/config/network:

#### WAN configuration
config interface    wan
    option ifname    "eth0.1"
    option proto    'pppoe'
    option username    'someusername'
    option password    'somepassword'

However, my modem also has a static IP address and telnet CLI and web interface. You can use this to check DSL line quality, available bandwidth, and other information.

I can connect to the modem via the router by giving eth0.1 a static IP as well:

root@OpenWrt:~# ifconfig eth0.1 192.168.1.42

OpenWrt:~# telnet 192.168.1.254

Entering character mode
Escape character is '^]'.

Username : 
...

I'd like the ip to be automatically assigned to eth0.1 so I don't have to do it manually every time the router reboots. However adding ipaddr and netmask options to the network configuration above, doesn't seem to be doing it. Is it possible to assign a static ip to eth0.1, or is it not actually meant to have one because it's there for PPPoE only?

http://en.wikipedia.org/wiki/Pppoe#How_PPPoE_fits_in

I've never tried this, but is it possible to have multiple interface lines use the same ifname?  Since PPPoE *should* never touch IP, I'd think it might work:

#### WAN configuration
config interface    wan
    option ifname    "eth0.1"
    option proto    'pppoe'
    option username    'someusername'
    option password    'somepassword'

#### WAN_CONFIG configuration
config interface    wan_config
    option ifname    "eth0.1"
    #DHCP or static, whichever makes you happy
    option proto    dhcp

(Last edited by exobyte on 9 Jan 2008, 20:08)

Even if this works, it won't be touched once it's set up. So if you force a re-dial by 'ifdown wan; ifup wan;' only the wan configuration will be restored, not the wan_config and thus the IP will be lost. So I don't think this is the way to go. It's fine if it can't be done. I simply included the ifconfig eth0.1 192.168.1.1 command into my qos-script for now.

frostschutz wrote:

Even if this works, it won't be touched once it's set up. So if you force a re-dial by 'ifdown wan; ifup wan;' only the wan configuration will be restored, not the wan_config and thus the IP will be lost. So I don't think this is the way to go. It's fine if it can't be done. I simply included the ifconfig eth0.1 192.168.1.1 command into my qos-script for now.

Does taking down a pppoe connection on an interface even call ifconfig?  It shouldn't; pppoe is over ethernet (data link layer), and ifconfig only touches the network layer (I think).

On my DG-834 that has a PPPoE connection, I see this from ifconfig:

nas0      Link encap:Ethernet  HWaddr ...
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15151969 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13026517 errors:1578 dropped:0 overruns:1578 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2400834504 (2.2 GiB)  TX bytes:2091339147 (1.9 GiB)

ppp0      Link encap:Point-Point Protocol
          inet addr:...  P-t-P:...  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:15151964 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13028087 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:5
          RX bytes:2279618546 (2.1 GiB)  TX bytes:1674673787 (1.5 GiB)

nas0 is the dsl modem, ppp0 is the pppoe link over it.  If I just do ifconfig, I don't see nas0.

(Last edited by exobyte on 9 Jan 2008, 23:26)

Hmm...  If this doesn't work, it might even be a bug in ifdown

Unfortunately it doesn't work at all. Having two different entries in config/network for the same device eth0.1, they interfere with each other so neither works. If wan_config is up the IP is set correctly but PPPoE is completely unable to connect. If you ifdown ifup wan manually PPPoE connects but the IP is no longer set. Currently the only way that works for me is manually setting the IP using ifconfig eth0.1 192.168.1.42 after the PPPoE connection is online (I put it into my QoS script that gets called via hotplug on a PPP connection).

I don't mind that, except now I want to do 'telnet routerip' from my local network and end up on the telnet server of the modem (192.168.1.254). Doing this from the router directly works, but not from the local network. Which means I also have to manually set up some routes? or port-forwarding rules within the local area network? Unfortunately neither seems to work for me.

Anyone ever tried to access the modem on the WAN port from the LAN?

A direct connection isn't possible, since the WAN port isn't part of the switch, which I guess is a good thing, cause otherwise anyone in the network could fire up PPPoE connections or mess with the modem directly. So it seems that the router has to route / forward the packets somehow, but how?

EDIT:
As a workaround, I'm using SSH port forwarding now, which works well enough.

(Last edited by frostschutz on 29 Jan 2008, 14:27)

I have the same problem. Is there any solution now?

I had the same problem and what I did is make a script that run on startup that does :

 ifconfig eth0.1 192.168.1.2

and it works well.
You also need to add :

iptables -I FORWARD -d 192.168.1.0/24  -j ACCEPT
iptables -I POSTROUTING -t nat -o eth1 -d 192.168.1.0/24 -j MASQUERADE

to your /etc/firewall.user file if you want to be abble to connect to your modem on the 192.168.1.0/24 subnet

Of course you then need

config 'include'
        option 'path' '/etc/firewall.user'

in your /etc/config/firewall file

(Last edited by zorxd on 22 Feb 2011, 16:29)

Hi,

I know this is a bit old now, but I've just run into exactly the same problem ... so here's a proposed fix, it's not perfect but it does the job.

My approach is to add a "secondaryinterface" flag which basically implies that you don't own the underlying interface and therefore shouldn't do anything destructive to it... this is the best option I came up with that was minimal in terms of code changes, but it does have a knock-on effect on things like the interface status page etc.

I'm very new to this, and maybe it's all wrong, so comments appreciated.

Lee.

root@OpenWrt:/jffs# diff /rom/sbin/ifdown /jffs/sbin/ifdown 
--- /rom/sbin/ifdown    Fri Jan 15 21:01:00 2010
+++ /jffs/sbin/ifdown   Mon Jan 18 14:44:04 2010
@@ -54,6 +54,8 @@
 config_get ifname "$cfg" ifname
 config_get device "$cfg" device
 
+config_get secondaryinterface "$cfg" secondaryinterface
+[ -n "$secondaryinterface" ] && device=
 [ ."$device" != ."$ifname" ] || device=
 for dev in $ifname $device; do
        ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
root@OpenWrt:/jffs# diff -wd /rom/lib/network/config.sh /jffs/lib/network/config.sh
--- /rom/lib/network/config.sh  Fri Jan 15 21:01:00 2010
+++ /jffs/lib/network/config.sh Mon Jan 18 14:37:00 2010
@@ -243,6 +243,9 @@
                [ "$?" = 0 ] || return 1
        }
 
+       config_get secondaryinterface "$config" secondaryinterface
+       [ -n "$secondaryinterface" ] || {
+               echo "iface=$iface"
                prepare_interface "$iface" "$config" "$vifmac" || return 0
 
                [ "$iface" = "br-$config" ] && {
@@ -260,6 +263,7 @@
                        config_get macaddr "$config" macaddr
                        [ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
                        $DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up
+               }
        }
        set_interface_ifname "$config" "$iface"

Yep, but I couldn't find a solution. After searching a bit, I found "parent" and "device" options (in /etc/config/network) but they don't work (r19635).

The discussion might have continued from here.