Sambung IP Segment OpenVPN dengan Local Network

Beberapa minggu yang lepas aku setup OpenVPN di server dalam rumah untuk aku akses dari luar beberapa website yang aku host dan juga CCTV.

Cara nak setup OpenVPN rasanya merata dan banyak dah orang kongsi contoh nya disini, aku pun ikut guide dari web itu juga.

Dan apabila dah ada service VPN ini baru lah perasan yang aku tak boleh nak akses local device yang bersambung dengan local network jadi aku buat pencari Google dan rata-rata forumers menggalakan untuk rujuk dokumentasi OpenVPN di sini.

Dan melalui dokumentasi ini lah aku jumpa section untuk setup IP segment dan update konfigurasi OpenVPN seperti di bawah.

Expanding the scope of the VPN to include additional machines on either the client or server subnet

Including multiple machines on the server side when using a routed VPN (dev tun)

Once the VPN is operational in a point-to-point capacity between client and server, it may be desirable to expand the scope of the VPN so that clients can reach multiple machines on the server network, rather than only the server machine itself.

For the purpose of this example, we will assume that the server-side LAN uses a subnet of 10.66.0.0/24 and the VPN IP address pool uses 10.8.0.0/24 as cited in the server directive in the OpenVPN server configuration file.

First, you must advertise the 10.66.0.0/24 subnet to VPN clients as being accessible through the VPN. This can easily be done with the following server-side config file directive:

push “route 10.66.0.0 255.255.255.0”

Next, you must set up a route on the server-side LAN gateway to route the VPN client subnet (10.8.0.0/24) to the OpenVPN server (this is only necessary if the OpenVPN server and the LAN gateway are different machines).

Make sure that you’ve enabled IP and TUN/TAP forwarding on the OpenVPN server machine.

Jadi apa yang perlu di buat adalah kita kena update server.conf file di sini.

# vi /etc/openvpn/server.conf

Dan kemudian masukkan parameter seperti contoh di bawah, yang mana IP segmen itu adalah IP segment local network anda.

push "route 10.10.1.0 255.255.255.0"

Lepas dah masukkan parameter tersebut kita kena restart service openvpn dan buat percubaan.

# systemctl restart openvpn-server@server.service

Bila dah pastikan service openvpn-server berjalan dengan baik maksudnya dah OK. Dan perlu buat percubaan untuk pastikan bahawa yang setup tadi betul.

Untuk pengetahuan, sekiranya kita hendak sambungkan IP segment dari server OpenVPN ke IP segment yang lain, perlu buat routing. Boleh rujuk balik petikan dokumentasi di atas.

Leave a Comment