3

I have a USB wireless adapter which is eth1. When it is plugged in it automatically gets an IP address of 192.168.8.100/24 and routes automatically added:

ip a output:

39: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 0c:5b:8f:27:9a:64 brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.100/24 brd 192.168.8.255 scope global dynamic noprefixroute eth1
       valid_lft 85920sec preferred_lft 85920sec
    inet6 fe80::640:311a:de17:1163/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

ip route output:

default via 192.168.8.1 dev eth1 proto dhcp metric 100
192.168.8.0/24 dev eth1 proto kernel scope link src 192.168.8.100 metric 100

The Internet is accessible, but if I change the IP address to 192.168.2.100/24 and add routes which are identical to the ones added, but with the new IP address and a higher metric, it doesn't work:

ip address del 192.168.8.100/24 dev eth1
ip address add 192.168.2.100/24 dev eth1
ip route add default via 192.168.2.1 dev eth1 proto static metric 99

So now the interface and routes look like this:

ip a output:

39: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 0c:5b:8f:27:9a:64 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.100/24 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::640:311a:de17:1163/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

ip route output:

default via 192.168.2.1 dev eth1 proto static metric 99
default via 192.168.8.1 dev eth1 proto dhcp metric 100
192.168.2.0/24 dev eth1 proto kernel scope link src 192.168.2.100
192.168.8.0/24 dev eth1 proto kernel scope link src 192.168.8.100 metric 100

Why does it not work?

  • 2
    Does 192.168.2.1 even exist? – Rui F Ribeiro Jan 13 at 16:01
  • maybe not actually. When the internet works, the active default route is the 192.168.8.1 one. Does this mean that the usb device is 192.168.2.100, but the router on the device is 192.168.2.1? (I'm a networking novice, sorry if this is a silly question) – Jonny Shanahan Jan 13 at 18:34
  • If you make up addresses out of thin air, they wont be routed or even have a way of talking, or even known by the Wifi router. Much like your mobile network operator giving you a 92xxxxxx mobile number, and you hacking your mobile telephone to have the number 94xxxxxx. It wont be recognized, and wont be routed in the infra-structure. – Rui F Ribeiro Jan 13 at 18:38
4

If 192.168.2.1 is not set up in the access point side, obviously routing won't work. If the Wi-Fi access point/router is only configured in the 192.168.8.x network, it will only accept doing the routing of IP addresses of the 192.168.8.x network.

(The reminder of the answer was written supposing an alternate scenario where routing is set up properly.)

The question is assuming an authenticated Wi-Fi medium does behave as your regular shared Ethernet medium by default; it does not.

In an authenticated Wi-Fi network, basically, in simple terms, you can think it emulates an Ethernet shared medium after you authenticate, for security sake. Basically, after authentication you are given an IP address that might be tied to the authentication (depending on several factors).

If you do change that IP address, the association might be lost, and you have to (re)start the Wi-Fi authentication process all over again.

There also might be firewalling rules in place that prevent you from the clients changing for another network.

PS: For more advanced users, both Wi-Fi and Ethernet can have authenticated or non-authenticated setups. I am just trying to lay it down in simple terms for the benefit of the OP.

  • 2
    @roaima i said I was simplifying it...there are tables that correlate IP address->authenticated password/user, obviously after getting an IP address via DHCP. The phenomenon is more visible/enforced when using 802.1X. But typically, due to those tables, wifi communications are not so happy about sudden IP addresses changes. Then there are arp ta bles, but they are short lived... You can also define static ranges, and it is possible to change IP addresses. It is just that the rules are not as relaxed as in a medium without authentication. – Rui F Ribeiro Jan 13 at 15:34
  • @roaima TLDR It might be possible to change IP addresses, depending on the configuration of the wireless infra-structure and vendor, it is just the rules are more enforced, and the possibility of it going wrong greater. – Rui F Ribeiro Jan 13 at 15:38
  • 1
    @roaima In fact, in 802.1X the association does not go up until after the process is all complete (i.e. after you get the IP address. Also, in most modern OSes (read Mac, iOS, Android), the interface does not go up after you get an IP address and some URLs are tested with success, for better or worse. That process might have problems with ARP caching – Rui F Ribeiro Jan 13 at 15:40
  • Thanks. How can I assign an static ip to this interface then? I have tried adding static ip to eth1 (the interface name for the usb adaptor) in /etc/network/interfaces. – Jonny Shanahan Jan 13 at 15:46
  • if at home, define a static IP address range in your wifi router and stick to it (or define your wifi MAC address gets a static IP address) If in an University/corporate setting with 802.1X, ask the local network help desk team for a static IP address associated to your user/MAC address. – Rui F Ribeiro Jan 13 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.