1

I have a Centos server and I have a problem with automatic detection of cable connection.
Whenever server is up before router has started i need to restart server to make it detect IP.

For Example:
- I bootup server.
- No network is connected (cable unplugged or router down),
- Start router or plug in cable.
- Connection is not detected. Server needs a restart.

How to configure (console) server to watch for cable plug-in event?

Ifconfig output:

eth0      Link encap:Ethernet  HWaddr 00:14:85:EE:7D:D9
          inet addr:192.168.1.15  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::214:85ff:feee:7dd9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:33127 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37421 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6348000 (6.0 MiB)  TX bytes:33946404 (32.3 MiB)

cat /etc/sysconfig/network-scripts/ifcfg-eth0 output:

# Intel Corporation 82801EB/ER (ICH5/ICH5R) integrated LAN Controller
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:14:85:ee:7d:d9

chkconfig (I use level 3):

/sbin/chkconfig --list network
network         0:off     1:off     2:On      3:On      4:On      5:On      6:off
/sbin/chkconfig --list NetworkManager
NetworkManager  0:off     1:off     2:off     3:off     4:off     5:off     6:off
  • What version of CentOS do you have? – ojs Nov 16 '15 at 23:19
  • Does your /etc/sysconfig/network-scripts/<interface> contain the following: onboot=yes and bootproto=static, I am assuming here that since this is a server that your using a static IP and not DHCP (else bootproto should be equal to dhcp). You can compare your setup to the one provided here. – ojs Nov 16 '15 at 23:40
  • Centos is 5.10. Router > local static IP (it's dev server) bootproto=dhcp and onboot=yes – Gacek Nov 16 '15 at 23:43
  • So you have a server that is assigned and ip address with DHCP, that is ... uhh, special :-) Check out the answer to this question. See if anything there helps you out. Note that information to these commands are only relevant to you while the network cable is connected and no network is showing up (so you need physical access to it). – ojs Nov 16 '15 at 23:59
  • If you only have access to the server through ssh, can you be sure that it is always getting the 192.168.1.15 address assigned to it with DHCP? – ojs Nov 17 '15 at 0:03
1

This seems to be exactly what NetworkManager was designed for.

Make sure NetworkManager is installed and the service running and stop the old network service.

By the way even with the network service rebooting is not necessary. A restart of that service should trigger a new dhcp request. But NetworkManager should do that automatically when it detects the cable is plugged in.

  • It's only remote management server. No keyboard nor mouse nor monitor. So only restart is what's left as I can't login via SSH to it if interface is down. going to test it now. – Gacek Nov 16 '15 at 23:40
  • NetworkManager-0.7.0-13.el5.i386 already installed and latest version – Gacek Nov 16 '15 at 23:45
  • To clarify: Network manager was installed but service was not enabled on runlevel (3) i'm using. – Gacek Nov 17 '15 at 10:58
  • how would one, say, ssh into an instance and re-enable network manager if stopping 'network' first is required? it'll cut the ssh once you do it... – frei Mar 13 '17 at 6:12

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.