DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 13th June 2019
notooth notooth is offline
Fdisk Soldier
 
Join Date: Jul 2015
Posts: 70
Default Cannot set static IP address on OpenBSD 6.5

Hello,

I cannot set a static IP address on OpenBSD 6.5. Can anyone help? Here is what I did:

Code:
# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
	index 3 priority 0 llprio 3
	groups: lo
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
	inet 127.0.0.1 netmask 0xff000000
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	lladdr b4:b5:2f:dd:b2:ac
	index 1 priority 0 llprio 3
	groups: egress
	media: Ethernet autoselect (100baseTX full-duplex)
	status: active
	inet 192.168.100.12 netmask 0xffffff00 broadcast 192.168.100.255
enc0: flags=0<>
	index 2 priority 0 llprio 3
	groups: enc
	status: active
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
	index 4 priority 0 llprio 3
	groups: pflog

# nano /etc/hostname.em0
inet 192.168.100.200 255.255.255.0

# nano /etc/mygate
192.168.100.1

# sh /etc/netstart

# ifconfig                    
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
	index 3 priority 0 llprio 3
	groups: lo
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
	inet 127.0.0.1 netmask 0xff000000
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	lladdr b4:b5:2f:dd:b2:ac
	index 1 priority 0 llprio 3
	groups: egress
	media: Ethernet autoselect (100baseTX full-duplex)
	status: active
	inet 192.168.100.12 netmask 0xffffff00 broadcast 192.168.100.255
enc0: flags=0<>
	index 2 priority 0 llprio 3
	groups: enc
	status: active
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
	index 4 priority 0 llprio 3
	groups: pflog
Reply With Quote
  #2   (View Single Post)  
Old 13th June 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,630
Default

Can you set the address manually? # ifconfig em0 192.168.100.200/24

If so, then your problem is likely to be an incorrectly terminated text file for /etc/hostname.em0, caused by your personal choice for your text editor.
Reply With Quote
  #3   (View Single Post)  
Old 13th June 2019
notooth notooth is offline
Fdisk Soldier
 
Join Date: Jul 2015
Posts: 70
Default

The IP address changed when I set it manually, but there was no internet access with the new IP address:
Code:
# ifconfig em0 192.168.100.200/24
 
# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 32768
	index 3 priority 0 llprio 3
	groups: lo
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
	inet 127.0.0.1 netmask 0xff000000
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	lladdr b4:b5:2f:dd:b2:ac
	index 1 priority 0 llprio 3
	groups: egress
	media: Ethernet autoselect (100baseTX full-duplex)
	status: active
	inet 192.168.100.200 netmask 0xffffff00 broadcast 192.168.100.255
enc0: flags=0<>
	index 2 priority 0 llprio 3
	groups: enc
	status: active
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
	index 4 priority 0 llprio 3
	groups: pflog

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendmsg: No route to host
ping: wrote 8.8.8.8 64 chars, ret=-1
ping: sendmsg: No route to host
ping: wrote 8.8.8.8 64 chars, ret=-1
ping: sendmsg: No route to host
ping: wrote 8.8.8.8 64 chars, ret=-1
ping: sendmsg: No route to host
ping: wrote 8.8.8.8 64 chars, ret=-1
ping: sendmsg: No route to host
ping: wrote 8.8.8.8 64 chars, ret=-1
Reply With Quote
  #4   (View Single Post)  
Old 13th June 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,630
Default

Quote:
Originally Posted by notooth View Post
The IP address changed when I set it manually...
Now you know the root cause of the configuration file problem: nano.
Quote:
...but there was no internet access with the new IP address...
Check your routing table. You can use route(8) or netstat(1) to determine if you have no default route. e.g.: $ route -n show -inet or $ netstat -rf inet

The key takeaway from this problem? Use a different editor when provisioning configuration files that need to be terminated correctly.
Reply With Quote
  #5   (View Single Post)  
Old 13th June 2019
notooth notooth is offline
Fdisk Soldier
 
Join Date: Jul 2015
Posts: 70
Default

There is no gateway with the new IP address:
Code:
# route -n show -inet
Routing tables

Internet:
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default            192.168.100.1      UGS       41      487     -     8 em0  
224/4              127.0.0.1          URS        0        0 32768     8 lo0  
127/8              127.0.0.1          UGRS       0        0 32768     8 lo0  
127.0.0.1          127.0.0.1          UHhl       1        2 32768     1 lo0  
192.168.100/24     192.168.100.12     UCn        1     5920     -     4 em0  
192.168.100.1      2c:ab:00:ac:49:40  UHLch      1     4732     -     3 em0  
192.168.100.12     b4:b5:2f:dd:b2:ac  UHLl       0      240     -     1 em0  
192.168.100.255    192.168.100.12     UHb        0       18     -     1 em0  

# ifconfig em0 192.168.100.200/24

# route -n show -inet                  
Routing tables

Internet:
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
224/4              127.0.0.1          URS        0        0 32768     8 lo0  
127/8              127.0.0.1          UGRS       0        0 32768     8 lo0  
127.0.0.1          127.0.0.1          UHhl       1        2 32768     1 lo0  
192.168.100/24     192.168.100.200    UCn        1        6     -     4 em0  
192.168.100.1      2c:ab:00:ac:49:40  UHLc       0        9     -     3 em0  
192.168.100.200    b4:b5:2f:dd:b2:ac  UHLl       0        2     -     1 em0  
192.168.100.255    192.168.100.200    UHb        0        0     -     1 em0
Reply With Quote
  #6   (View Single Post)  
Old 13th June 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,630
Default

You must also manually add the default route. # route add default 192.168.100.1

