Search This Blog

Sunday, December 25, 2011

verizon router dhcp getting a fixed IP address

I am currently using Verizon DSL to connect to the internet. So, I have

laptop -> router -> internet

A minor irritation with this set up is that the router can potentially assign different IP addresses whenever I do a reboot or something akin to /etc/init.d/networking restart. For example today it can be 192.168.1.58, tomorrow it could be 192.168.1.68 etc.,

I currently have

$ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:c5:19:9c:1a
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:17

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6790 errors:0 dropped:0 overruns:0 frame:0
TX packets:6790 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:773105 (754.9 KiB) TX bytes:773105 (754.9 KiB)

wlan0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b
inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::213:2ff:fe9e:cc1b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7486622 errors:0 dropped:0 overruns:0 frame:0
TX packets:4833561 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2650697959 (2.4 GiB) TX bytes:608573891 (580.3 MiB)

To have the same IP address, say 192.168.1.78, every time the computer is booted

1) Add the following lines to /etc/dhcp/dhclient.conf

alias {
interface "wlan0";
fixed-address 192.168.1.78;
option subnet-mask 255.255.255.255;
}

2) restart the network

sudo /etc/init.d/networking restart

Now you should see

$ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:c5:19:9c:1a
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:17

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6790 errors:0 dropped:0 overruns:0 frame:0
TX packets:6790 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:773105 (754.9 KiB) TX bytes:773105 (754.9 KiB)

wlan0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b
inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::213:2ff:fe9e:cc1b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7486678 errors:0 dropped:0 overruns:0 frame:0
TX packets:4833604 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2650705479 (2.4 GiB) TX bytes:608589238 (580.3 MiB)

wlan0:0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b
inet addr:192.168.1.78 Bcast:0.0.0.0 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Note the new wlan:0 interface which is always assigned to 192.168.1.78.

Followers