Policy Based Routing

From Hurlster Wiki
Revision as of 04:31, 17 April 2011 by Gqwill69 (talk | contribs) (→‎Add to startup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Build Policy Based Routing

This method only uses ip route not iptables

user@server:~$ netstat -rne
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
167.142.40.128  0.0.0.0         255.255.255.224 U     0      0        0 eth1
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    200    0        0 eth0
#echo 1 1 >> /etc/iproute2/rt_tables
#echo 2 2 >> /etc/iproute2/rt_tables
#ip route add default via 192.168.0.254 dev eth0 table 1
#ip route add default via 167.142.40.142 dev eth1 table 2
#ip route show table 1
default via 192.168.0.1 dev eth0
#ip route show table 2
default via 167.142.40.129 dev eth1
#ip rule add from 192.168.0.254/32 table 1 priority 500
#ip rule add from 167.142.40.142/32 table 2 priority 600
#ip rule show
0:      from all lookup local 
500:  from 192.168.0.254 lookup 1
600:  from 167.142.40.142 lookup 2 
32766:  from all lookup main 
32767:  from all lookup 253 
#ip route flush cache

Add to startup

root@server:~# more /etc/rc.local 
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Policy Based Routing
ip route add default via 192.168.0.254 dev eth0 table 1
ip route add default via 167.142.40.142 dev eth1 table 2
ip rule add from 192.168.0.254/32 table 1 priority 500
ip rule add from 167.142.40.142/32 table 2 priority 600
ip route flush cache

exit 0

USB Network Interface

USB 2.0 dongle doesn't pass traffic but shows up and active
Manual driver installation is required.

http://www.hurlster.com/wiki/AX88772B_772A_760_772_178_LINUX_Driver_v4.1.0_Source.tar.bz2

USB Installation

1. Extract the compressed driver source file to your template directory by the following command:

       [root@localhost template]# tar -xf DRIVER_SOURCE_PACKAGE.tar.bz2

2. Now, the driver source files should be extracted under the current directory. Executing the following command to compile the driver:

        [root@localhost template]# make

3. If the compilation is well, the asix.ko will be created under the current directory.

4. If you want to use modprobe command to mount the driver, executing the following command to install the driver into your Linux:

       [root@localhost template]# make install

USB Usage

1. If you want to load the driver manually, go to the driver directory and execute the following commands:

       [root@localhost template]# insmod asix.ko

2. If you had installed the driver during driver compilation, then you can use the following command to load the driver automatically.

       [root@localhost anywhere]# modprobe asix

If you want to unload the driver, just executing the following command:

       [root@localhost anywhere]# rmmod asix