Openbsd change, add or display default gateway
Q. How do I change existing openbsd gateway (openbsd routing) IP address?
A. OpenBSD use special file to store default gateway /etc/mygat .
You need to put the IP of your gateway in the file /etc/mygate. This will allow for your gateway to be set upon boot. The gateway is added to the routing tables by the route utility. If /etc/mygate does not exist, no default gateway is added to the routing
tables. The file may contain gateway addresses for both IPv4 and IPv6 networks: in dotted quad notation for v4 (e.g. 192.0.2.0) or in colon notation for v6 (e.g. 2001:1234:5678::1). Each address must be specified on a separate line. If more than one address of a specific family is found, only the first is used - all other addresses of that family are ignored (source man page).
Task: Display default gateway
Type the following command
$ cat /etc/mygat
Output:
75.126.68.49
75.126.68.49 is the router IP address.
You can also type any one of the following command to display router IP address:
$ route show
OR
$ netstat -rn
Output:
Routing tables
Internet:
Destination Gateway Flags Refs Use Mtu Interface
default 75.126.68.49 UGS 7 1203 - pcn0
75.126.68.48/29 link#1 UC 1 0 - pcn0
75.126.68.49 00:15:c7:32:a0:00 UHLc 1 0 - pcn0
127/8 127.0.0.1 UGRS 0 0 33192 lo0
127.0.0.1 127.0.0.1 UH 1 0 33192 lo0
224/4 127.0.0.1 URS 0 0 33192 lo0
Internet6:
Destination Gateway Flags Refs Use Mtu Interface
::/104 ::1 UGRS 0 0 - lo0
::/96 ::1 UGRS 0 0 - lo0
::1 ::1 UH 12 0 33192 lo0
::127.0.0.0/104 ::1 UGRS 0 0 - lo0
::224.0.0.0/100 ::1 UGRS 0 0 - lo0
::255.0.0.0/104 ::1 UGRS 0 0 - lo0
::ffff:0.0.0.0/96 ::1 UGRS 0 0 - lo0
2002::/24 ::1 UGRS 0 0 - lo0
2002:7f00::/24 ::1 UGRS 0 0 - lo0
2002:e000::/20 ::1 UGRS 0 0 - lo0
2002:ff00::/24 ::1 UGRS 0 0 - lo0
fe80::/10 ::1 UGRS 0 0 - lo0
fe80::%pcn0/64 link#1 UC 0 0 - pcn0
fe80::20c:29ff:fe7b:6672%pcn0 00:0c:29:7b:66:72 UHL 0 0 - lo0
fe80::%lo0/64 fe80::1%lo0 U 0 0 - lo0
fe80::1%lo0 link#5 UHL 0 0 - lo0
fec0::/10 ::1 UGRS 0 0 - lo0
ff01::/32 ::1 UC 0 0 - lo0
ff02::%pcn0/32 link#1 UC 0 0 - pcn0
ff02::%lo0/32 ::1 UC 0 0 - lo0
Task: Update or change OpenBSD default gateway
Open file using vi text editor
# vi /etc/mygat
Remove existing IP and put new IP address:
75.126.68.100
Save and close the file. To activate the changes type the command:
# sh /etc/netstart
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- OpenBSD Set / Change Default Gateway
- OpenBSD Install Ports Collection
- OpenBSD Change Hostname
- OpenBSD Restart Networking Service
- OpenBSD set up default boot time by modifying boot.conf file
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: bsd default gateway, display default gateway in unix, gateway openbsd, openbsd add default gateway, openbsd default gateway, openbsd default route, openbsd gateway, openbsd set default gateway



Recent Comments
Today ~ 32 Comments
Yesterday ~ 1 Comment
Yesterday ~ 3 Comments
Yesterday ~ 2 Comments
Yesterday ~ 3 Comments