How to make two network segments work at the same time (frequently switch the external network exit)

How to make two network segments work at the same time (frequently switch the external network exit)
Both network segments of the company must be used.
Wired network, 6 network segments, experimental network. net 192.168.6.0, netmast 255.255.255.0
alone network time, You can access the external network, which will send and receive multicast data.
The data of the network segment net 239.0.0.0, netmast 255.0.0.0

Wireless network, 1 network segment, work network. net 192.168.1.0, netmast 255.255.255.0,  
when there is a single network, you can access the external network. A git server is arranged on this network. I monitored it and its ip address is 222.128.105.173
I don't quite understand how they set up a 222.128.105.174 server on segment 1. Is it leased? It's not like setting up by yourself.
(Traceroute goes a long way), and I don't know why segment 6 can't access it .These
two network segments are not connected to each other. I know this.

When both networks are open, check with route, there will be two default gateways, but because the priority of the wireless network card is low (the hop is 600), the wired hop is 100, in fact, the
default gateway is still wired, so at this time Still can’t access the git server of 1 network segment.
The usual way is to work with 1 network segment. When you need to use the git server, close 1 network segment and open 6 network segments. I have worked in this environment for 1 year. The feeling
is It’s too low, can these two network segments work at the same time?!
And the company still has problems from time to time. If network segment 6 cannot access the Internet, then use network segment 1. If network segment 1 cannot access the Internet, then use network 6 segment. So there will also be switching requirements.
Both networks can’t access the Internet, so I can only byebye, haha!

Solution:
route belongs to the tools in the net-tools toolkit.

Specific operation method: 2 kinds, choose one

1. Delete the default gateway route of network segment 1, leaving only network segment 6 as the default route
$ sudo route del 0.0.0.0 gw 192.168.1.1

2. Add the git server address to network segment 1
$ sudo route add -host 222.128.105.173 gw 192.168.1.1


Another
1. Delete the default gateway route of 6 network segments, leaving only 1 network segment as the default route
$ sudo route del 0.0.0.0 gw 192.168.6.1

2. Add the 239 network segment to the 6 network segment
$ sudo route add -net 239.0.0.0 netmask 255.0.0.0 gw 192.168.6.1
It means that all data accessing the 239.0.0.0 network segment must pass through the gateway 192.168.6.1,

The problem is solved.
The problem of route loss at start-
up makes the route permanent under ubuntu, and it also involves whether the network is managing the network or the netowrkManager is managing the network. It’s really troublesome! Forget it, write
a script, you can execute it when you need it, or you can add it directly Call in .bashrc to combine the two requirements, actually add two routes, this is easy ,
and select the external network is 1 network segment or 6 network segments according to user input
.
Segment Internet
access./myroute.sh 6: 6 network segments to access the Internet

The script content is as follows:
$ cat myroute.sh
#!/bin/bash
temp_var=$(route -n)

# help display
if [ $# -ne 1 ]
then
    echo "Usage $0 <1 or 6 >"
    exit 0
fi

# Adjust the default gateway
if [ "$1" == "1" ] #When the input parameter is 1, delete 6 gateways and add 1 gateway then
if
    echo $temp_var | grep -q "0.0.0.0 192.168.6.1"
    then
        sudo route del -net 0.0.0.0 gw 192.168.6.1
    fi
    if echo $temp_var | grep -q "0.0.0.0 192.168.1.1"
    then
        echo "default gate 192.168.1.1 has exist"
    else
        sudo route add -net 0.0.0.0 gw 192.168. 1.1
    fi
    
fi

if [ "$1" == "6" ] #When the input parameter is 6, delete gateway 1 and add gateway 6 then
if
    echo $temp_var | grep -q "0.0.0.0 192.168.1.1"
    then
        sudo route del -net 0.0 .0.0 gw 192.168.1.1
    fi
    if echo $temp_var | grep -q "0.0.0.0 192.168.6.1"
    then
        echo "default gate 192.168.6.1 has exist."
    else
        sudo route add -net 0.0.0.0 gw 192.168.6.1
    fi
    
fi
# Add a route to access the gitserver website
if echo $temp_var | grep -q "222.128.105.173 192.168.1.1"
then
    echo "already add the net:222.123.105.173 gw 192.168.1.1"
else
    sudo route add -host 222.128.105.1923.gw 6 .1.1
fi

# Add a route to access the broadcast

if echo $temp_var | grep -q "239.0.0.0 192.168.6.1"
then
    echo "already add the net:239.0.0.0 gw 192.168.6.1"
else
    sudo route add -net 239.0.0.0/8 gw 192.168.6.1
fi
# show routing table
route -n

Guess you like

Origin blog.csdn.net/hejinjing_tom_com/article/details/129579180