Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Networking] [Solved][Networking] ifup: /etc/network/interfaces:1: misplaced option

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
kurto
Posts: 8
Joined: 2023-03-29 15:08
Has thanked: 1 time

[Solved][Networking] ifup: /etc/network/interfaces:1: misplaced option

#1 Post by kurto »

Hi, I'm new to Debian, but have been around for a while.

I'm trying to assign a static IP address to my new server. The server is up and running, and connected to the network with a dynamic (DHCP) address.

I modified my /etc/network/interfaces file to contain the following:

Code: Select all

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
#
source /etc/network/interfaces.d/*
#
# The loopback network interface
auto lo
iface lo inet loopback
#
# The primary network interface
auto enp46s0
iface enp46s0 inet static
address 192.168.1.101/24
gateway 192.168.1.1
Nothing complex here at all, simply two interfaces. When I attempt to start the service, it fails with a "ifup[26243]: ifup: /etc/network/interfaces:1: misplaced option".

I am simply missing what is wrong with this file.

Any help would be appreciated. :?
Last edited by kurto on 2023-04-02 14:48, edited 4 times in total.

User avatar
kent_dorfman766
Posts: 535
Joined: 2022-12-16 06:34
Location: socialist states of america
Has thanked: 57 times
Been thanked: 70 times

Re: [Networking] Static IP assignment

#2 Post by kent_dorfman766 »

tabs/spaces for the attribute lines of each interface.

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: [Networking] Static IP assignment

#3 Post by Aki »

Hello,
kurto wrote: 2023-04-01 00:01 [..] When I attempt to start the service, it fails with a "ifup[26243]: ifup: /etc/network/interfaces:1: misplaced option". [..]
Could the /etc/network/interface file be not in ASCII format (e.g., UTF-8 format) ? You can test it with the command:

Code: Select all

file /etc/network/interfaces
Can you send the /etc/network/interfaces file as attachment (compressed as zip) to the next message ?

You can also verify the output of the following commands to gather other hints (root password will be asked):

Code: Select all

script log.txt
su -l -c "ifdown -a"
su -l -c "ifup --verbose -a"
exit
The output of previous commands will be stored in the log.txt that you can analyse or share in a following post.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: [Networking] Static IP assignment

#4 Post by sunrat »

kent_dorfman766 wrote: 2023-04-01 05:06 tabs/spaces for the attribute lines of each interface.
Yep. Examples in the wiki - https://wiki.debian.org/NetworkConfigur ... e_manually
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

kurto
Posts: 8
Joined: 2023-03-29 15:08
Has thanked: 1 time

Re: [Networking] Static IP assignment

#5 Post by kurto »

I will put the spaces back in for the attribute lines, although I removed them intentionally to see if that helped. It didn't. In fact, I removed the second (main) interface completely, and even with just a loopback interface which has no attributes, it still failed.

I'm going to look at the ASCII format as opposed to the UTF-8 encoding. Unfortunately, I needed to reboot that server, and therefore lost my network connectivity. I'll be back in a bit with the zipped version of my file.

kurto
Posts: 8
Joined: 2023-03-29 15:08
Has thanked: 1 time

Re: [Networking] Static IP assignment

#6 Post by kurto »

Based on the reply from Aki, the file command indicates that the file is in UTF-8 encoding. I tried to edit the file using whatever editor Nautilus (under Gnome) provides, and it too showed the encoding to be UTF-8. I tried to save the file as Western (ISO-8859-15), but it wouldn't let me, providing a message that some character in my message could not be encoded in ISO-8859-15. It didn't let me know which character or how to eliminate the problem.

I'd like to provide a .zip file of my interfaces file, but this tool doesn't seem to allow the transfer of .zip documents.

I'm still looking for the solution, but I think I'm on the right path.

kurto
Posts: 8
Joined: 2023-03-29 15:08
Has thanked: 1 time

Re: [Networking] Static IP assignment

#7 Post by kurto »

My problem has been resolved. It was definitely a character/encoding issue. I'm still not sure exactly what character was the problem, but I was able to convert to ISO-8559-1 encoding in a Windows environment. That caused the file to be reduced by 3 bytes. I copied that file back over to Debian, and all is well. Still not sure how to keep that from happening, or how to fix it in Linux, but I'll learn.

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: [Networking] Static IP assignment

#8 Post by Aki »

Hello,
kurto wrote: 2023-04-01 21:08 My problem has been resolved. It was definitely a character/encoding issue. I'm still not sure exactly what character was the problem, but I was able to convert to ISO-8559-1 encoding in a Windows environment. That caused the file to be reduced by 3 bytes. I copied that file back over to Debian, and all is well.
I'm happy we helped you to get it sorted.
kurto wrote: 2023-04-01 21:08 Still not sure how to keep that from happening, or how to fix it in Linux, but I'll learn.
This can happen when some text is copied from a browser page (where unicode is often used as text encoding) and pasted directly to a unicode capable editor.

In Debian GNU/Linux you should be able to convert the /etc/network/interfaces from UTF-8 to ASCII with the following command:

Code: Select all

iconv -f UTF-8 -t ASCII /etc/network/interfaces > interfaces.text
You can check the newly created file interfaces.text:

Code: Select all

file interfaces.text
Then you can rename the old /etc/network/interfaces and replace it with the new one:

Code: Select all

mv /etc/network/interfaces /etc/network/interfaces.old
cp interfaces.text /etc/network/interfaces
file /etc/network/interfaces
You could consider to rename the subject of the first post from "[Networking] Static IP assignment" to "[Networking] ifup: /etc/network/interfaces:1: misplaced option" to make it more useful to other viewers with the same issue .

Please, mark the thread as "Solved" putting the tag "[Solved]" as prefix in the subject of the first post.

Happy Debian. :-)
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
kent_dorfman766
Posts: 535
Joined: 2022-12-16 06:34
Location: socialist states of america
Has thanked: 57 times
Been thanked: 70 times

Re: [Networking] ifup: /etc/network/interfaces:1: misplaced option

#9 Post by kent_dorfman766 »

I sooooo miss the days of 8bit ASCII, before i18n. LOL

Post Reply