Get cash from your website. Sign up as affiliate.
4000 TV channels
Download TV Software. It's safe to install.
Safe to install software
Download TV Software. It's safe to install.
Number one rated software

Nov 14, 2009

seting network

Wearing Linux on notebooks is a pride in itself, because the install sometimes requires more effort than when installed on the PC desktop, because Linux drivers are available for hardware notebooks are still relatively few desktop PCs, especially network card driver, modem, infrared port ( IrDA), and bluetoothnya. Ok, when finally installed Linux successfully, obstacles arise when we use this notebook in a different location ... ... let's say in the office and at home. Because chances are the network settings at work and at home is different, whether it's IP address, Gateway, DNS, etc.. Will be very inconvenient if we have any time to change the network settings of our notebook when moving from office to home, and back again the next day the office.

This article will discuss an efficient trick how to use the script to make the network settings automatically and quickly. The author uses Mandrake 9.2, but this script can also for other distributions by adjusting the location of files and startup scripts in the distro in question.

Well, we started well. Setting-network setting in the following files are:
/etc/resolv.conf --> berisi settingan DNS.

/etc/sysconfig/network --> berisi settingan hostname, dan gateway.

/etc/sysconfig/network-scripts/ifcfg-eth0 --> berisi settingan kartu network kita, yaitu IP address, netmask, network address, broadcast address, dll.

Maybe someone says, "But I never touch the configuration files, how about when wrong?" Do not worry, you only need to change the relevant information only. To give an illustration, these files typically contain the following:

[fajar@centrino fajar]$ cat /etc/resolv.conf

search linux.home

#nameserver 192.168.0.234

#nameserver 202.158.3.7

nameserver 202.157.48.8


[fajar@centrino fajar]$ cat /etc/sysconfig/network

HOSTNAME=centrino.linux.home

NETWORKING=yes

GATEWAY=192.168.7.25


[fajar@centrino fajar]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=static

IPADDR=192.168.4.29

NETMASK=255.255.255.248

NETWORK=192.168.4.24

BROADCAST=192.168.4.31

ONBOOT=yes

HWADDR=00:c1:9e:28:01:65

MII_NOT_SUPPORTED=no


Ketiga file itulah yang harus kita ubah mengikuti ketentuan yang ada di masing-masing lokasi. Misalkan di rumah kita memakai settingan jaringan sebagai berikut:

Nameserver 202.127.5.6

IP 192.168.0.5

Netmask 255.255.255.0

Network 192.168.0.0

Broadcast 192.168.0.255


Sedangkan di kantor kita memakai settingan sebagai berikut:

Nameserver 192.168.4.100

IP 192.168.4.29

Netmask 255.255.255.248

Network 192.168.4.24

Broadcast 192.168.4.31











So we can imagine that we would be bothered at all if every time we are in different locations that we must change the network settings by editing the configuration files mentioned above. If we use the configuration menu from any distribution will still be trouble, right?
Then what? Well, here is the trick:
We will use the shell environment that has been provided in our distro. This time the authors use the BASH shell.
Step 1. Make a configuration file for each location (file name up to you, which is important to distinguish between these different locations). The contents of configuration files are tailored to what we need in each location.

/etc/resolv.conf-rumah

/etc/resolv.conf-kantor

/etc/sysconfig/network-rumah

/etc/sysconfig/network-kantor

/etc/sysconfig/network-scripts/ifcfg-eth0-rumah

/etc/sysconfig/network-scripts/ifcfg-eth0-kantor

If you are unsure or worried about one, the easiest way is to copy configuration files into the original file name you want, then you edit the file copy of these with the desired settigan.


Step 2. Write this script using your favorite text editor:

2a. Script for the home network.




#!/bin/bash

cp -v /etc/resolv.conf-rumah /etc/resolv.conf

cp -v /etc/sysconfig/network-rumah /etc/sysconfig/network

cp -v /etc/sysconfig/network-scripts/ifcfg-eth0-rumah /etc/sysconfig/network-scripts/ifcfg-eth0

service network restart


aka netrumah = "/ root / .netrumah"

aka netkantor = "/ root / .netkantor"


Then as root, run this command for both is stored into the shell environment:

bash

Ok, easy right? Let us test. As root, we have to do is type:

netrumah <- to set the network when at home netkantor <- when he was in office when the command is executed will appear as can be seen in figure 1: Check whether the network has been finely tuned correctly with the command: ifconfig example in Figure 2. Then test by trying to browse the internet. When was the way, means you have succeeded. Congratulations:) The use of other than bash environment. As you can see at the beginning of this paper, that we can create our own command in the bash, which this can we use to make the things we often do on the server. For example, as a sysadmin, of course we often need to monitor the log-log files from our server. Of course we often type the command-command like: tail-f / var / log / messages tail-f / var / log / squid / access.loh tail-f / var / log / httpd / access_log tail-f / var / log / httpd / error_log I mean, typing command-command is not long, especially if there is bash history. But it would be nice if we could shorten the command-command again it becomes a shorter, right? It's easy, just like when entering the command netrumah / netkantor above. Enter the command lines that we want into the file / root / .bashrc. Like this: alias tailm = "tail-f / var / log / messages' alias tails =" tail-f / var / log / squid / access.log "alias tailhttpd =" tail-f / var / log / httpd / access_log "alias tailhttpderr =" tail-f / var / log / httpd / error_log "When you're done, save the file. bashrc and run type 'bash' at the console for additional mengsave. Now try running 'tailm' and see the results, so easy, is not it? :) As can be seen in Figure 3. So this writing, it would be useful for us all. If there are less obvious can contact the author at fajarpri (at) arinet (dot) org or through the website at http://linux2.arinet.org Thank you. v.1.0 by ari_stress aka tiger74 aka Fajar Priyanto Jakarta, March 12, 2005. fajarpri at arinet dot org. The author is a Microsoft Certified Professional, who fell in love with Linux. Working in an educational institution in Jakarta Last Updated (Saturday, 12 March 2005)



0 comments:

Post a Comment