On Apr 4, 2013, at 11:41 AM, udita gangwal wrote: > I want to run a DHCP server in the POX controller. The controller has to be > able to capture all the DHCP requests that come in so that the DHCP server > can lease out an IP address to each host. ... > ./pox.py openflow.of_01 --address=192.168.56.1 forwarding.l2_learning > flow_stats misc.dhcpd --network=10.1.1.0/24 --ip=10.0.0.4 --first=10 > --last=None > > where, 192.168.56.1 is the IP address of the Mininet VM, flow-stats is the > module to display the flow table entries in the controller fetched from the > OF Switch. 10.0.0.4 is the IP address of one of the Mininet hosts. > > In one of the Mininet hosts (IP_addr = 10.0.0.2, MAC_addr = > 00:00:00:00:00:02), when I run the dhclient with the following command: > > sudo dhclient h2-eth0 , > > whr, h2-eth0 is the name of its interface, I can see the following message in > the POX controller: > > INFO:misc.dhcpd:Leased 10.1.1.10 to 00:00:00:00:00:02 > > But now, when I do an ifconfig in the host, it still gives me the old IP > address, 10.0.0.2. > > > Can someone please point out where the mistake is and what exactly should it > be done?
I think there's no mistake and everything is running fine. Check out the following: mininet> h1 dhclient -v Internet Systems Consortium DHCP Client 4.2.4 Copyright 2004-2012 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/h1-eth0/00:00:00:00:00:01 Sending on LPF/h1-eth0/00:00:00:00:00:01 Sending on Socket/fallback DHCPREQUEST of 10.2.2.1 on h1-eth0 to 255.255.255.255 port 67 DHCPACK of 10.2.2.1 from 192.168.0.254 bound to 10.2.2.1 -- renewal in 1543 seconds. mininet> h1 ifconfig h1-eth0 h1-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:01 inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::200:ff:fe00:1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:28 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2614 (2.6 KB) TX bytes:900 (900.0 B) mininet> h2 dhclient -v Internet Systems Consortium DHCP Client 4.2.4 Copyright 2004-2012 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/h2-eth0/00:00:00:00:00:02 Sending on LPF/h2-eth0/00:00:00:00:00:02 Sending on Socket/fallback DHCPREQUEST of 10.2.2.2 on h2-eth0 to 255.255.255.255 port 67 DHCPACK of 10.2.2.2 from 192.168.0.254 bound to 10.2.2.2 -- renewal in 1434 seconds. mininet> h2 ifconfig h2-eth0 h2-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:02 inet addr:10.0.0.2 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::200:ff:fe00:2/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:28 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2878 (2.8 KB) TX bytes:900 (900.0 B) mininet> h1 ping 10.2.2.2 PING 10.2.2.2 (10.2.2.2) 56(84) bytes of data. 64 bytes from 10.2.2.2: icmp_req=1 ttl=64 time=63.2 ms 64 bytes from 10.2.2.2: icmp_req=2 ttl=64 time=0.313 ms 64 bytes from 10.2.2.2: icmp_req=3 ttl=64 time=0.172 ms 64 bytes from 10.2.2.2: icmp_req=4 ttl=64 time=0.058 ms ^C --- 10.2.2.2 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3000ms rtt min/avg/max/mdev = 0.058/15.939/63.214/27.294 ms mininet> h2 ifconfig h2-eth0 h2-eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:02 inet addr:10.0.0.2 Bcast:10.255.255.255 Mask:255.0.0.0 inet6 addr: fe80::200:ff:fe00:2/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:34 errors:0 dropped:0 overruns:0 frame:0 TX packets:14 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3354 (3.3 KB) TX bytes:1376 (1.3 KB) Note that dhclient -v shows that it gets the correct assignment, and that pinging works even though ifconfig still shows the old addresses. Also notice that if you manually use ifconfig to set some new address ("h1 ifconfig h1-eth0 1.2.3.4"), another run of ifconfig will now show the address with 10.2.2.1! And after setting another address ("h1 ifconfig h1-eth0 5.6.7.8"), ifconfig will now show 1.2.3.4! So what's going on? The answer is that two IP addresses are being assigned to the interface, but ifconfig only shows one of them. If you use "h1 ip addr", you'll see both of them. It's for reasons like this that ifconfig is (sort of? entirely?) deprecated. In the past, I haven't seen this two-address behavior with dhclient... I suspect something must have changed in the default configuration of Ubuntu 12.10 or something like that. Hope that helps. -- Murphy
