Route LAN Users to IPPBX on CentOS 7 Using eth1
In this article, we will discuss how to configure a CentOS 7 server to route Local Area Network (LAN) users to an IP Private Branch Exchange (IPPBX) system through the eth1 network interface. We will cover key concepts, provide detailed context on the topic, and use subtitles to organize the content. Code blocks will be properly formatted with the appropriate programming language syntax, including indentation and tabulation where needed.
Prerequisites
Before we begin, make sure you have a CentOS 7 server up and running. You can check the network interfaces using the ifconfig command. The output should show two network interfaces, eth0 for LAN users and eth1 for the IPPBX system. For example, the eth0 interface should display the following flags: eth0: flags=4163<.
Configuring the Network Interfaces
To configure the network interfaces on CentOS 7, we will edit the /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-eth1 files. First, open the ifcfg-eth0 file using your preferred text editor, such as vi, and make sure the following lines are present:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=<unique-uuid>
ONBOOT=yes
IPADDR=<lan-ip-address>
NETMASK=<lan-netmask>
GATEWAY=<lan-gateway>
Next, edit the ifcfg-eth1 file and include the following lines:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_FAILURE_FATAL=no
NAME=eth1
UUID=<unique-uuid>
ONBOOT=yes
IPADDR=<ippbx-ip-address>
NETMASK=<ippbx-netmask>
Once the network interface configurations have been updated, restart the networking service to apply the changes:
sudo systemctl restart network
Routing LAN Users to IPPBX
To route LAN users to the IPPBX system, we need to configure the routing table. Edit the /etc/sysctl.conf file and uncomment or add the following line:
net.ipv4.ip_forward = 1
Next, save the file and run the following command:
sudo sysctl -p
Lastly, create a new routing rule using the ip route command:
sudo ip route add <ippbx-subnet> via <ippbx-ip-address> dev eth1
- Checked the network interfaces using the
ifconfigcommand. - Edited the
ifcfg-eth0andifcfg-eth1files to configure the network interfaces. - Restarted the networking service using
sudo systemctl restart network. - Updated the
/etc/sysctl.conffile to enable IP forwarding. - Applied the sysctl configuration using
sudo sysctl -p. - Created a routing rule using the
ip routecommand.
References
- CentOS 7 Documentation: https://docs.centos.org/en-US/7/networking/
- IP Forwarding in Linux: https://www.xmodulo.com/enable-ip-forwarding-linux.html
- IP Route Command: https://linux.die.net/man/8/ip