Guest's picture

When I change any values in /etc/network/interfaces, they do not show properly in confconsole until I reboot. Most changes only result in the gateway turning empty. Below is an example to show what I mean.


Settings in confconsole before:
IP Address: 192.168.0.240
Netmask: 255.255.255.0
Gateway: 192.168.0.1
Name Server: 192.168.0.1

Settings in /etc/networkd/interfaces before:
address 192.168.0.240
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameserver 192.168.0.1

Settings in /etc/networkd/interfaces after:
address 192.168.0.40
netmask 255.255.0.0
gateway 192.168.0.10
dns-nameserver 192.168.0.21 192.168.0.22 192.168.0.23

Settings in confconsole after:
IP Address: 192.168.0.240
Netmask: 255.255.255.0
Gateway: 192.168.0.1
Name Server: 192.168.0.21
Name Server: 192.168.0.22
Name Server: 192.168.0.23


Even bringing the eth0 down and up again, does little to fix this, this is what empties the gateway setting, in confconsole only, the /etc/network/interfaces value remains as I set it. But when I change the /etc/networkd/interfaces and reboot, the values are shown properly in confconsole, including the gateway.

What am I forgetting? How do I make changes take effect, whithout using a reboot.


I really want to do this via editing /etc/network/interfaces, as I want to make it part of a script set I'm working on.

 

Thanks again TurnKey for a great distribution and everybody for helping me this far.

Forum: 
JasminAmarea's picture

Seems like I was wearing one of those classic hats, you know, the one with "Dunce" written on them ;-)... I forgot to add one important command, once added, all worked fine. I needed to add /etc/init.d/networking reload to the command list, makes sence, once you think it thru.

For those interested, copy and past below in a (bash) script file:

#!/bin/bash


NETWORK_FILEDATA="/etc/network/interfaces"
NETWORK_FILETEMP="/etc/network/tempfile"


# Ask and store Server Name
echo -n "==> What is the Server Name:"
read SERVERNAME

# Ask and store Netmask
echo -n "==> What is the Netmask:"
read NETMASK

# Ask and store IP Address
echo -n "==> What is the Server IP Address:"
read IPADDRESS

# Ask and store Gateway
echo -n "==> What is the Gateway IP Address:"
read GATEWAY

# Ask and store DNS Name Server(s)
echo -n "==> What is the DNS IP Address(es):"
read DNSSERVERS


# Inform the user of the changes that will be made
echo "Setting Server name to : " $SERVERNAME
echo "Setting Netmask to     : " $NETMASK
echo "Setting IP Address to  : " $IPADDRESS
echo "Setting Gateway to     : " $GATEWAY
echo "Setting Primary DNS to : " $DNSSERVERS

# Setting the server (host) name
echo $SERVERNAME > /etc/hostname

# Copy the network settings to a temp file
cp $NETWORK_FILEDATA $NETWORK_FILETEMP
# Replace the line containing "netmask" with the new setting
sed -i "/netmask/c\    netmask $NETMASK" $NETWORK_FILETEMP
# Replace the line containing "address" with the new setting
sed -i "/address/c\    address $IPADDRESS" $NETWORK_FILETEMP
# Replace the line containing "gateway" with the new setting
sed -i "/gateway/c\    gateway $GATEWAY" $NETWORK_FILETEMP
# Replace the line containing "dns-nameservers" with the new setting(s)
sed -i "/dns-nameservers/c\    dns-nameservers $DNSSERVERS" $NETWORK_FILETEMP
#nano $NETWORK_FILETEMP
cp $NETWORK_FILETEMP $NETWORK_FILEDATA

# Tell the user the new IP Address and ask to reconnect
echo "Resetting network connection, please reconnect."

# Perform a reload of the new network settings
/etc/init.d/networking reload

 

Jeremy Davis's picture

Glad you got it sorted... And don't feel stupid. I'm sure all of us have made silly mistakes at times. I know I certainly have...! :)

Also FWIW you can use the 'service" command in TurnKey (Debian) so instead of

/etc/init.d/networking reload

You could use

service networking reload

Not that there's anything wrong with the former, I just prefer the latter and wanted to share! :)

JasminAmarea's picture

Hi Jeremy,

Thanx for your reply and the added suggestion. It was one of your replies (to one of my earlier questions) that lead to my script with the sed commands. So thank you that also.

Real happy with you guys and with TKL. You just have to LOVE TurnKey Linux!! :))

Add new comment