Weird static ip setup doesn't work

My Ubuntu machine can reach internet using the configuration below(valid ipv4 address,/32 netmask, private ipv4 gateway) :
root@workstation:~# cat /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens3
iface ens3 inet static
address 5.x.xx.xx
netmask 255.255.255.255
gateway 10.0.0.1
hwaddress ether xx:xx:xx:xx:xx:xx
dns-nameservers 8.8.8.8 8.8.4.4

Same config on OpenWrt doesn’t work :



config interface 'wan' 
       option device 'eth0' 
       option proto 'static' 
       option ipaddr '5.x.xx.xx' 
       option netmask '255.255.255.255' 
       option gateway '10.0.0.1' 
       list dns '8.8.8.8' 

That isn’t generally a valid configuration. What is the goal?

Does your isp provide you with a static ip that is supposed to be configured as static (many are configured with dhcp and the isp provides a static dhcp reservation)?

1 Like

this is the exact network configuration I’m given. everything works on an ubuntu machine.

Typically the gateway must be in the same subnet as the address. So this looks like a situation where there is an rfc1918 transport address for a static ip. I’m not familiar with configuring this scenario but I suspect that it also would not work on most other router environments without other elements.

Hopefully someone who has done this type of config can chime in about how to achieve this goal.

2 Likes

Please show the output from Ubuntu machine:

ip r
ip l show ens3
1 Like

1 Like

Please avoid using pictures.

I know that should work somehow but cannot test this at the moment.
Try ip link set dev eth0 arp off in OpenWrt.
The second thing to try is to replace 10.0.0.1 with 0.0.0.0

did not work, tested with 10.0.0.1 and 0.0.0.0 as gateway.

Is there any kind of authentication in place? Did you register your MAC address perhaps?
What's the access technology? Do you have just a dedicated ethernet cable or something else?

That Ubuntu machine has been extremely altered.

The OP is (claiming to be) successfully sending packets as 5.x.x.x via 10.0.0.1. They also noted they were given this [assumed working] configuration.

OpenWrt allows interfaces to be addressed as a /32. But the user, in addition to an old and altered version of Ubuntu, it seems the configuration is OK with that. I surmise that has to do with the possibility routing is enabled on this device.

Anyways, the user can configure 10.0.0.2/30 (keeping 10.0.0.1 as their gateway), and add 5.x.x.x/32 as an additional IP. They can Source NAT all IPs. :thinking:

it is a virtual environment and you can apply this configuration on any linux iso image you might boot. tested on ubuntu can test on other distros as well.

1 Like

My guess that this 10.0.0.1 is a dummy address, I also remember seeing in this place something like 100.64.0.1 and even 1.1.1.1 years ago, but all that was real, not virtual.
So with 0.0.0.0 as a gateway we change to interface based routing, so ip r shows just an interface as a default gateway and OpenWrt should be happy with that. I'm probably missing something with this virtual environment.

1 Like

unlike ubuntu, ip r doesn’t show any default gateway on openwrt, given my /etc/config/network

unlike ubuntu, ip r doesn’t show any default gateway on openwrt, given my /etc/config/network

yes

What if you add it with ip r add default dev eth0 ?

this worked, but Idk how it translates in openwrt :

ip route add 10.0.0.1/32 dev eth0
ip route add default via 10.0.0.1 dev eth0

1 Like

option gateway '0.0.0.0' is the equivalent of ip r add default dev eth0, make sure you restart network or reboot after making a change.

2 Likes

a

config route
  option interface 'wan'
  option target '10.0.0.1/32'

alongside

config interface 'wan' 
       option device 'eth0' 
       option proto 'static' 
       option ipaddr '5.x.xx.xx' 
       option netmask '255.255.255.255' 
       option gateway '10.0.0.1' 
       list dns '8.8.8.8' 

did the trick. thank you everyone.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.