I hope you realize that if you select a better editor, you can then repair /etc/mygate and /etc/hostname.em0 and let netstart(8) issue these commands for you.
Reply With Quote
  #7   (View Single Post)  
Old 13th June 2019
notooth notooth is offline
Fdisk Soldier
 
Join Date: Jul 2015
Posts: 70
Default

Thank you. After I used vim to repair /etc/mygate and /etc/hostname.em0, netstart(8) worked.
Reply With Quote
  #8   (View Single Post)  
Old 14th June 2019
frcc frcc is offline
Don't Worry Be Happy!
 
Join Date: Jul 2011
Location: hot,dry,dusty,rainy,windy,straight winds, tornado,puts the fear of God in you-Texas
Posts: 154
Default

Administrator-IF this post belongs elsewhere, please feel free to move it.

However, I was "curious" as it relates to Jiggimi's reply above concerning Nano and his statement regarding selecting a "better editor".

Jiggimi, would you be so kind as to clarify the technical issue (i.e. end line characters, etc) when "Nano" is used to edit the config file as stated in this post as I have used it many times in the past without issue?


Last edited by frcc; 14th June 2019 at 11:56 AM. Reason: clarify
Reply With Quote
  #9   (View Single Post)  
Old 14th June 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,630
Default

Above, I'd posted a link to this thread.

http://daemonforums.org/showthread.php?t=11007

I'm not a nano user, but it is clear that users are able to create text files that do not terminate properly. This doesn't appear to happen with any other text file editors.
Reply With Quote
Old 14th June 2019
frcc frcc is offline
Don't Worry Be Happy!
 
Join Date: Jul 2011
Location: hot,dry,dusty,rainy,windy,straight winds, tornado,puts the fear of God in you-Texas
Posts: 154
Default

Interesting!
Thanks Jiggimi! also noted your reply concerning the "Ed Mastery" book by Mitch Lucas.
Since I am over the hill (age) so to speak, vi, vim, emacs, etc present a learning curve that I am hesitant to participate in, therefore since I am proficient with "ed" and "nano", looks like I'll edit config files with "ed" to be sure from now on.

PLEASE this entry is not intended to start an editor war.

Also, I wonder if Nano's maintainer is aware of this issue?

_

Last edited by frcc; 14th June 2019 at 12:14 PM. Reason: clarify and add
Reply With Quote
Old 14th June 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,630
Default

Quote:
Originally Posted by frcc View Post
Interesting!
Thanks Jiggimi! also noted your reply concerning the "Ed Mastery" book by Mitch Lucas.
Michael. His tech books are under the name Michael W. Lucas.
Quote:
Since I am over the hill (age) so to speak, vi, vim, emacs, etc present a learning curve that I am hesitant to participate in...
You can learn to use the vi family of editors in 5 minutes. If you dare.

http://heather.cs.ucdavis.edu/~matlo...s/ViIntro.html
Quote:
Also, I wonder if Nano's maintainer is aware of this issue?
No idea. You can send Email to naddy@ and ask him.
Reply With Quote
Old 15th June 2019
johnR johnR is offline
Port Guard
 
Join Date: Nov 2017
Posts: 37
Default

Quote:
Originally Posted by jggimi View Post
I'm not a nano user, but it is clear that users are able to create text files that do not terminate properly. This doesn't appear to happen with any other text file editors.
I don't normally use nano but I just installed it to test this. The only way I could get it to leave out the newline at the end was to start it with the -L option (--nonewlines). If saving to a .txt file, it didn't leave it out even with the -L option.

I guess it's possible if launching nano from a gui icon in a desktop environment (not something I use) it might behave differently.
Reply With Quote
Old 15th June 2019
johnR johnR is offline
Port Guard
 
Join Date: Nov 2017
Posts: 37
Default

Quote:
Originally Posted by frcc View Post
Since I am over the hill (age) so to speak, vi, vim, emacs, etc present a learning curve that I am hesitant to participate in, therefore since I am proficient with "ed" and "nano", looks like I'll edit config files with "ed" to be sure from now on.
The learning curve for vi is steep but short. If you can use "ed" I don't think you'd find vi difficult :-)

I'd recommend "Learning the vi Editor" (O'Reilly) by Lamb and Robbins as a gentle introduction. You can find older (but still valid) editions at very low prices.
Reply With Quote
Old 4 Weeks Ago
TheTKS TheTKS is offline
Port Guard
 
Join Date: Sep 2018
Location: Canada
Posts: 14
Default

Quote:
Originally Posted by johnR View Post
I don't normally use nano but I just installed it to test this. The only way I could get it to leave out the newline at the end was to start it with the -L option (--nonewlines). If saving to a .txt file, it didn't leave it out even with the -L option.

I guess it's possible if launching nano from a gui icon in a desktop environment (not something I use) it might behave differently.
I do normally use nano, from the CLI, and it behaves for me the way described in the thread jggimi linked to - I'm one of the posters who was puzzled with the strange results using nano, until I learned in that thread what was going on. I still use nano, but always check to make sure my files have the final newline.

With that said, I have used vi, vim and others, but never enough to get the hang of them. I will use vi a bit more to get handy with a second editor. Looking over that tutorial, it looks like it should take less than I expected to get there. Thanks for that, jggimi!

TKS
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set static IP under OpenBSD ? bsd007 OpenBSD General 1 5th October 2018 05:19 PM
FreeCode goes static shep News 0 18th June 2014 09:59 PM
Trouble after changing static IP to dynamic IP on OpenBSD gateway magrin OpenBSD General 5 5th April 2014 10:38 AM
Static IP address problem rex FreeBSD General 2 25th November 2008 08:53 PM
Cannot assign static IP. bsdnewbie999 OpenBSD General 5 21st June 2008 09:50 AM


All times are GMT. The time now is 06:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick