Tampilkan postingan dengan label LINUX. Tampilkan semua postingan
Tampilkan postingan dengan label LINUX. Tampilkan semua postingan
Rabu, 28 November 2012
LINUX SETUP GATEAWAY WITH ROUTE COMMAND
Linux setup default gateway with route command
by NIXCRAFT on AUGUST 2, 2006 · 26 COMMENTS· last updated at AUGUST 16, 2007
Q. How do I setup default gateway with a route command?
A. route command show and/or manipulate the IP routing table under Linux and UNIX oses.
Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig program. When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.
Display default route
Following three-command display the current routing table:
# route
Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 ra0
default dsl-router 0.0.0.0 UG 0 0 0 ra0
$ /sbin/route
Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
191.255.255.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 191.255.255.1 0.0.0.0 UG 0 0 0 eth0
You can use -n option, to display numerical addresses instead of trying to determine symbolic host names (via dns or /etc/hosts file). This is useful if you are trying to determine why the route to your nameserver has vanished.
$ /sbin/route -n
Output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
191.255.255.0 0.0.0.0 255.255.255.0 U 0 0 0 venet0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 venet0
0.0.0.0 191.255.255.1 0.0.0.0 UG 0 0 0 venet0
Please note that a destionation entry 0.0.0.0 (or default) is the default gatway. In above example 191.255.255.1 is a default gatway.
Add / setup a new route
The syntax is as follows:
route add default gw {IP-ADDRESS} {INTERFACE-NAME}
Where,
IP-ADDRESS: Specify router IP address
INTERFACE-NAME: Specify interface name such as eth0
For example if your router IP address is 192.168.1.254 type the following command as the root user:
# route add default gw 192.168.1.254 eth0
OR use hostname such as dsl-router:
# route add default gw dsl-router eth0
Setting route using GUI tools/command under Linux
If you find above command hard to use, consider using GUI tools. If your are using Red Hat/CentOS/Fedora core Linux type following command:
# redhat-config-network
OR If you are using other Linux distribution use command:
# network-admin
BACKUP DATA UNTUK 2 SERVER LINUX
Memakai Linux sebagai sistem operasi memiliki banyak kelebihan. Selain tahan virus, banyak fungsi-fungsi otomatis yang bisa dilakukan melalui script. Misalnya untuk melakukan backup atau sinkronisasi antar dua file-sharing server bisa dilakukan dengan command scp (server copy) yang dikombinasikan dengan cron untuk otomatisasi (scheduling).
Command scp memerlukan fungsi ssh (secure shell) untuk bisa tersambung dengan remote server. Supaya ssh bisa langsung connect tanpa mengisikan password, caranya sebagai berikut :
1. Buat sebuah private/public key di local server
ssh-keygen -t rsa
2. Copykan public key tersebut ke remote server
scp ~/.ssh/id_rsa.pub remote_host:
3. Tambahkan key tersebut ke remote server trusted key
Login ke remote server. Jika belum pernah membuat key sama sekali, jalankan ssh-keygen -t rsa guna menyiapkan directory untuk key.
Kemudian tambahkan key yang baru dibuat tadi ke file authorized_keys
Your ads will be inserted here by
Easy AdSense.
Please go to the plugin admin page to paste your ad code.
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
Ubah akses level file dengan command :
chmod 644 ~/.ssh/authorized_keys
4. Sekarang coba anda login ke remote server melalui ssh
ssh username@remote_server
Jika langkah-langkah diatas benar, harusnya anda bisa masuk tanpa perlu mengetikkan password.
5. Buat script untuk copy file dari remote server
scp username@remote_server:/remote_dir /local_dir
Simpan command tersebut ke sebuah file (misal: mybackup.sh) dan ubah mode filenya dengan chmod 755 mybackup.sh
Copykan file mybackup.sh ke directory /etc/cron.daily supaya bisa running otomatis tiap hari.
Langganan:
Postingan (Atom)