Tuesday, February 4, 2014

How to redirect traffic from one IP to another IP


/sbin/iptables -t nat -A PREROUTING -p icmp -d 10.106.210.176 -j DNAT --to-destination 10.20.1.2


To view whatever is configured:

/sbin/iptables -t nat -vnL --line-number  (with nat)
/sbin/iptables -vnL --line-number           (without nat)



To Delete/remove :
/sbin/iptables -D FORWARD 1   (without nat and 'FORWARD' is the policy, replace accordingly from whatever is listed from above command output)

another example to delete with nat:
/sbin/iptables -t nat -D PREROUTING 1   (here 1, 2 ..3 are the line-numbers which will get listed from view command)

.VIMRC file



:set nocompatible
:set bs=2
:set expandtab
:set tabstop=4
:set shiftwidth=4
:set showmatch
:set mouse=a
:set virtualedit=all
:set nu
syntax enable
set hlsearch
set incsearch
set ignorecase
set smartcase


set t_Co=128
highlight DiffAdd cterm=NONE ctermfg=Black ctermbg=Green gui=NONE guifg=Black guibg=Green
highlight DiffDelete cterm=NONE ctermfg=Black ctermbg=Red gui=NONE guifg=Black guibg=Red
highlight DiffChange cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Black guibg=Yellow
highlight DiffText cterm=NONE ctermfg=Black ctermbg=Magenta gui=NONE guifg=Black guibg=Magenta