LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2019, 04:50 AM   #1
Ogly213
LQ Newbie
 
Registered: Sep 2019
Posts: 2

Rep: Reputation: Disabled
Unhappy need help with programming


okey.. i will try to resume my problem

i have 2 network's cards with different Internet providers
one is on 192.168.1.38 and another is on 192.168.8.1 (most likely a ppp0)

i access through Squid to 192.168.1.38 public ip but we are not going to work with that ethernet we are going to work on
192.168.8.1 public ip

my question is how we can redirect all the traffic and then access through 192.168.1.38 public ip and get redirected as 192.168.8.1 public ip

i have been working on this 2 weeks, i made it on local, but somehow on external doesn't work very well, could you mind lend me a hand?
 
Old 09-12-2019, 06:14 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,445

Rep: Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902
While I doubt I can help you with network programming, I have suggestions how to ask a better question.

Quote:
Originally Posted by Ogly213 View Post
my question is how we can redirect all the traffic and then access through 192.168.1.38 public ip and get redirected as 192.168.8.1 public ip
This is confusing. You want to access what from where? Do you mean all traffic that comes in via one NIC should be rerouted to the other NIC? Have you investigated whether netfilter (iptables command) allows you to do that?

Quote:
i have been working on this 2 weeks, i made it on local, but somehow on external doesn't work very well, could you mind lend me a hand?
I don't think anybody will lend you a hand unless you state a few fundamental facts, such as the programming language(s) you use, the program that works "on local", and what the symptoms are when it doesn't work "on external".
 
Old 09-12-2019, 06:20 AM   #3
Ogly213
LQ Newbie
 
Registered: Sep 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
While I doubt I can help you with network programming, I have suggestions how to ask a better question.


This is confusing. You want to access what from where? Do you mean all traffic that comes in via one NIC should be rerouted to the other NIC? Have you investigated whether netfilter (iptables command) allows you to do that?


I don't think anybody will lend you a hand unless you state a few fundamental facts, such as the programming language(s) you use, the program that works "on local", and what the symptoms are when it doesn't work "on external".


okey, let's be more clear

i have tried all this.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 20000 -j DNAT --to-destination 192.168.8.1
iptables -A FORWARD -i eth0 -o eth1 -p tcp --dport 20000 -j ACCEPT
iptables -I FORWARD -o eth1 -s 192.168.1.0/16 -j ACCEPT
iptables -I INPUT -s 192.168.1.0/16 -j ACCEPT

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

iptables -A INPUT -i lo -j ACCEPT

iptables -A INPUT -i eth0 -j ACCEPT

iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT

iptables -t nat -A PREROUTING -s 192.168.1.38 -p tcp --dport 20000 -j DNAT --to-destination 192.168.8.100

iptables -t nat -A PREROUTING -d 192.168.1.38 -j DNAT --to-destination 192.168.8.100
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -A INPUT -i eth1 -j ACCEPT
iptables -t nat -A PREROUTING -s 192.168.1.0/16 -i eth1

^
|
this worked on local
i'm trying to redirect the traffic that comes to NIC to another NIC on port 20000
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
future of programming, programming jobs, programming languages? detr Programming 17 08-01-2016 03:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration