#!/bin/sh
# CentOS Linux release 7.4.1708 (Core)
# 1. restart the network service
# 2. take the NIC [ens32] down
# 3. bring the NIC [ens32] up
systemctl restart network \
&& ifdown ens32 \
&& ifup ens32
#!/bin/sh
# Linux far-seer-01 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux
/etc/init.d/networking restart \
&& ifdown eth0 \
&& ifup eth0
p.ej
[root@localhost tmp]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:b3:74:da brd ff:ff:ff:ff:ff:ff
inet 192.168.224.129/24 brd 192.168.224.255 scope global dynamic ens32
valid_lft 1796sec preferred_lft 1796sec
inet6 fe80::f06e:8b57:23fc:b25/64 scope link
valid_lft forever preferred_lft forever
[root@localhost tmp]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@localhost tmp]# cat net.sh
#!/bin/sh
# 1. restart the network service
# 2. take the NIC [ens32] down
# 3. bring the NIC [ens32] up
systemctl restart network \
&& ifdown ens32 \
&& ifup ens32
[root@localhost tmp]# sh net.sh
Device 'ens32' successfully disconnected.
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ cat net.sh
#!/bin/sh
# Linux far-seer-01 4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux
/etc/init.d/networking restart \
&&ifdown eth0 \
&& ifup eth0
$ sh net.sh
[ ok ] Restarting networking (via systemctl): networking.service.
ifdown: interface eth0 not configured
Internet Systems Consortium DHCP Client 4.3.5
Copyright 2004-2016 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/00:0c:29:8a:67:72
Sending on LPF/eth0/00:0c:29:8a:67:72
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 5
DHCPREQUEST of 192.168.224.128 on eth0 to 255.255.255.255 port 67
DHCPOFFER of 192.168.224.128 from 192.168.224.254
DHCPACK of 192.168.224.128 from 192.168.224.254
bound to 192.168.224.128 -- renewal in 847 seconds.