Tag Archives: add

How to Add Linux route ?

You can use any one of the following tool to add, display, delete Linux kernel routing table:

(a) route command : show / manipulate the IP routing table on Linux.

(b) ip command : show / manipulate routing, devices, policy routing and tunnels on Linux.

Display your current routing table

Open the Terminal or login to server using ssh/console. Type the  following command to display routing table:

# route
 OR
# route -n

route

 # ip route show
 OR
 # ip route list

Linux add a default route using route  command

Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:

 # route add default gw 192.168.1.254 eth0

Linux add a default gateway (route) using ip command

Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:

 # ip route add 192.168.1.0/24 dev eth0

Verify newly added route ip in the Linux kernel routing table

To verify new routing table, enter:
 # ip route list
 OR
 # route -n

How do I make routing changes persistent across reboots?

To make route entry persistent in the Linux kernel routing table, you need to modify config file as per your Linux distributions.

RHEL/CentOS/Fedora/Scientific Linux persistent routing configuration

Edit /etc/sysconfig/network and set default gateway IP address:
# vi /etc/sysconfig/network
Sample outputs:

GATEWAY=192.168.1.254

You can add additional static route for eth0 by editing /etc/sysconfig/network-scripts/route-eth0 file as follows:

10.0.0.0/8 via 10.10.29.65

The above config sets static routing for network 10.0.0.0/8 via 10.9.38.65 router.

Debian / Ubuntu Linux persistence static routing configuration

Edit /etc/network/interfaces file, enter:
# vi /etc/network/interfaces
Append the following in eth0 section:

up route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254
down route del -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254

Save and close the file.

Generic method to add persistent static routing on Linux

The following method works with almost all Linux distributions.

Edit /etc/rc.d/rc.local or /etc/rc.local, enter
# vi /etc/rc.local
Append the following line:

/sbin/ip route add 192.168.1.0/24 dev eth0

Save and close the file.

How to add a repository manually in RHEL6

Red Hat Enterprise Linux 6 (RHEL6) repository configurations.

yum looks at /etc/yum.repos.d/*.repo for enabled repository.

Create a file IntraNet.repo:

[IntraNet]
name=Local Network Repository for RHEL6 $releasever – $basearch
baseurl=ftp://x.x.x.x/RHEL6-GA-x86_64/
enabled=1
gpgcheck=0

Save and close the file.

[IntraNet]: Repository name i.e. The [IntraNet] section must exist for yum to do anything.
name=Local Repository for RHEL6 $releasever – $basearch: A human readable string describing the repository name.
baseurl=ftp://x.x.x.x/RHEL6-GA-x86_64/: Must be a URL to the directory where the yum repository’s ‘repodata’ directory lives. x.x.x.x is the ip address.
enabled=1: Enabled or disabled repo. To disable the repository temporarily, set the enabled=0.

############################################################

To setup a repository to use a locally mounted DVD with RHEL6

Create a dvd.repo text file in /etc/yum.repos.d/ with the following content:
[dvd]
mediaid=xxxxxxxxxx.xxxxxx
name=DVD for RHEL6
baseurl=file:///media/RHEL_xxxxxxxxxxxDVD/Server
enabled=1
gpgcheck=0

mediaid: Value comes from the .discinfo file located in the root of the DVD

To add a local repository in your hard drive.

Append the file localRepo:
# cd /etc/yum.repos.d
# vi localRepo.repo

############################################################
[localRepo]
name=localRepo
baseurl=file:///rhel6/RHEL6-GA-x86_64/
enabled=1
gpgcheck=0

# mkdir /rhel6
Moved all RHEL DVD files to this Directory /rhel6
# cd /rhel6

Installed createrepo RPM
# createrepo -v

############################################################

Run:
# yum clean all

To list packages:
# yum list
Or to list packages beginning with fc:
# yum list fc*

To install a package
# yum install rpm
where rpm is the name of the package.

Add a RAM File System in Aix

Create a RAM disk of 10 MB

# mkramdisk 10M

/dev/rramdisk0

Create a JFS File System on this RAM disk

# mkfs -V jfs /dev/rramdisk0

mkfs:destroy /dev/rramdisk0 (yes) ? y

Create Mountpoint

# mkdir /ramdisk

Mount  RAM File System

# mount -V jfs -o nointegrity /dev/ramdisk0 /ramdisk

The purpose of the mkramdisk command is to create file systems directly in memory. This is useful for applications that make many temporary files. Use ramdisk only for data that can be lost. After each reboot the ramdisk file system is destroyed and must be rebuilt.

Linux add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

 

a) Login as the root user

 

b) Type following command to create 512MB swap file (1024 * 1024MB = 1048576 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576

 

c) Set up a Linux swap area:
# mkswap /swapfile

 

d) Activate /swapfile1 swap space immediately:
# swapon /swapfile

 

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab

 

Append following line:
/swapfile swap swap defaults 0 0

 

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

 

g) How do I verify swap is activated or not?
Simply use free command:
$ free -m