![]() |
Feel free with Open Source SoftwareAndries Filmer - Internet professional sinds 1996.
|
|
|
|
Networking on linuxSome notes for networking on GNU / linux
netstatList internet services on a systemnetstat -tupl List active connections to/from system netstat -tup
Network tools
apt-get install ethtool net-tools Output eth0 configuration options
ethtool eth0 Same with MII View (or manipulate media-independent interface) status
mii-tool eth0 Change the speed and duplex settings Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD mii-tool -F 100baseTx-HD mii-tool -F 10baseT-HDSetup Negotiated speed with ethtool ethtool -s eth0 speed 100 duplex full ethtool -s eth0 speed 10 duplex half
IP TunellingWe will do IPv4 tunneling using GRE. GRE is a tunneling protocol that was originally developed by Cisco, and it can do a few more things than IP-in-IP tunneling. For example, you can also transport multicast traffic and IPv6 through a GRE tunnel. We are using Debian with linux kernel 2.4.26. In Linux, you'll need the ip_gre.o module.
Starting ConfigurationWe have 2 routers X and Y, and intermediate network C (or let's say, Internet).
router X Router X is connected to the Internet on interface eth0 and network A on eth1.
interface eth0 :: address 169.229.255.134 on the Internet (or network C) interface eth1 :: address 10.0.2.1, network 10.0.2.0/24 (network A)
router Y Router Y is connected to the Internet on interface eth0, network B on eth1 and network C on eth2.
interface eth0 :: address 207.241.237.37 on the Internet (or network C) interface eth1 :: address 10.0.3.1, network 10.0.3.0/24 (network B) interface eth2 :: address 10.0.4.1, network 10.0.4.0/24 (network C) As far as network C is concerned, we assume that it will pass any packet sent from X to Y and vice versa. How and why, we do not care.
Tunnelling ObjectiveCreate a tunnel between router X and Y, such that we can route traffic from network A (connected to X) to networks B and C (connected to Y). This tunnel will look just like a wire between the two routers with its own subnet (10.0.201.0/24)
Create Tunnels On router X, commands are
iptunnel add tunX mode gre remote 207.241.237.37 local 169.229.255.134 ttl 225 ifconfig tunX 10.0.201.1/24 ifconfig tunX up ifconfig tunX pointopoint 10.0.201.2 ifconfig tunX multicast
One router Y, commands are
iptunnel add tunY mode gre local 207.241.237.37 remote 169.229.255.134 ttl 225 ifconfig tunY 10.0.201.2/24 ifconfig tunY up ifconfig tunY pointopoint 10.0.201.1 ifconfig tunY multicast
Tunnel X<->Y
routerX ----------------tunnel-----------------routerY
10.0.201.1 10.0.201.2
(tunX) (tunY)
We can send packets on the 10.0.201.0/24 network from router X to Y and vice versa. So we can ping router X from Y on the tunnel interface.
routerX# ping 10.0.201.2 routerY# ping 10.0.201.1
Additional RoutesHowever, if we to send packets to network B or C from router X, we need to add routes so that traffic for these networks is sent on the tunnelling interface. On router X:
route add -net 10.0.3.1/24 gw 10.0.201.1 dev tunX route add -net 10.0.4.1/24 gw 10.0.201.1 dev tunX Similarily, to send packets to network A from router Y, we need to add a route. On router Y:
route add -net 10.0.2.1/24 gw 10.0.201.2 dev tunY
Delete TunnelsOn router X:
ifconfig tunX down iptunnel del tunX
Network Diagram
(network A)
10.0.2.1, eth1
|
___|_________
| Router X |
|_____________|
| 169.229.255.134 (eth0)
| (Internet or network C)
|
|
| | 10.0.201.1 (tunX)
| |
| |
| | (gre tunnel: 169.229.255.134 <-> 207.241.237.37)
| |
| |
| | 10.0.201.2 (tunY)
|
| (Internet or network C)
| 207.241.237.37 (eth0)
___|___________
| Router Y |
|_______________|
| |
| |
10.0.3.1 10.0.4.1
eth1 eth2
(network B) (network C)
Debian Configuration
router X: /etc/network/interfaces
auto tun0
iface tun0 inet static
address 10.0.201.1
netmask 255.255.255.0
broadcast 10.0.201.255
up ifconfig tun0 multicast
pre-up iptunnel add tun0 mode gre remote 207.241.237.37 local 169.229.255.134 ttl 255
pointopoint 10.0.201.2
post-down iptunnel del tun0
router Y: /etc/network/interfaces
auto tun0
iface tun0 inet static
address 10.0.201.2
netmask 255.255.255.0
broadcast 10.0.201.255
up ifconfig tun0 multicast
pre-up iptunnel add tun0 mode gre local 207.241.237.37 remote 169.229.255.134 ttl 255
pointopoint 10.0.201.1
post-down iptunnel del tun0
Reference: http://tier.cs.berkeley.edu/wiki/HOWTO:IPTunnelling
Redirect ip-address portRedirect ip-address port to other server port/usr/local/bin/redir --laddr 82.201.122.21 --lport 80 --caddr 194.242.19.13 --cport 80
I appreciate if you give some comment about this page. Please go ahead. |
|
Andries Filmer | http://andries.filmer.nl | andries@filmer.nl | © 2011
|