![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Member
Join Date: Oct 2006
Location: Australia
Posts: 857
|
When networking comes online for a specific group of servers, I need them to try to DHCP, but if that fails I need to set a specific IP address (private net).
How can I do this? Everyone is saying it's not possible, but it's FOSS right, so anything is possible. I'm thinking I might have to write a udev or if-up script? |
|
|
|
| Join OCAU to remove this ad! |
|
|
#2 |
|
48656C6C6F20576F726C6421
Join Date: Jun 2001
Location: At a desk. Distro:Ubuntu
Posts: 7,120
|
...why would you expect DHCP to fail?
__________________
If practice makes perfect, and nobody's perfect, why practice? |
|
|
|
|
|
#3 |
|
Member
Join Date: Mar 2003
Location: Armadale, Melbourne
Posts: 1,663
|
No need. (edit: Whoever told you wasn't possible is talking out their backside).
Here's the way i'd do that. Edit your /etc/network/interfaces file and create a static ip entry for the desired interface with the private network ip address you wish the machine to use assuming a DHCP lease is not obtained like this: Code:
auto eth0 iface eth0 inet static address 10.0.94.254 netmask 255.0.0.0 broadcast 10.255.255.255 network 10.0.0.0 post-up /sbin/dhclient eth0 || true Obviously change the details to match your network and system configuration. Last edited by f3n1x; 1st July 2009 at 11:52 AM. |
|
|
|
|
|
#4 |
|
Member
Join Date: Mar 2003
Location: Armadale, Melbourne
Posts: 1,663
|
Laptop moving between networks where one has a dhcp server and the other has machines configured statically? Some people hate NetworkManager that much.
Last edited by f3n1x; 1st July 2009 at 11:51 AM. |
|
|
|
|
|
#5 |
|
Mental in the Face
Join Date: Apr 2003
Location: Griffith NSW
Posts: 3,933
|
You could also try using something like guessnet:
Code:
Package: guessnet Priority: optional Section: net Installed-Size: 492 Maintainer: Enrico Zini <enrico@debian.org> Architecture: amd64 Version: 0.49-1 Depends: libc6 (>= 2.7-1), libgcc1 (>= 1:4.1.1-21), libiw29 (>= 28+29pre7), libnet1 (>= 1.1.2-1), libpcap0.8 (>= 0.9.3-1), libstdc++6 (>= 4.2.1-4) Suggests: pppoe, waproamd, ifplugd Filename: pool/main/g/guessnet/guessnet_0.49-1_amd64.deb Size: 186516 MD5sum: 51f7c7f1a32c3f0c5ac6910302799496 SHA1: 5f9bcd01ca092f2d642aa6eff8e0e7ebe111ee8e SHA256: e3b074bea69d359d9d5c9487d58e6675df85f2394fb1b53ac6fc8efb53620c03 Description: Guess which LAN a network device is connected to Guessnet is a non-aggressive network detection tool to use when moving a machine among networks which don't necessarily provide DHCP. . Guessnet takes in input a list of candidate network profiles, each of which includes a test description; then it runs all the tests in parallel and prints the name of the profile whose test was the first one to succeed. . Available tests are: * ARP probes to check for known hosts in the network * link beat check, to check if the interface is connected to anything * Wireless lan checks, to look for access points found by waproamd * PPPOE check to see if there is a concentrator accessible via PPPOE * Checks provided by custom arbitrary scripts. . Guessnet can be used in either native mode or "ifupdown mode". In the latter case guessnet integrates nicely with ifupdown as a "mapping script". Enhances: ifupdown Tag: hardware::laptop, implemented-in::c++, interface::commandline, network::scanner, role::program, scope::utility, use::scanning
__________________
SmugMug |
|
|
|
|
|
#6 | |
|
Member
Join Date: Oct 2006
Location: Australia
Posts: 857
|
Quote:
Sorry, major bump as I finally got time to implement this. Firstly, I like your thinking process. I didn't think of doing it that way. However, when I tried to implement it I found it didn't work. Once dhclient tried to bind to an interface, it immediately reset that static IP to 'nothing' and once it failed the DHCP, it assigned 'nothing' to that interface. Any ideas? |
|
|
|
|
|
|
#7 |
|
Mental in the Face
Join Date: Apr 2003
Location: Griffith NSW
Posts: 3,933
|
you probably want to run the dhclient command as a pre-up command
man interfaces: Code:
pre-up command
Run command before bringing the interface up. If this command fails then ifup aborts, refraining from marking the interface as configured, prints an error
message, and exits with status 0. This behavior may change in the future.
__________________
SmugMug |
|
|
|
|
|
#8 |
|
Member
Join Date: Jul 2002
Location: Tasmania
Posts: 4,019
|
You're looking in the wrong config file.
Leave /etc/network/interfaces set to 'dhcp', and let dhclient's logic determine how to configure your interface. Add the following(or similar) block to /etc/dhcp3/dhclient.conf(modified for your network obviously): Code:
timeout 10;
initial-interval 1;
backoff-cutoff 3;
lease {
interface "eth0";
fixed-address 192.168.1.2;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.154;
}
As far as "everyone saying it's not possible"... uh, who's everyone? They should be sacked for a lack of thoroughness when it comes to finding solutions to pretty trivial problems
__________________
OCAU MetaL Club Member #666 | last.fm 2005: Megadeth | 2006: Opeth | 2007: Blind Guardian, Sodom | 2008: Iron Maiden | 2009: Pain of Salvation, Dream Theater 2010: Ensiferum, Sonata Arctica, Wolves in the Throne Room |
|
|
|
![]() |
| Bookmarks |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|