[Indeks FAQ] [Ke Bagian 5 - Membangun Sistem dari Kode Sumber [Ke Bagian 7 - Kendali Keyboard dan Tampilan]
Pada sebagian besar dokumen ini akan membantu jika anda telah membaca dan paling tidak sedikit memahami bagian Pengaturan dan Konfigurasi Kernel dari FAQ, dan ifconfig(8) dan halaman manual netstat(1).
Jika anda seorang administrator jaringan, dan anda mengatur protokol routing, jika anda menggunakan OpenBSD anda sebagai router, jika anda perlu kejelasan tentang jaringan IP, anda sangat perlu membaca Pemahaman Pengalamatan IP(Understanding IP Addressing). Dokumen ini sangat bagus. "Understanding IP Addressing" berisi pengetahuan dasar untuk membangun jaringan IP, khususnya ketika anda berurusan atau bertanggung jawab pada lebih dari satu jaringan.
Jika anda bekerja dengan aplikasi seperti server web, server ftp, dan server mail, anda akan sangat diuntungkan dengan membaca RFC. Kebanyakan sepertinya, anda tidak membaca seluruhnya. Ambil beberapa bahasan yang menarik bagi anda, atau yang adna gunakan dalam lingkungan jaringan anda. Cermati , temukan bagimana sesuatu dinginkan berjalan seperti apa. RFC menentukan banyak (ribuan) standar untuk protokol pada Internet dan bagaimana protokol-protokol tersebut harus berjalan.
Untuk permulaan, anda harus mengenali kartu jaringan anda. Dalam OpenBSD, dinamai berdasar jenis kartu, bukan jenis koneksitas. Bisa anda lihat kartu jaringan anda dikenali sewaktu proses booting, atau setelah proses booting menggunakan perintah dmesg(8) . Bisa pula anda punyai kesempatan untuk mengenali kartu jaringan anda menggunakan perintah ifconfig(8). Misal, di sini diberikan keluaran dmesg kartu jaringan Intel Fast Ethernet, yang menggunakan nama divais fxp.
fxp0 at pci0 dev 10 function 0 "Intel 82557" rev 0x0c: irq 5, address 00:02:b3:2b:10:f7 inphy0 at fxp0 phy 1: i82555 10/100 media interface, rev. 4
Jika anda tidak tahu penamaan kartu jaringan, mohon lihat daftar peranti keras terdukung untuk platform anda. Akan anda jumpai sebuah daftar untuk banyak kartu yang umum dan nama divaisnya pada OpenBSD disebutkan di sini. Gabungan nama divais alfabet pendek (seperti fxp) dengan sebuah angka yang diberikan oleh kernel dan anda akan mempunyai sebuah nama (seperti fxp0).
Dapat anda lihat bahwa kartu jaringan telah dikenali dengan menggunakan utilitas ifconfig(8) . Perintah berikut ini akan menunjukkan seluruh antarmuka jaringan pada sebuah sistem. Contoh keluaran memperlihatkan pada kita hanya ada satu antarmuka fisik ethernet, dan itu adalah fxp(4).
$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33224
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
lo1: flags=8008<LOOPBACK,MULTICAST> mtu 33224
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:04:ac:dd:39:6a
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 10.0.0.38 netmask 0xffffff00 broadcast 10.0.0.255
inet6 fe80::204:acff:fedd:396a%fxp0 prefixlen 64 scopeid 0x1
pflog0: flags=0<> mtu 33224
pfsync0: flags=0<> mtu 2020
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 296
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
ppp1: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
tun0: flags=10<POINTOPOINT> mtu 3000
tun1: flags=10<POINTOPOINT> mtu 3000
enc0: flags=0<> mtu 1536
bridge0: flags=0<> mtu 1500
bridge1: flags=0<> mtu 1500
vlan0: flags=0<> mtu 1500
address: 00:00:00:00:00:00
vlan1: flags=0<> mtu 1500
address: 00:00:00:00:00:00
gre0: flags=9010<POINTOPOINT,LINK0,MULTICAST> mtu 1450
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gif1: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gif2: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gif3: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
Seperti anda lihat, ifconfig(8) memberi kita banyak keterngan daripada yang kita butuhkan disini. Tetapi, masih bisa kita lihat antarmuka jaringan kita. Pada contoh di atas, kartu jaringan kita telah dikonfigurasi . Sangat jelas karena sebuah jaringan IP telah dikonfigurasi pada fxp0, yaitu nilai "inet 10.0.0.38 netmask 0xffffff00 broadcast 10.0.0.255". Juga, penanda UP and RUNNING telah aktif.
Pada akhirnya, anda akan diberitahu beberapa antarmuka lainnya yang diaktifkan dari bawaan sistem. Itu adalah antarmuka virtual yang melayani berbagai fungsi. Halaman manual berikut menjelaskannya:
Jika kartu jaringan anda tidak terkonfigurasi, langkah pertama adalah membuat
berkas /etc/hostname.xxx, dengan nama divais anda akan menggantikan
xxx. Dari keterangan contoh di atas,
nama berkas akan manjadi /etc/hostname.fxp0. Layout berkas ini
sederhana:
(Lebih rinci tentang format berkas ini dapat ditemukan pada halaman manual hostname.if(5) .)address_family address netmask broadcast [other options]
Berkas konfigurasi yang umum, untuk konfigurasi alamat IPv4, terlihat seperti berikut:
$ cat /etc/hostname.fxp0 inet 10.0.0.38 255.255.255.0 NONE
Bisa juga anda tentukan jenis media untuk Ethernet, katakan, jika anda ingin memaksa menggunakan modus 100baseTX full-duplex.
inet 10.0.0.38 255.255.255.0 NONE media 100baseTX mediaopt full-duplex
(Tentu saja, anda seharusnya jangan pernah memaksakan modus full duplex kecuali kedua sisi koneksi telah diatur untuk hal ini! Pada kebutuhan yang umum, pengaturan media seharusnya diabaikan.)
Atau, mungkin anda ingin menggunakan penanda khusus untuk beberapa antarmuka. Format berkas hostname tidak berubah banyak!
$ cat /etc/hostname.vlan0 inet 172.21.0.0 255.255.255.0 NONE vlan 2 vlandev fxp1
Langkah selanjutnya dari sini adalah mengatur gateway default anda. Untuk hal ini, mudahnya letakkan IP gateway anda pada berkas /etc/mygate. Akan membuat gateway anda dikonfigurasi setelah boot. DAri isni anda seharusnya mengatur nameserver anda, dan berkas /etc/hosts anda (lihat halaman manual hosts(5) ). Untuk mengkonfigurasi nameserver anda, anda perlu membuat sebuah berkas bernama /etc/resolv.conf. Bisa anda baca lebih lanjut tentang format berkas ini pada halaman manual resolv.conf(5) . tetapi untuk penggunaan standar, berikut ini ada contohnya. Pada contoh ini server domain anda adalah 125.2.3.4 dan 125.2.3.5. Anda juga mempunyai domain "example.com".
$ cat /etc/resolv.conf search example.com nameserver 125.2.3.4 nameserver 125.2.3.5 lookup file bind
Dari sini, bisa anda reboot maupun menjalankan skrip /etc/netstart. Anda lakukan ini dengan mudahnya mengetikkan (sebagai root):
# sh /etc/netstart writing to routing socket: File exists add net 127: gateway 127.0.0.1: File exists writing to routing socket: File exists add net 224.0.0.0: gateway 127.0.0.1: File exists
Perhatikan bahwa sedikit kesalahan telah terjadi. Dengan menjalankan skrip ini, anda mengkonfigurasi ulang sesuatu yang telah terkonfigurasi. Seperti, beberapa route telah dialokasikan pada tabel routing kernel. Dari sini sistem anda seharusnya siap dan berjalan untuk koneksi jaringan. Sekali lagi, bisa anda periksa untuk memastikan kartu jaringan telah di konfigurasi dengan tepat menggunakan ifconfig(8). Bisa juga anda periksa route anda dengan netstat(1) atau route(8). Jika anda mempunyai masalah routing, mungkin anda ingin menggunakan penanda -n pada route(8) yang akan mencetak alamat IP daripada melakukan pencarian DNS dan menampilkan nama host. Berikut ini contoh menampilkan tabel routing menggunakan kedua program tersebut.
$ netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Mtu Interface default 10.0.0.1 UGS 0 86 - fxp0 127/8 127.0.0.1 UGRS 0 0 - lo0 127.0.0.1 127.0.0.1 UH 0 0 - lo0 10.0.0/24 link#1 UC 0 0 - fxp0 10.0.0.1 aa:0:4:0:81:d UHL 1 0 - fxp0 10.0.0.38 127.0.0.1 UGHS 0 0 - lo0 224/4 127.0.0.1 URS 0 0 - lo0 Encap: Source Port Destination Port Proto SA(Address/SPI/Proto) $ route show Routing tables Internet: Destination Gateway Flags default 10.0.0.1 UG 127.0.0.0 LOCALHOST UG localhost LOCALHOST UH 10.0.0.0 link#1 U 10.0.0.1 aa:0:4:0:81:d UH 10.0.0.38 LOCALHOST UGH BASE-ADDRESS.MCA LOCALHOST U
Ini adalah keterangan dasar yang anda perlukan untuk membuat boks OpenBSD anda sebagai sebuah gateway (juga disebut sebuah router). Jika anda gunakan OpenBSD sebagai router dengan koneksi Internet, kami sarankan anda baca juga petunjuk pengaturan Packet Filter di bawah ini untuk menutup lalulintas yang berpotensial buruk. Juga, karena rendahnya ketersediaan alamat IPv4 dari jaringan penyedia layanan Internet dan registri regional, anda mungkin ingin melihat pada Network Address Translation untuk keterangan pada penghematan ruang alamat IP anda.
Kernel GENERIC selalu mempunyai kemampuan membolehkan Forwarding IP, tetapi perlu untuk diaktifkan. Anda seharusnya melakukan ini dengan utilitas sysctl(8) . Untuk mengubah secara menetap harus anda suntung berkas /etc/sysctl.conf agar bisa untuk Forwarding IP. Untuk hal ini juga tambahkan baris berikut pada berkas konfigurasi.
net.inet.ip.forwarding=1
Untuk membuat perubahan ini tanpa melakukan reboot anda gunakan utilitas sysctl(8) secara langsung. Ingatlah ini meski perubahan tidak akan berpengaruh setelah reboot, dan perlu dijalankan sebagai root.
# sysctl -w net.inet.ip.forwarding=1 net.inet.ip.forwarding: 0 -> 1
Sekarang kita modifikasi route pada host lain pada kedua sisi. Ada banyak kemungkinan penggunaan OpenBSD sebagai router, menggunakan software semisal routed(8), gated, mrtd, dan zebra. OpenBSD mempunyai dukungan pada koleksi port untuk zebra, gated dan mrtd. OpenBSD mendukung beberapa antarmuka T1, HSSI, ATM, FDDI, Ethernet, dan serial (PPP/SLIP).
OpenBSD mempunyai tatacara sederhana untuk membuat alias pada sebuah antarmuka. Untuk hal ini mudahnya sunting berkas /etc/hostname.<if>. Berkas ini dibaca setelah booting oleh skrip /etc/rc(8) , yang merupakan bagian dari hierarki pemulaan rc. Sebagai contoh, kita anggap pengguna mempunyai sebuah antarmuka dc0 dan pada jaringan 192.168.0.0. Keterangan penting lainnya:
Sedikit catatan tambahan tentang alias. Dalam OpenBSD anda gunakan hanya nama antarmuka. Tidak ada perbedaan antara alias pertama dan alias kedua. Tidak seperti sistem operasi lainnya, OpenBSD tidak merujuk alias sebagai dc0:0, dc0:1. Jika anda merujuk pada sebuah alamat IP alias dengan ifconfig, atau menambahkan alias, pastikan untuk menyatakan "ifconfig int alias" daripada hanya "ifconfig int" pada baris perintah. Bisa anda hapus alias dengan "ifconfig int delete".
Anggap anda menggunakan beberapa alamat IP yang berada pada subnet IP yang sama untuk alias, pengaturan netmask anda untuk tiap alias menjadi 255.255.255.255. IP alias tidak perlu mengikuti netmask dari IP pertama yang dipasang pada kartu jaringan. Pada contoh ini, /etc/hostname.dc0, dua alias ditambahkan pada divais dc0, yang, kita lihat, telah terkonfigurasi sebagai 192.168.0.2 netmask 255.255.255.0.
# cat /etc/hostname.dc0 inet 192.168.0.2 255.255.255.0 media 100baseTX inet alias 192.168.0.3 255.255.255.255 inet alias 192.168.0.4 255.255.255.255
Setelah anda membuat berkas ini, ini hanya butuh untuk reboot agar berpengaruh. Bagaimanapun anda bisa menagtifkan alias secara manual dengan utilitas ifconfig(8) . Untuk mengaktifkan alias pertama anda gunakan perintah:
# ifconfig dc0 inet alias 192.168.0.3 netmask 255.255.255.255
Untuk melihat alias ini harus anda gunakan perintah:
$ ifconfig -A
dc0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST>
media: Ethernet manual
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet 192.168.0.3 netmask 0xffffffff broadcast 192.168.0.3
Untuk menggunakan klien DHCP dhclient(8) yang disertakan dalam OpenBSD, sunting /etc/hostname.xl0 (dianggap kartu jaringan utama anda adalah xl0. Milik anda mungkin juga ep0 atau fxp0 atau lainnya!). Yang anda perlukan adalah meletakkannya pada berkas nama host adalah 'dhcp'
# echo dhcp >/etc/hostname.xl0
INi akan membuat OpenBSD sevara langsung memulai klien DHCP sewaktu boot. OpenBSD akan mengumpulkan alamat-alamat IP, gateway default, dan server DNS dari server DHCP.
Jika anda ingin menjalankan klien dhcp dari bari perintah, pastikan berkas /etc/dhclient.conf telah ada, lalu coba:
# dhclient fxp0
Dengan fxp0 adalah kartu jaringan yang anda inginkan menerima koneksi dhcp.
Tidak peduli bagaimana anda menjalankan dhclient, dapat anda sunting berkas /etc/dhclient.conf untuk tidak membarui DNS anda berdasar pada gagasan server dhcp tentang DNS dengan pertama-tama membuka baris 'request' pada nya (itu adalah contoh untuk konfigurasi standar bawaan, tetapi anda perlu membuka baris tersebut untuk menimpa konfigurasi dhclient bawaan.)
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name, lpr-servers, ntp-servers;
dan lalu hapus domain-name-servers. Tentu saja, mungkin anda ingin untuk mengahpus nama host, atau konfigurasi lainnya juga.
Jika anda ingin menggunakan OpenBSD sebagai sebuah server DHCP dhcpd(8), sunting /etc/rc.conf. Aturlah sehingga menjadi dhcpd_flags="-q" daripada dhcpd_flags=NO. Letakkan antarmuka yang anda inginkan untuk tempat dhcpd berjalan(listen) pada /etc/dhcpd.interfaces.
# echo xl1 xl2 xl3 >/etc/dhcpd.interfaces
Lalu, sunting /etc/dhcpd.conf. Pilihan opsi pada berkas tersebut telah menjelaskan sendiri dengan terang dan bagus.
option domain-name "example.com";
option domain-name-servers 192.168.1.3, 192.168.1.5;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
range 192.168.1.32 192.168.1.127;
}
Hal ini akan memberitahu klien DHCP anda doamin yang di masukkan pada permintaan DNS adalah exmaple.com (sehingga, jika user menulis 'telnet joe' maka ini akan dikirim sebagai joe.example.com). Akan mengrahakan permintaan DNS ke server DNS 192.168.1.3 dan 192.168.1.5. Untuk host-host yang berada pada jaringan yang sama dengan antarmuka jaringan pada mesin OpenBSD, yang berada dalam daerah 192.168.1.0/24, akan diberikan sebuah alamat IP untuk klien antara 192.168.1.32 dan 192.168.1.127. Akan diatur gateway default di 192.168.1.1.
Jika anda ingin menjalankan dhcpd(8) dari baris perintah, setelah menyunting /etc/dhcpd.conf, coba:
# dhcpd -q fxp0
Dengan fxp0 adalah sebuah antarmuka untuk menjalankan layanan DHCP Penanda -q membuat dhcpd(8) tenang; jika tidak akan sangat banyak memberi pesan keluaran.
Jika anda melayani DHCP pada sebuah boks Windows, mungkin anda ingin agar dhcpd(8) memberi klien tersebut sebuah alamat server 'WINS'. Untuk membuat hal ini, hanya tambahkan baris berikut ke /etc/dhcpd.conf anda:
option netbios-name-servers 192.168.92.55;
(dengan 192.168.92.55 adalah IP Windows atau server Samba anda .) Lihat dhcp-options(5) untuk pilihan opsi yang mungkin akan dipakai klien DHCP anda.
Point-to-Protocol secara umum adalah apa yang digunakan untuk membuat hubungan dengan ISP anda melalui sebuah modem. OpenBSD mempunyai 2 cara untuk hal ini.
Hal paling pertama akan kami bahas adalah daemon userland PPP. Sebagai persiapan anda perlu beberapa keterangan singkast tentang ISP anda. Berikut ini adalah daftar keterangan berguna yang akan anda perlukan.
Beberapa ada yang tidak harus dipakai, tetapi akan sangat membantu dalam mengatur ppp anda. Daemon PPP userland menggunakan berkas /etc/ppp/ppp.conf sebagai berkas konfigurasinya. Terdapat banyak berkas bermanfaat pada /etc/ppp yang mempunyai pengaturan berbeda-beda untuk banyak keadaan berbeda. Anda seharusnya memeriksa direktori tersebut.
Juga, pastikan, jika anda tidak menggunakan kernel GENERIC, anda mempunyai baris ini dalam berkas konfigurasi anda:
pseudo-device tun 2
Inisialisasi Pengaturan untuk daemon userland PPP terdiri dari menyunting berkas /etc/ppp/ppp.conf anda. Berkas ini tidak ada dari bawaan sistem, tetapi ada berkas /etc/ppp/ppp.conf.sample yang mudahnya bisa anda sunting untuk membuat berkas ppp.conf anda sendiri. Di sini penulis akan menjalankan dengan pengaturan termudah dan mungkin paling banyk digunakan. Ini adalah sebuah berkas ppp.conf yang ringkas yang mudahnya akan menghubungkan ke ISP anda dan mengatur route default dan nameserver anda . Dengan berkas ini seluruh keterangan yang anda perlukan adalah nomor telepon ISP anda dan username beserta password anda.
default: set log Phase Chat LCP IPCP CCP tun command set device /dev/cua01 set speed 115200 set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \"\" AT OK-AT-OK ATE1Q0 OK\\dATDT\\T TIMEOUT 40 CONNECT"
bagian di bawah penanda default: akan dijalankan setiap kali. Di sini kita konfigurasi seluruh keterangan penting kita. Dengan "set log" kita atur tingkat logging kita. Ini bisa diubah; merujuk pada ppp(8) untuk lebih jelas tentang mengatur tingkat logging. Divais kita di atur dengan "set device". Ini adalah divais tempat modem berjalan. Pada contoh ini modem berjalan pada port com 2. Karenanya port com 1 akan menjadi /dev/cua00. Dengan "set speed" kita atur kecepatan koneksi dialup kita dan dengan "set dial" kita atur parameter dialup kita. Dengan hal ini bisa kita atur waktu tunggu koneksi(timeout) kita, dll. Baris ini seharusnya tetap seperti tersebut adanya.
Sekarang kita berlanjut dan mengatur keterangan khusus kita ke ISP kita. Kita lakukan ini dengan menambahkan penanda lain dibawah bagian default: kita. Penanda ini dapat dinamai sesuka anda, termudah gunakan nama ISP anda. Disini saya akan menggunakan myisp: sebagai penanda kita merujuk pada ISP kita. Berikut ini adalah contoh konfigurasi terkait dengan semua yang kita perlukan agar kita terhubung ke ISP.
myisp: set phone 1234567 set login "ABORT NO\\sCARRIER TIMEOUT 5 ogin:--ogin: ppp word: ppp" set timeout 120 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0 add default HISADDR enable dns
Di sini kita harus mengatur keterangan dasar untuk ISP tertentu. Pilihan pertama "set phone" menentukan nomor dialup ISP anda. "set login" mengatur pilihan login kita. Di sini kita punya waktu tunggu ditentukan ke 5; artinya kita akan membatalkan percobaan login setelah 5 detik jika tidak ada hubungan. Jika tidak, akan menunggu "login:" terkirim dan mengirimkan username serta password anda. Pada contoh ini Username = ppp dan Password = ppp. Nilai variable ini perlu anda sesuaikan. baris "set timeout" menentukan waktu tunggu diam(idle timeout) untuk keseluruhan waktu koneksi menjadi 120 detik. "set ifaddr" baris tersebut agak bersifat trik. Berikut ini sebuah penjelasan lebih lanjut.
set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
Pada baris diatas, telah kita atur dalam format "set ifaddr [alamat_aku[/nn] [alamat_isp[/nn] [netmask [triggeraddr]]]]". Sehingga IP pertama yang ditentukan adalah IP yang kita pakai. Jika anda punya IP statis , anda tentukan di sini. Pada contoh kita kita gunakan /0 yang menunjukkan bahwa tidak perlun alamat ip ini bersesuaian dan keseluruhan selanjutnya lalu dapat terubah. IP kedua yang ditentukan adalah IP isp. Jika anda mengetahuinya bisa anda tentukan. Sekali lagi pada baris kita tidak kita ketahui IP yang akan diberikan, sehingga biarkan isp mengaturnya. Pilihan ketiga adalah netmask kita, disni diatur pada 255.255.255.0. Jika triggeraddr ditentukan, ini digunakan untuk mengganti alamat_aku pada inisialisasi negosiasi IPCP. Namun, hanya sebuah alamat pada daerah alamat_aku akan diterima. Ini berguna ketika negosiasi dengan beberapa implementasi PPP yang tidak memberikan sebuah IP kecuali peer nya meminta ``0.0.0.0''.
Berikutnya digunakan "add default HISADDR" menentukan route default kita ke IP isp. Ini saling terkait, artinya jika IP isp nerubah, route kita akan secara langsung disesuaikan. Dengan "enable dns" kita meminta ISP kita untuk mengotentikasi alamat nameserver kita. JANGAN melakukan hal ini jika anda menjalankan DNS lokal, karena ppp akan langsung menggunakan beberapa baris nameserver pada /etc/resolv.conf.
Sekarang telah kita punyai berkas ppp.conf kita dapat mulai mencoba membuat sebuah hubungan ke ISP kita. Akan dijelaskan beberapa argumen yang umum dipakai pada ppp.
By using /usr/sbin/ppp with no options will put you into interactive mode. From here you can interact directly with the modem, it is great for debugging problems in your ppp.conf file.
In some situations you might want commands executed as your connection is made or dropped. There are two files you can create for just these situations. /etc/ppp/ppp.linkup and /etc/ppp/ppp.linkdown. Sample configurations can be viewed here:
Extended information can be found at FreeBSD Handbook entry on User PPP.
You would normally use this to allow for routing or connection problems. Of course, for it to be most effective, both sides of the connection need to use similar values.
To tweak this, use sysctl and increase the values of:
net.inet.tcp.keepinittime net.inet.tcp.keepidle net.inet.tcp.keepintvl
Using sysctl -a, you can see the current values of these (and many other) parameters. To change one, use sysctl -w, as in sysctl -w net.inet.tcp.keepidle=28800.
Normally, you don't want to do this. This allows someone to send traffic to the broadcast address(es) of your connected network(s) if you are using your OpenBSD box as a router.
There are some instances, in closed networks, where this may be useful, particularly when using older implementations of the NetBIOS protocol. This is another sysctl. sysctl -w net.inet.ip.directed-broadcast=1 turns this on. Read about smurf attacks if you want to know why it is off by default.
There is a sysctl for this also. From sysctl(8):
Set the list of reserved TCP ports that should not be allocated by the kernel dynamically. This can be used to keep daemons from stealing a specific port that another program needs to function. List elements may be separated by commas and/or whitespace. # sysctl -w net.inet.tcp.baddynamic=749,750,751,760,761,871 It is also possible to add or remove ports from the current list. # sysctl -w net.inet.tcp.baddynamic=+748 # sysctl -w net.inet.tcp.baddynamic=-871
NFS, or Network File System, is used to share a filesystem over the network. A few choice man pages to read before trying to setup a NFS server are:
This section will go through the steps for a simple setup of NFS. This example details a server on a LAN, with clients accessing NFS on the LAN. It does not talk about securing NFS. We presume you have already setup packet filtering or other firewalling protection, to prevent outside access. If you are allowing outside access to your NFS server, and you have any kind of sensitive data stored on it, we strongly recommend that you employ IPsec. Otherwise, people can potentially see your NFS traffic. Someone could also pretend to be the IP address which you are allowing into your NFS server. There are several attacks that can result. When properly configured, IPsec protects against these types of attacks.
Another important security note. Don't just add a filesystem to /etc/exports without some kind of list of allowed host(s). Without a list of hosts which can mount a particular directory, anyone on who can reach your host will be able to mount your NFS exports.
NFS depends upon portmap(8) to be running before it will operate. Portmap(8) is now off by default on OpenBSD 3.2 and later, so you must enable it in rc.conf(8) by changing the portmap line to read:
and reboot to make it take effect.portmap=YES
The setup consists of a server with the ip 10.0.0.1. This server will be serving NFS only to clients within that network. The first step to setting up NFS is to setup your /etc/exports file. This file lists which filesystems you wish to have accessible via NFS and defines who is able to access them. There are many options that you can use in your /etc/exports file, and it is best that you read the exports(5) man page. For this example we have an /etc/exports that looks like this:
# # NFS exports Database # See exports(5) for more information. Be very careful, misconfiguration # of this file can result in your filesystems being readable by the world. /work -alldirs -ro -network 10.0.0 -mask 255.255.255.0
This means that the local filesystem /work will be made available via NFS. -alldirs specifies that clients will be able to mount at any point under the /work mount point. -ro specifies that it will only be allowed to be mounted read-only. The last two arguments specify that only clients within the 10.0.0.0 network using a netmask of 255.255.255.0 will be authorized to mount this filesystem. This is important for some servers that are accessible by different networks.
Once your /etc/exports file is setup, you can go ahead and setup your NFS server. You should first make sure that options NFSSERVER & NFSCLIENT are in your kernel configuration. (GENERIC kernel has these options included.) Next, you should set nfs_server=YES in /etc/rc.conf. This will bring up both nfsd(8) and mountd(8) when you reboot. Now, you can go ahead and start the daemons yourself. These daemons need to be started as root, and you need to make sure that portmap(8) is running on your system. Here is an example of starting nfsd(8) which serves on both TCP and UDP using 4 daemons. You should set an appropriate number of NFS server daemons to handle the maximum number of concurrent client requests that you want to service.
# /sbin/nfsd -tun 4
Not only do you have to start the nfsd(8) server, but you need to start mountd(8). This is the daemon that actually services the mount requests on NFS. To start mountd(8), make sure an empty mountdtab file exists, and run the daemon:
# echo -n >/var/db/mountdtab # /sbin/mountd
If you make changes to /etc/exports while NFS is already running, you need to make mountd aware of this! Just HUP it:
# kill -HUP `cat /var/run/mountd.pid`
From here, you can check to make sure that all these daemons are up and registered with RPC. To do this, use rpcinfo(8).
$ rpcinfo -p 10.0.0.1
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100005 1 udp 633 mountd
100005 3 udp 633 mountd
100005 1 tcp 916 mountd
100005 3 tcp 916 mountd
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
During normal usage, there are a few other utilities that allow you to see what is happening with NFS. One is showmount(8), which allows you to view what is currently mounted and who is mounting it. There is also nfsstat(8) which shows much more verbose statistics. To use showmount(8), try /usr/bin/showmount -a host. For example:
$ /usr/bin/showmount -a 10.0.0.1 All mount points on 10.0.0.1: 10.0.0.37:/work
NFS filesystems should be mounted via mount(8), or more specifically, mount_nfs(8). To mount a filesystem /work on host 10.0.0.1 to local filesystem /mnt, do this (note that you don't need to use an IP address; mount will resolve host names):
# mount -t nfs 10.0.0.1:/work /mnt
To have your system mount upon boot, add something like this to your /etc/fstab:
10.0.0.1:/work /mnt nfs rw 0 0
It is important that you use 0 0 at the end of this line so that your computer does not try to fsck the NFS filesystem on boot!!!! The other standard security options, such as noexec, nodev, and nosuid, should also be used where applicable. Such as:
10.0.0.1:/work /mnt nfs rw,nodev,nosuid 0 0
This way, no devices or setuid programs on the NFS server can subvert security measures on the NFS client. If you are not mounting programs which you expect to run on the NFS client, add noexec to this list.
NOTE: This does not apply to ALL ADSL providers, but much information can be gleaned from the setup here. This is known to work for Inode, an ADSL provider in Austria.
To start off, you need to install pptp. The port is located at /usr/ports/net/pptp. Read FAQ 8, Ports for more information on the OpenBSD ports tree.
Because of a conflict between the In-Kernel gre(4) support and pptp, you will need to re-compile your kernel, removing support for gre(4).
Patch to remove GRE(4) support.Index: GENERIC =================================================================== RCS file: /cvs/src/sys/conf/GENERIC,v retrieving revision 1.86 diff -u -r1.86 GENERIC --- GENERIC 14 Mar 2002 00:42:25 -0000 1.86 +++ GENERIC 17 May 2002 01:52:17 -0000 @@ -87,7 +87,7 @@ pseudo-device enc 1 # option IPSEC needs the encapsulation interface pseudo-device bridge 2 # network bridging support pseudo-device vlan 2 # IEEE 802.1Q VLAN -pseudo-device gre 1 # GRE encapsulation interface +#pseudo-device gre 1 # GRE encapsulation interface #pseudo-device strip 1 # Starmode Radio IP interface pseudo-device pty 64 # pseudo-terminals
To recompile your kernel, check out OpenBSD source via cvs (refer to AnonCVS web page for more information), apply the following patch, and rebuild your kernel as per FAQ 5, Building a kernel.
After you have the pptp package installed and a new kernel, you need to edit a few files to setup for your connection. This packages uses the in-house OpenBSD ppp(8), so if you are familiar with ppp(8), much of the setup is the same. Also, refer to FAQ 6, PPP.
For the /etc/ppp/options file, a setup like below will most likely do all that you need:
# cat /etc/ppp/options name "LOGINNAME" noauth noipdefault defaultroute debug
LOGINNAME should be replaced with your User-ID.
The /etc/ppp/pap-secrets a line like:
# cat /etc/ppp/pap-secrets LOGINNAME 10.0.0.138 PASSWORD
Where LOGINNAME is your User-ID and PASSWORD is your password. 10.0.0.138 is the IP assigned to your MODEM in the case that you are using ADSL, etc. Make sure this file stays readonly by root (mode 600).
In the above example, our modem came with a preconfigured interface of 10.0.0.138. We now need to assign an address to OUR interface. It's best to pick an IP close to the one given by your MODEM, or use the static IP assigned to you. Read more about setting up interfaces in FAQ 6, Setup.
Once your interface is setup, you should be able to create a pptp connection with the command:
# /usr/local/sbin/pptp 10.0.0.138 &
Since this uses the in-house OpenBSD ppp(8), two processes are started. You can kill pptp by killing both these processes:
# kill -9 [pid of pppd] $ kill -9 [pid of pptp]
It is recommended to open /var/log/messages in a extra terminal window, to recognize possible problems.
# tail -f /var/log/messages
We also suggest that you put the startup command in /etc/rc.local so that you automatically connect on reboot.
A bridge is a link between two or more separate networks. Unlike a router, packets transfer through the bridge "invisibly" -- logically, the two network segments appear to be one segment to nodes on either side of the bridge. The bridge will only forward packets that have to pass from one segment to the other, so among other things, they provide an easy way to reduce traffic in a complex network and yet allow any node to access any other node when needed.
Note that because of this "invisible" nature, an interface in a bridge may or may not have an IP address of its own. If it does, the interface has effectively two modes of operation, one as part of a bridge, the other as a normal, stand-alone NIC. If neither interface has an IP address, the bridge will pass network data, but will not be externally maintainable (which can be a feature).
One of my computer racks has a number of older systems, none of which have a built-in 10BASE-TX NIC. While they all have an AUI or AAUI connector, my supply of transceivers is limited to coax. One of the machines on this rack is an OpenBSD-based terminal server which always on and connected to the high-speed network. Adding a second NIC with a coax port will allow me to use this machine as a bridge to the coax network.
This system has two NICs in it now, an Intel EtherExpress/100 (fxp0) and a 3c590-Combo card (ep0) for the coax port. fxp0 is the link to the rest of my network and will thus have an IP address, ep0 is going to be for bridging only and will have no IP address. Machines attached to the coax segment will communicate as if they were on the rest of my network. So, how do we make this happen?
The file hostname.fxp0 contains the configuration info for the fxp0 card. This machine is set up using DHCP, so its file looks like this:
$ cat /etc/hostname.fxp0 dhcp NONE NONE NONE NONE
No surprises here.
The ep0 card is a bit different, as you might guess:
$ cat /etc/hostname.ep0 up media 10base2
Here, we are instructing the system to activate this interface using ifconfig(8) and set it to 10BASE-2 (coax). No IP address or similar information needs to be specified for this interface. The options the ep card accepts are detailed in its man page.
Now, we need to set up the bridge. Bridges are initialized by the existence of a file named something like bridgename.bridge0. Here is an example for my situation here:
$ cat /etc/bridgename.bridge0 add fxp0 add ep0 up
This is saying set up a bridge consisting of the two NICs, fxp0 and ep0, and activate it. Does it matter which order the cards are listed? No, remember a bridge is very symmetrical -- packets flow in and out in both directions.
That's it! Reboot, and you now have a functioning bridge.
Keep in mind, by the nature of a bridge, the same data flows through both interfaces, so you only need to filter on one interface. Your default "Pass all" statements would look something like this:
pass in on ep0 all pass out on ep0 all pass in on fxp0 all pass out on fxp0 all
Now, let's say I wish to filter traffic hitting these old machines, I want only Web and SSH traffic to reach them. In this case, we are going to let all traffic in and out of the ep0 interface, but filter on the fxp0 interface, using keep state to handle the reply data:
# Pass all traffic through ep0
pass in quick on ep0 all
pass out quick on ep0 all
# Block fxp0 traffic
block in on fxp0 all
block out on fxp0 all
pass in quick on fxp0 proto tcp from any to any port {22, 80} \
flags S/SA keep state
Note that this rule set will prevent anything but incoming HTTP and SSH traffic from reaching either the bridge machine or any of the other nodes "behind" it. Other results could be had by filtering the other interface.
To monitor and control the bridge you have created, use the brconfig(8) command, which can also be used to create a bridge after boot.
[Indeks FAQ] [Ke Bagian 5 - Membangun Sistem dari Kode Sumber [Ke Bagian 7 - Kendali Keyboard dan Tampilan]