dhcpclient for all the eth* which has no ip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting dhcpclient for all the eth* which has no ip
# 1  
Old 09-12-2012
dhcpclient for all the eth* which has no ip

I want to run dhcpclient for all the eth* which has no ip

for example

Code:
eth0      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EF  
          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)
          Memory:d1900000-d1920000 
 
eth1      Link encap:Ethernet  HWaddr 00:1B:21:3F:BF:28  
          inet addr:192.85.1.1  Bcast:192.85.255.255  Mask:255.255.0.0
          inet6 addr: fe80::21b:21ff:fe3f:bf28/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:5126 (5.0 KiB)
 
eth2      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EE  
          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)
          Memory:d1920000-d1940000

I want dhclient eth0, dhclient eth2 becasue they have no ip, any help, I haven't a good way to do this, better to use less codes

---------- Post updated at 08:05 AM ---------- Previous update was at 03:55 AM ----------

Any help?

Last edited by yanglei_fage; 09-12-2012 at 10:06 AM..
# 2  
Old 09-12-2012
Moderator's Comments:
Mod Comment Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.


What is your system?
# 3  
Old 09-12-2012
Linux
# 4  
Old 09-13-2012
Try using something like...
Code:
$ cat file1
eth0      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EF
          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)
          Memory:d1900000-d1920000

eth1      Link encap:Ethernet  HWaddr 00:1B:21:3F:BF:28
          inet addr:192.85.1.1  Bcast:192.85.255.255  Mask:255.255.0.0
          inet6 addr: fe80::21b:21ff:fe3f:bf28/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:5126 (5.0 KiB)

eth2      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EE
          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)
          Memory:d1920000-d1940000

$ awk '/^eth/{e[++c]=$1}/inet addr/{a[c]=$2}END{for(i=1;i<=c;i++)if(!a[i])print e[i]}' file1
eth0
eth2

$

# 5  
Old 09-13-2012
Quote:
Originally Posted by Ygor
Try using something like...
Code:
$ cat file1
eth0      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EF
          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)
          Memory:d1900000-d1920000
 
eth1      Link encap:Ethernet  HWaddr 00:1B:21:3F:BF:28
          inet addr:192.85.1.1  Bcast:192.85.255.255  Mask:255.255.0.0
          inet6 addr: fe80::21b:21ff:fe3f:bf28/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:5126 (5.0 KiB)
 
eth2      Link encap:Ethernet  HWaddr 00:1E:67:3E:BA:EE
          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)
          Memory:d1920000-d1940000
 
$ awk '/^eth/{e[++c]=$1}/inet addr/{a[c]=$2}END{for(i=1;i<=c;i++)if(!a[i])print e[i]}' file1
eth0
eth2
 
$


Hi thanks for the help, this is the first time I see this awk usage
'/**/***/***/'
# 6  
Old 09-13-2012
Quote:
Originally Posted by yanglei_fage
Linux
Linux what? Ubuntu? Centos? RHEL? Fedora? Arch? Gentoo? SuSe? Other? They share the kernel in common but that doesn't make them the same...
# 7  
Old 09-13-2012
Quote:
Originally Posted by Corona688
Linux what? Ubuntu? Centos? RHEL? Fedora? Arch? Gentoo? SuSe? Other? They share the kernel in common but that doesn't make them the same...
ubuntu, I think it's srcipt's job, so I don't mention more about this Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

RedHat eth interfaces not seem to be present

Dear community, I'm in trouble with Red Hat Server 5.8. After rebooting the server, I loose two interfaces used for bond2 (eth4 and eth5). I reboot twice the server but the result is always: # service network restart Shutting down interface bond0: Shutting down... (1 Reply)
Discussion started by: Lord Spectre
1 Replies

2. Red Hat

ifconfig eth - errors after certain packets received

Hi, I am facing an issue with one of the 10G fiber link. After certain packets received. I am seeing errors in ifconfig eth* output. MTU is set to 9000. any idea? (1 Reply)
Discussion started by: snchaudhari2
1 Replies

3. UNIX for Dummies Questions & Answers

Traffic moves to another eth

hi guys I have a server which has 2 nics eth0 and eth1 eth0 is used for our email traffic server. everything working fine some time later a eth1 was added for backup purposes so this new nic sends data to another vlan for backup purposes all of a sudden our mail server starts to fail... (3 Replies)
Discussion started by: karlochacon
3 Replies

4. Red Hat

Find out which eth or device belongs to interface "port 1 PCI 4"

Hi, I´ve given only this info to configure a network interface : "port 1 PCI 4" I´ve been searching for any kind of relationship in the system which allow me to find the etc that must be configured... Please, could anybody help me? rhxx:#/root# lspci |grep -i "PCI BRIDGE" 00:01.0 PCI... (0 Replies)
Discussion started by: pabloli150
0 Replies

5. IP Networking

Eth interfaces UP but NOT RUNNING

Hi people, I have a solaris OS system. I configured its interfaces. They are UP but not in RUNNING status except loopback interface. I made the interfaces DOWN and UP again. The other side of the interfaces (switch ports) are UP. Does anyone have any idea? What may cause this problem, How can I... (1 Reply)
Discussion started by: hubatuwang
1 Replies

6. IP Networking

Socket and interface (eth0, eth 1)relationship

hi, Could some one answer this please we have a program with client socket declared which connect to a server for the above program description we wont send an interface information ... let us suppose, I have two interfaces (eth0 , eth1) which are assigned some ip, which interface the... (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

7. UNIX for Dummies Questions & Answers

NIC and eth connection

folks; This might sounds stupid but i hope someone can give me an answer: On my Linux SUSE boxes, i have 2 NIC cards NIC1 & NIC2. I always assumed that NIC1 is eth0 when i run "ifconfig" and NIC2 is eth1 but i noticed that's not always the case. Is there a way or a command i can run to find... (1 Reply)
Discussion started by: Katkota
1 Replies

8. Linux

Renaming eth interfaces

Hi I had a DL380 with two two port eth cards. I now replaced one with a four port eth card and my interfaces seemed to have jumped around. Is there a method of moving eth ports... eg making port eth4 eth2.:confused: (2 Replies)
Discussion started by: theroncj
2 Replies

9. UNIX for Advanced & Expert Users

Eth err: "3c501 device eth0 does not seem to be present"

HI, When I do 'service network restart' , I am getting the following error. "3c501 device eth0 does not seem to be present, delaying initialization" Can any one suggest me the cause/solution for this? When I do 'lspci' it is showing the ehternet card as " Ethernet controller"Marvell... (2 Replies)
Discussion started by: praveen_b744
2 Replies
Login or Register to Ask a Question