|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
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 |
|
||||
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. |
|
|||
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 |
|
|||
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 |
|
||||
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. |
|
|||
Thank you. After I used vim to repair /etc/mygate and /etc/hostname.em0, netstart(8) worked.
|
|
|||
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 |
|
||||
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. |
|
|||
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 |
|
||||
Quote:
Quote:
http://heather.cs.ucdavis.edu/~matlo...s/ViIntro.html Quote:
|
|
|||
Quote:
I guess it's possible if launching nano from a gui icon in a desktop environment (not something I use) it might behave differently. |
|
|||
Quote:
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. |
|
|||
Quote:
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 |
|
|
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 |